tornado-core/migrations/5_deploy_erc20_mixer.js

32 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-08-20 22:39:21 +02:00
/* global artifacts */
require('dotenv').config({ path: '../.env' })
const ERC20Mixer = artifacts.require('ERC20Mixer')
const Verifier = artifacts.require('Verifier')
2019-10-04 18:17:28 +02:00
const hasherContract = artifacts.require('Hasher')
2019-08-20 22:39:21 +02:00
const ERC20Mock = artifacts.require('ERC20Mock')
module.exports = function(deployer, network, accounts) {
return deployer.then(async () => {
2019-08-27 22:42:24 +02:00
const { MERKLE_TREE_HEIGHT, ETH_AMOUNT, EMPTY_ELEMENT, ERC20_TOKEN, TOKEN_AMOUNT } = process.env
2019-08-20 22:39:21 +02:00
const verifier = await Verifier.deployed()
const hasherInstance = await hasherContract.deployed()
await ERC20Mixer.link(hasherContract, hasherInstance.address)
2019-08-20 22:39:21 +02:00
let token = ERC20_TOKEN
2019-08-30 12:06:17 +02:00
if(token === '') {
2019-08-20 22:39:21 +02:00
const tokenInstance = await deployer.deploy(ERC20Mock)
token = tokenInstance.address
}
const mixer = await deployer.deploy(
ERC20Mixer,
verifier.address,
MERKLE_TREE_HEIGHT,
EMPTY_ELEMENT,
accounts[0],
2019-08-27 22:42:24 +02:00
token,
TOKEN_AMOUNT
2019-08-20 22:39:21 +02:00
)
console.log('ERC20Mixer\'s address ', mixer.address)
})
}