Skip to content

Instantly share code, notes, and snippets.

@ajb413
Created February 11, 2020 21:18
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/acac37c3a06c66c1ca4e2bc2ac61db0e to your computer and use it in GitHub Desktop.
Save ajb413/acac37c3a06c66c1ca4e2bc2ac61db0e to your computer and use it in GitHub Desktop.
Minting test DAI snippet
let daiContract;
let accounts;
web3.eth.getAccounts().then((ganacheAccounts) => {
accounts = ganacheAccounts;
daiContract = new web3.eth.Contract(daiAbi, daiMainNetAddress);
// 500 DAI
const numbDaiToMint = web3.utils.toWei('500', 'ether');
return daiContract.methods.mint(accounts[0], numbDaiToMint)
.send({
from: daiMcdJoin,
gasPrice: web3.utils.toHex(0)
});
}).then((result) => {
console.log('DAI mint success');
return daiContract.methods.balanceOf(accounts[0]).call();
}).then((balanceOf) => {
const dai = web3.utils.fromWei(balanceOf, 'ether');
console.log('DAI amount in first Ganache account wallet:', dai);
}).catch((err) => {
console.error(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment