Note 📣 After May 8, 2023, all API requests without an API key will return an error. Legacy code examples may contain requests without API keys. Follow this guide for how to get a live API key and use it for any 0x products.
Learn how to build a token swapping dapp, similar to a simple Matcha.xyz, using the 0x /swap API endpoint.
This app aggregates liquidity across the greater DEX ecosystem using 0x to surfaces the best price to the user and allow them to easily settle their trades!
- 💦 What is liquidity aggregation?
- 🪟 Query + Display an ERC20 token list
- ♻️ Use @0xProject API's /swap endpoint
- 🧱 Build a Swap Dapp with Metamask and Web3.js
- 🎥 Watch Video Walk-Through: https://www.youtube.com/watch?v=tVvZ1ivp4X0
- 📖 Full Written Tutorial: https://docs.alchemy.com/alchemy/road-to-web3/weekly-learning-challenges/9.-how-to-build-a-token-swap-dapp-with-0x-api
- The repo is broken up by parts which correspond to parts in the written tutorial above ☝️ Each part builds upon the previous one.
- Part 1. Walk-through Starter Code
- Part 2. Connect to MetaMask
- Part 3. Create a Modal for the Token List
- Part 4. Fetch and Display Token List from CoinGecko API
- Part 5. Display Selected Token Image and Symbol in Swap Box
- Part 6. Get Price
- Part 7. Get Quote
- Part 8. Set a Token Allowance
- Part 9. Perform the Swap
- Jessica Lin
- Developer Advocate, 0x Labs.
- How to use Live Server Extension.
- GetToken a token info from https://tokenlists.org/
- Get source from CoinGecko https://tokens.coingecko.com/uniswap/all.json
- Why need wrapped ETH : https://support.opensea.io/hc/es/articles/360063498293--Qu%C3%A9-es-WETH-C%C3%B3mo-lo-consigo-
- WETH to DAI in Match.xyz: https://www.matcha.xyz/markets/1/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2/0x6b175474e89094c44da98b954eedeac495271d0f
- 0x api Documentation : https://0x.org/docs/0x-swap-api/api-references/get-swap-v1-quote
- Browserify, lets you require('modules') in the browser by bundling up all of your dependencies: https://browserify.org/
- install 'qs'
- Open Zeppelin Documentation Aprove Api for a token erc 20: https://docs.openzeppelin.com/contracts/4.x/api/token/erc20#IERC20-Approval-address-address-uint256-
- how to set your token allowances with 0x API: https://0x.org/docs/0x-swap-api/advanced-topics/how-to-set-your-token-allowances
- Documentation from Web3.Js contract, transaction confirm doc: https://web3js.readthedocs.io/en/v1.10.0/web3-eth-contract.html#transactionconfirmationblocks
- Create a DEX Aggregator DAPP
https://testnets.opensea.io/assets/goerli/0xf4910c763ed4e47a585e2d34baa9a4b611ae448c/5650374730150659443715928048758275365410007916752074954041965403840314343425