From 8580c5e427aa044b3eb485a015969a38b5297107 Mon Sep 17 00:00:00 2001 From: poma Date: Thu, 11 Feb 2021 10:29:50 +0300 Subject: [PATCH] deploy script --- contracts/Mocks/IDeployer.sol | 6 ++++++ deploy.js | 25 +++++++++++++++++++++++++ migrations/4_deploy_eth_tornado.js | 2 +- migrations/5_deploy_erc20_tornado.js | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 contracts/Mocks/IDeployer.sol create mode 100644 deploy.js diff --git a/contracts/Mocks/IDeployer.sol b/contracts/Mocks/IDeployer.sol new file mode 100644 index 0000000..63e119d --- /dev/null +++ b/contracts/Mocks/IDeployer.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.6.0; + +interface IDeployer { + function deploy(bytes memory _initCode, bytes32 _salt) external returns (address payable createdContract); +} diff --git a/deploy.js b/deploy.js new file mode 100644 index 0000000..1f01484 --- /dev/null +++ b/deploy.js @@ -0,0 +1,25 @@ +const eth = true +const poolSize = '1000000000000000000' +const hasherAddress = '0x83584f83f26aF4eDDA9CBe8C730bc87C364b28fe' +const verifierAddress = '0xce172ce1F20EC0B3728c9965470eaf994A03557A' +const deployerAddress = '0xCEe71753C9820f063b38FDbE4cFDAf1d3D928A80' +const deploySalt = '0x0000000000000000000000000000000000000000000000000000000047941987' +const rpcUrl = 'https://mainnet.infura.io' + +const Web3 = require('web3') +const web3 = new Web3(rpcUrl) + +const contractData = require('./build/contracts/' + (eth ? 'ETHTornado.json' : 'ERC20Tornado.json')) +const contract = new web3.eth.Contract(contractData.abi) +const bytes = contract + .deploy({ + data: contractData.bytecode, + arguments: [verifierAddress, hasherAddress, poolSize, 20], + }) + .encodeABI() + +console.log('Deploy bytecode', bytes) + +const deployer = new web3.eth.Contract(require('./build/contracts/IDeployer.json').abi, deployerAddress) +const receipt = deployer.methods.deploy(bytes, deploySalt) +receipt.then(console.log).catch(console.log) diff --git a/migrations/4_deploy_eth_tornado.js b/migrations/4_deploy_eth_tornado.js index cf00328..371c7d8 100644 --- a/migrations/4_deploy_eth_tornado.js +++ b/migrations/4_deploy_eth_tornado.js @@ -4,7 +4,7 @@ const ETHTornado = artifacts.require('ETHTornado') const Verifier = artifacts.require('Verifier') const Hasher = artifacts.require('Hasher') -module.exports = function (deployer, network, accounts) { +module.exports = function (deployer) { return deployer.then(async () => { const { MERKLE_TREE_HEIGHT, ETH_AMOUNT } = process.env const verifier = await Verifier.deployed() diff --git a/migrations/5_deploy_erc20_tornado.js b/migrations/5_deploy_erc20_tornado.js index cee9b84..697e4a4 100644 --- a/migrations/5_deploy_erc20_tornado.js +++ b/migrations/5_deploy_erc20_tornado.js @@ -5,7 +5,7 @@ const Verifier = artifacts.require('Verifier') const Hasher = artifacts.require('Hasher') const ERC20Mock = artifacts.require('ERC20Mock') -module.exports = function (deployer, network, accounts) { +module.exports = function (deployer) { return deployer.then(async () => { const { MERKLE_TREE_HEIGHT, ERC20_TOKEN, TOKEN_AMOUNT } = process.env const verifier = await Verifier.deployed()