6_deploy_erc20_mixer.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. /* global artifacts */
  2. require('dotenv').config({ path: '../.env' })
  3. const ERC20Mixer = artifacts.require('ERC20Mixer')
  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, EMPTY_ELEMENT, ERC20_TOKEN, TOKEN_AMOUNT } = process.env
  10. const verifier = await Verifier.deployed()
  11. const hasherInstance = await hasherContract.deployed()
  12. await ERC20Mixer.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 mixer = await deployer.deploy(
  19. ERC20Mixer,
  20. verifier.address,
  21. TOKEN_AMOUNT,
  22. MERKLE_TREE_HEIGHT,
  23. EMPTY_ELEMENT,
  24. accounts[0],
  25. token,
  26. )
  27. console.log('ERC20Mixer\'s address ', mixer.address)
  28. })
  29. }