tornado-core/migrations/5_deploy_erc20_tornado.js

30 lines
1006 B
JavaScript
Raw Normal View History

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