Created
February 11, 2020 21:18
-
-
Save ajb413/acac37c3a06c66c1ca4e2bc2ac61db0e to your computer and use it in GitHub Desktop.
Minting test DAI snippet
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
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