tornado-nova/scripts/deployTornado.js

87 lines
2.7 KiB
JavaScript
Raw Permalink Normal View History

2021-06-06 19:31:32 +02:00
const { ethers } = require('hardhat')
2021-10-06 17:09:37 +02:00
const { utils } = ethers
2022-02-08 17:54:32 +01:00
// const prompt = require('prompt-sync')()
2021-06-06 19:31:32 +02:00
2021-09-08 17:57:24 +02:00
const MERKLE_TREE_HEIGHT = 23
const { MINIMUM_WITHDRAWAL_AMOUNT, MAXIMUM_DEPOSIT_AMOUNT } = process.env
2021-06-06 19:31:32 +02:00
async function main() {
2021-10-04 13:18:55 +02:00
require('./compileHasher')
2022-02-08 17:54:32 +01:00
const govAddress = '0xBAE5aBfa98466Dbe68836763B087f2d189f4D28f'
2021-09-30 20:32:49 +02:00
const omniBridge = '0x59447362798334d3485c64D1e4870Fde2DDC0d75'
const amb = '0x162e898bd0aacb578c8d5f8d6ca588c13d2a383f'
2021-09-30 20:32:49 +02:00
const token = '0xCa8d20f3e0144a72C6B5d576e9Bd3Fd8557E2B04' // WBNB
2022-02-08 17:54:32 +01:00
const l1Unwrapper = '0x8845F740F8B01bC7D9A4C82a6fD4A60320c07AF1' // WBNB -> BNB
2021-10-04 13:18:55 +02:00
const l1ChainId = 56
2022-02-08 17:54:32 +01:00
const multisig = '0xE3611102E23a43136a13993E3a00BAD67da19119'
2021-09-08 17:57:24 +02:00
const Verifier2 = await ethers.getContractFactory('Verifier2')
const verifier2 = await Verifier2.deploy()
await verifier2.deployed()
console.log(`verifier2: ${verifier2.address}`)
const Verifier16 = await ethers.getContractFactory('Verifier16')
const verifier16 = await Verifier16.deploy()
await verifier16.deployed()
console.log(`verifier16: ${verifier16.address}`)
2021-06-06 19:31:32 +02:00
2021-09-30 20:32:49 +02:00
const Hasher = await await ethers.getContractFactory('Hasher')
const hasher = await Hasher.deploy()
2021-10-04 13:18:55 +02:00
await hasher.deployed()
2021-10-04 13:51:33 +02:00
console.log(`hasher: ${hasher.address}`)
2021-06-06 19:31:32 +02:00
const Pool = await ethers.getContractFactory('TornadoPool')
2021-10-06 19:14:28 +02:00
console.log(
`constructor args:\n${JSON.stringify([
verifier2.address,
verifier16.address,
MERKLE_TREE_HEIGHT,
hasher.address,
token,
omniBridge,
l1Unwrapper,
govAddress,
2021-10-12 17:50:25 +02:00
l1ChainId,
2022-02-08 17:54:32 +01:00
multisig,
2021-10-06 19:14:28 +02:00
]).slice(1, -1)}\n`,
2021-09-30 20:32:49 +02:00
)
2022-02-08 17:54:32 +01:00
//const tornadoImpl = prompt('Deploy tornado pool implementation and provide address here:\n')
const tornadoImpl = await Pool.deploy(
verifier2.address,
verifier16.address,
MERKLE_TREE_HEIGHT,
hasher.address,
token,
omniBridge,
l1Unwrapper,
govAddress,
l1ChainId,
multisig,
)
await tornadoImpl.deployed()
console.log(`TornadoPool implementation address: ${tornadoImpl.address}`)
2021-09-08 17:57:24 +02:00
const CrossChainUpgradeableProxy = await ethers.getContractFactory('CrossChainUpgradeableProxy')
2022-02-08 17:54:32 +01:00
const proxy = await CrossChainUpgradeableProxy.deploy(tornadoImpl.address, govAddress, [], amb, l1ChainId)
2021-09-08 17:57:24 +02:00
await proxy.deployed()
console.log(`proxy address: ${proxy.address}`)
const tornadoPool = await Pool.attach(proxy.address)
2021-10-06 17:09:37 +02:00
await tornadoPool.initialize(
utils.parseEther(MINIMUM_WITHDRAWAL_AMOUNT),
utils.parseEther(MAXIMUM_DEPOSIT_AMOUNT),
)
console.log(
`Proxy initialized with MINIMUM_WITHDRAWAL_AMOUNT=${MINIMUM_WITHDRAWAL_AMOUNT} ETH and MAXIMUM_DEPOSIT_AMOUNT=${MAXIMUM_DEPOSIT_AMOUNT} ETH`,
)
2021-06-06 19:31:32 +02:00
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})