5_deploy_erc20_mixer.js 1008 B

12345678910111213141516171819202122232425262728293031
  1. /* global artifacts */
  2. require('dotenv').config({ path: '../.env' })
  3. const ERC20Tornado = artifacts.require('ERC20Tornado')
  4. const Verifier = artifacts.require('Verifier')
  5. const hasherContract = artifacts.require('Hasher')
  6. const ERC20Mock = artifacts.require('ERC20Mock')
  7. module.exports = function(deployer, network, accounts) {
  8. return deployer.then(async () => {
  9. const { MERKLE_TREE_HEIGHT, ERC20_TOKEN, TOKEN_AMOUNT } = process.env
  10. const verifier = await Verifier.deployed()
  11. const hasherInstance = await hasherContract.deployed()
  12. await ERC20Tornado.link(hasherContract, hasherInstance.address)
  13. let token = ERC20_TOKEN
  14. if(token === '') {
  15. const tokenInstance = await deployer.deploy(ERC20Mock)
  16. token = tokenInstance.address
  17. }
  18. const tornado = await deployer.deploy(
  19. ERC20Tornado,
  20. verifier.address,
  21. TOKEN_AMOUNT,
  22. MERKLE_TREE_HEIGHT,
  23. accounts[0],
  24. token,
  25. )
  26. console.log('ERC20Tornado\'s address ', tornado.address)
  27. })
  28. }