|
| 1 | +require('dotenv').config() |
| 2 | +const config = require('../config/config.json') |
| 3 | +const hre = require('hardhat') |
| 4 | + |
| 5 | +// Use your own deployed child tunnel addresses here instead! |
| 6 | +const fxERC20ChildTunnel = '0x918cc10cf2393bb9803f9d9D3219539a1e736dd9' |
| 7 | +const fxERC721ChildTunnel = '0xdC335C19868d49aCa554AA64d5ae8524A093De5b' |
| 8 | +const fxERC1155ChildTunnel = '0x46d40260e48A6164bbF24206D3AB9426a41D8664' |
| 9 | + |
| 10 | +async function main () { |
| 11 | + let fxRoot, checkpointManager, fxERC20, fxERC721, fxERC1155 |
| 12 | + |
| 13 | + const network = await hre.ethers.provider.getNetwork() |
| 14 | + |
| 15 | + if (network.chainId === 1) { // Ethereum Mainnet |
| 16 | + fxRoot = config.mainnet.fxRoot.address |
| 17 | + checkpointManager = config.mainnet.checkpointManager.address |
| 18 | + fxERC20 = config.mainnet.fxERC20.address |
| 19 | + fxERC721 = config.mainnet.fxERC721.address |
| 20 | + fxERC1155 = config.mainnet.fxERC1155.address |
| 21 | + } else if (network.chainId === 5) { // Goerli Testnet |
| 22 | + fxRoot = config.testnet.fxRoot.address |
| 23 | + checkpointManager = config.testnet.checkpointManager.address |
| 24 | + fxERC20 = config.testnet.fxERC20.address |
| 25 | + fxERC721 = config.testnet.fxERC721.address |
| 26 | + fxERC1155 = config.testnet.fxERC1155.address |
| 27 | + } else { |
| 28 | + fxRoot = process.env.FX_ROOT |
| 29 | + checkpointManager = process.env.CHECKPOINT_MANAGER |
| 30 | + fxERC20 = process.env.FX_ERC20 |
| 31 | + fxERC721 = process.env.FX_ERC721 |
| 32 | + fxERC1155 = process.env.FX_ERC1155 |
| 33 | + } |
| 34 | + |
| 35 | + // You will want to use your own tunnel addresses here instead! |
| 36 | + const ERC20 = await hre.ethers.getContractFactory('FxERC20RootTunnel') |
| 37 | + const erc20 = await ERC20.deploy(checkpointManager, fxRoot, fxERC20) |
| 38 | + console.log(erc20.deployTransaction) |
| 39 | + await erc20.deployTransaction.wait() |
| 40 | + console.log('ERC20RootTunnel deployed to:', erc20.address) |
| 41 | + |
| 42 | + const setERC20Child = await erc20.setFxChildTunnel(fxERC20ChildTunnel) |
| 43 | + console.log(setERC20Child) |
| 44 | + await setERC20Child.wait() |
| 45 | + console.log('ERC20ChildTunnel set') |
| 46 | + |
| 47 | + const ERC721 = await hre.ethers.getContractFactory('FxERC721RootTunnel') |
| 48 | + const erc721 = await ERC721.deploy(checkpointManager, fxRoot, fxERC721) |
| 49 | + console.log(erc721.deployTransaction) |
| 50 | + await erc721.deployTransaction.wait() |
| 51 | + console.log('ERC721RootTunnel deployed to:', erc721.address) |
| 52 | + |
| 53 | + const setERC721Child = await erc721.setFxChildTunnel(fxERC721ChildTunnel) |
| 54 | + console.log(setERC721Child) |
| 55 | + await setERC721Child.wait() |
| 56 | + console.log('ERC721ChildTunnel set') |
| 57 | + |
| 58 | + const ERC1155 = await hre.ethers.getContractFactory('FxERC1155RootTunnel') |
| 59 | + const erc1155 = await ERC1155.deploy(checkpointManager, fxRoot, fxERC1155) |
| 60 | + console.log(erc1155.deployTransaction) |
| 61 | + await erc1155.deployTransaction.wait() |
| 62 | + console.log('ERC1155RootTunnel deployed to:', erc1155.address) |
| 63 | + |
| 64 | + const setERC1155Child = await erc1155.setFxChildTunnel(fxERC1155ChildTunnel) |
| 65 | + console.log(setERC1155Child) |
| 66 | + await setERC1155Child.wait() |
| 67 | + console.log('ERC1155ChildTunnel set') |
| 68 | +} |
| 69 | + |
| 70 | +main() |
| 71 | + .then(() => process.exit(0)) |
| 72 | + .catch((error) => { |
| 73 | + console.error(error) |
| 74 | + process.exit(1) |
| 75 | + }) |
0 commit comments