Timeline for How to swap ETH to WBTC in Solidity
Current License: CC BY-SA 4.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 5 at 10:16 | comment | added | user9541033 |
ok @Mehran Ra I understand but I think I used the correct address of Uniswap Router V3 when deploying. On the other hand, when I thought about it I replaced the uniswapRouter.WETH9() code with address public constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 because there didn't seem to be a uniswapRouter.WETH9() method. Perhaps this is the error. PS: I've edited the current post with my current tested code
|
|
Jan 2 at 18:45 | comment | added | Mehran Ra | Because you need to communicate with UniSwap, you should test on the network that UniSwap supports and give the address of that network to its interface. | |
Jan 1 at 19:34 | comment | added | user9541033 | Thank you for your reply. In fact, I want my contract to retrieve the msg.value and automatically swap it into WBTCs. These WBTCs will remain in the contract afterwards. I tested your code on Remix VM Mainnet fork and I get this error (1 ETH as msg.value): "revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information." Do you have any idea how to proceed? Thanks in advance | |
Dec 28, 2023 at 16:01 | history | answered | Mehran Ra | CC BY-SA 4.0 |