tornado-nova/migrations/2_deploy_pool.js

20 lines
776 B
JavaScript
Raw Normal View History

2020-04-09 11:04:06 +02:00
/* global artifacts */
const Verifier = artifacts.require('Verifier')
const TornadoPool = artifacts.require('TornadoPool')
2020-04-09 20:38:10 +02:00
const MERKLE_TREE_HEIGHT = 5
const MerkleTree = require('../lib/merkleTree')
const { bigInt } = require('snarkjs')
const toHex = (number, length = 32) => '0x' + (number instanceof Buffer ? number.toString('hex') : bigInt(number).toString(16)).padStart(length * 2, '0')
2020-04-09 11:04:06 +02:00
module.exports = function(deployer, network, accounts) {
return deployer.then(async () => {
2020-04-09 20:38:10 +02:00
const tree = new MerkleTree(MERKLE_TREE_HEIGHT)
const root = await tree.root()
2020-04-09 11:04:06 +02:00
const verifier = await Verifier.deployed()
2020-04-09 20:38:10 +02:00
const tornado = await deployer.deploy(TornadoPool, verifier.address, toHex(root))
2020-04-09 11:04:06 +02:00
console.log('TornadoPool\'s address ', tornado.address)
})
}