I am following this tutorial teaching how to swap tokens using Uniswap V3 with ethers.js (link). Its codebase is here. However, it's for the Ropsten testnet which has already been deprecated. I am trying to convert the code for Goerli testnet. Based on Uniswap's documentation, I made a few changes including changing the address of the native token (WETH) to
const name0 = "Wrapped Ether"; const symbol0 = "WETH"; const decimals0 = 18; const address0 = "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6"; When I run the code, I got this error: var error = new Error(message); ^ Error: call revert exception (method="token0()", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.5.0) at Logger.makeError (C:\MyCodeProject\learn\etherjs\tut_ethersJsByDappUniversity\ethers_examples\node_modules\@ethersproject\logger\lib\index.js:199:21) at Logger.throwError (C:\MyCodeProject\learn\etherjs\tut_ethersJsByDappUniversity\ethers_examples\node_modules\@ethersproject\logger\lib\index.js:208:20) at Interface.decodeFunctionResult (C:\MyCodeProject\learn\etherjs\tut_ethersJsByDappUniversity\ethers_examples\node_modules\@ethersproject\abi\lib\interface.js:384:23) at Contract.<anonymous> (C:\MyCodeProject\learn\etherjs\tut_ethersJsByDappUniversity\ethers_examples\node_modules\@ethersproject\contracts\lib\index.js:390:56) at step (C:\MyCodeProject\learn\etherjs\tut_ethersJsByDappUniversity\ethers_examples\node_modules\@ethersproject\contracts\lib\index.js:48:23) at Object.next (C:\MyCodeProject\learn\etherjs\tut_ethersJsByDappUniversity\ethers_examples\node_modules\@ethersproject\contracts\lib\index.js:29:53) at fulfilled (C:\MyCodeProject\learn\etherjs\tut_ethersJsByDappUniversity\ethers_examples\node_modules\@ethersproject\contracts\lib\index.js:20:58) at processTicksAndRejections (node:internal/process/task_queues:96:5) { reason: null, code: 'CALL_EXCEPTION', method: 'token0()', errorArgs: null, errorName: null, errorSignature: null, address: '0x4D7C363DED4B3b4e1F954494d2Bc3955e49699cC', args: [], transaction: { data: '0x0dfe1681', to: '0x4D7C363DED4B3b4e1F954494d2Bc3955e49699cC' } } It's pointing to the LP pool address 0x4D7C363DED4B3b4e1F954494d2Bc3955e49699cC returning null. This is confirmed to have no match of smart contract on the Goerli explorer. I try to look up the UNI/WETH pool address here, without any luck since they only seem to show the networks that are available and Goerli is not there. I have also tried doing a UNI/WETH swap manually on Uniswap, and explore the transaction details, but I didn't see anything related to the LP pool contract. I have reviewed a similar question, but the answer didn't help. How do I find the specific UNI/WETH pool contract address on Goerli network?To find the specific UNI/WETH pool contract address on the Goerli testnet, you can follow these steps:
Go to the Uniswap app on the Goerli testnet at https://app.uniswap.org/#/swap?inputCurrency=ETH&outputCurrency=0x1f9840a85d5af5bf1d1762f925bdaddc4201f984&use=V3.
Click on the "Pool" button on the top left corner of the screen.
Click on the "Copy Address" button to copy the pool contract address to your clipboard.
Alternatively, you can use Etherscan to search for the UNI/WETH pool contract on the Goerli testnet. Here's how:
Go to Etherscan at https://goerli.etherscan.io/.
In the search bar, enter the address of the UNI token contract on the Goerli testnet: 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984.
On the UNI token contract page, click on the "View on Uniswap" button.
On the Uniswap app page, click on the "Pool" button.
On the Pool page, you should see the UNI/WETH pool contract address in the URL of the page. It should look something like this: https://app.uniswap.org/#/pool/0x1234567890abcdef1234567890abcdef12345678.
Note that the pool contract address may change over time, so you should double-check that the address you have is still valid before using it in your code.
Comments
Post a Comment