Skip to content

Instantly share code, notes, and snippets.

@ajb413
Created February 11, 2020 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajb413/95c58027642e170a0d82f797ca1b56b9 to your computer and use it in GitHub Desktop.
Save ajb413/95c58027642e170a0d82f797ca1b56b9 to your computer and use it in GitHub Desktop.
Snippet for supplying DAI to Compound
// Mint some cDAI by sending DAI to the Compound Protocol
console.log('MyContract is now minting cDAI...');
let supplyResult = await myContract.methods.supplyErc20ToCompound(
daiMainNetAddress,
compoundCDaiContractAddress,
web3.utils.toHex(10e18) // 10 DAI to supply
).send({
from: myWalletAddress,
gasLimit: web3.utils.toHex(5000000), // posted at compound.finance/developers#gas-costs
gasPrice: web3.utils.toHex(20000000000), // use ethgasstation.info (mainnet only)
});
// console.log('Supplied DAI to Compound via MyContract', JSON.stringify(supplyResult));
console.log('Supplied DAI to Compound via MyContract');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment