Swap 100 USDC for WETH on Ethereum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const client: IWeb3 = TWeb3.Create( | |
web3.Ethereum, | |
web3.eth.infura.endpoint(web3.Ethereum, INFURA_PROJECT_ID) | |
); | |
web3.eth.balancer.v2.swap( | |
client, | |
owner, | |
TSwapKind.GivenIn, | |
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC | |
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH | |
web3.utils.scale(100, 6), // 100 USDC | |
0, // limit | |
web3.Infinite, // deadline | |
procedure(rcpt: ITxReceipt; err: IError) | |
begin | |
if Assigned(err) then | |
// handle error gracefully | |
else | |
// your transaction got mined | |
end); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment