Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
Last active October 28, 2020 05:49
Show Gist options
  • Save yuyasugano/2fee774a92826aab674ef7d206d5c929 to your computer and use it in GitHub Desktop.
Save yuyasugano/2fee774a92826aab674ef7d206d5c929 to your computer and use it in GitHub Desktop.
encode Rinkeby DAI transfer function
// DAI smart contract's address in Rinkeby network, chainId = 4
// https://rinkeby.etherscan.io/token/0x5592ec0cfb4dbc12d3ab100b257153436a1f0fea
const daiExchangeAddress = "0x5592ec0cfb4dbc12d3ab100b257153436a1f0fea";
const daiExchangeAbi = require("./erc20abi.json");
const web3 = new Web3(
new Web3.providers.HttpProvider("https://rinkeby.infura.io/v3/<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