Skip to content

Instantly share code, notes, and snippets.

Last active Oct 28, 2020
What would you like to do?
encode Rinkeby DAI transfer function
// DAI smart contract's address in Rinkeby network, chainId = 4
const daiExchangeAddress = "0x5592ec0cfb4dbc12d3ab100b257153436a1f0fea";
const daiExchangeAbi = require("./erc20abi.json");
const web3 = new Web3(
new Web3.providers.HttpProvider("<endpoint>")
const daiExchangeContract = new web3.eth.Contract(JSON.parse(JSON.stringify(daiExchangeAbi)), daiExchangeAddress);
const DAI = web3.utils.toHex(100000000000000000); // 0.1 DAI
const exchangeEncodeABI = daiExchangeContract.methods.transfer(receiverAddress, DAI).encodeABI();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment