Published On Jan 3, 2023
Get my free EthersJS cheatsheet to master Web3!
👉 https://blockman-codes.ck.page/91b29a...
------------------------------------------
Courses:
👉 Build a Uniswap V3 interface that can do swaps: https://bit.ly/3JkXYqL
------------------------------------------
How can you pass ETH (instead of WETH) as the input to a swap when interacting with Uniswap V3 with code?
The Uniswap app allows specifying ETH as the input token, but programmatically interacting with the Swap Router does not.
Let's learn how to do this.
This can reduce the number of transactions and save you gas and fees.
--------------------------------------
Imports
const { abi: V3SwapRouterABI } = require('@uniswap/v3-periphery/artifacts/contracts/SwapRouter.sol/SwapRouter.json')
const ROUTER_ADDRESS = '0xE592427A0AEce92De3Edee1F18E0157C05861564'
const WETH_ADDRESS = '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6'
const UNI_ADDRESS = '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984'