Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update swap v2 allowance holder readme #52

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions swap-v2-allowance-holder-headless-example/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# Swap v2 AllowanceHolder headless example (viem)

A headless example of how to use 0x Swap API v2 `/allowance-holder/price` and `/allowance-holder/quote` using [viem](https://viem.sh/)
A headless example of how to use 0x Swap API v2 `/allowance-holder/price` and `/allowance-holder/quote` using [viem](https://viem.sh/).

Demonstrates the following on Base mainnet:

1. [Get a 0x API key](https://0x.org/docs/introduction/getting-started)
2. Get an indicative price (sell 0.1 USDC → buy WETH)
3. (If needed) Set token allowance for AllowanceHolder
4. Fetch a firm quote (sell 0.1 USDC → buy WETH)
5. Send transaction.
5. Send transaction

### What is the difference between Permit2 and AllowanceHolder?
> [!WARNING]
> This is a demo, and is not ready for production use. The code has not been audited and does not account for all error handling. Use at your own risk.

## What is the difference between Permit2 and AllowanceHolder?

<details>
<summary>What is the difference between using Permit2 and AllowanceHolder for Swap API?</summary>
<summary>Expand to read about the difference between using Permit2 and AllowanceHolder for Swap API.</summary>

0x Swap API allows you to choose between two allowance methods: [Permit2](https://0x.org/docs/introduction/0x-cheat-sheet#permit2-contractcontract) or [AllowanceHolder]([../introduction/0x-cheat-sheet#allowanceholder-contract](https://0x.org/docs/introduction/0x-cheat-sheet#allowanceholder-contract)).

Expand Down Expand Up @@ -51,10 +54,7 @@ Still have questions? [Reachout to our team](https://0x.org/docs/introduction/co
</details>


> [!WARNING]
> This is a demo, and is not ready for production use. The code has not been audited and does not account for all error handling. Use at your own risk.

### Requirements
## Requirements

- Install [Bun](https://bun.sh/) (v1.1.0+)
- An Ethereum private key
Expand Down