Skip to content

Commit 4b07231

Browse files
authored
Merge pull request #18 from QEDK/scripts
Add deployment scripts
2 parents d8f2fa9 + 2c3b27f commit 4b07231

File tree

7 files changed

+7777
-7407
lines changed

7 files changed

+7777
-7407
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ npm-debug.log*
55
yarn-debug.log*
66
yarn-error.log*
77
lerna-debug.log*
8+
.DS_Store
89

910
# Diagnostic reports (https://nodejs.org/api/report.html)
1011
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@@ -108,4 +109,4 @@ node_modules
108109
#Hardhat files
109110
cache
110111
artifacts
111-
scripts
112+
internal

config/config.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"mainnet":{
3+
"fxRoot":{
4+
"address":"0xfe5e5D361b2ad62c541bAb87C45a0B9B018389a2"
5+
},
6+
"fxChild":{
7+
"address":"0x8397259c983751DAf40400790063935a11afa28a"
8+
},
9+
"checkpointManager":{
10+
"address":"0x86E4Dc95c7FBdBf52e33D563BbDB00823894C287"
11+
},
12+
"fxERC20":{
13+
"address":"0xAd87e3b217c66B0D45dEaFBC540330d300811b94"
14+
},
15+
"fxERC721":{
16+
"address":"0x467c9BA5DAB81C8975F7d8237ECe61918AA6e8fF"
17+
},
18+
"fxERC1155":{
19+
"address":"0x4443c9877aB1767e1080fa70Ac038758e526c609"
20+
}
21+
},
22+
"testnet":{
23+
"fxRoot":{
24+
"address":"0x3d1d3E34f7fB6D26245E6640E1c50710eFFf15bA"
25+
},
26+
"fxChild":{
27+
"address":"0xCf73231F28B7331BBe3124B907840A94851f9f11"
28+
},
29+
"checkpointManager":{
30+
"address":"0x2890bA17EfE978480615e330ecB65333b880928e"
31+
},
32+
"fxERC20":{
33+
"address":"0xDDE69724AeFBdb084413719fE745aB66e3b055C7"
34+
},
35+
"fxERC721":{
36+
"address":"0xf2720927E048726267C0221ffA41A88528048726"
37+
},
38+
"fxERC1155":{
39+
"address":"0x80be8Cf927047A40d3f5791BF7436D8c95b3Ae5C"
40+
}
41+
}
42+
}

hardhat.config.js

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,48 @@
1-
require("@nomiclabs/hardhat-waffle");
2-
require("dotenv").config();
3-
4-
// This is a sample Hardhat task. To learn how to create your own go to
5-
// https://hardhat.org/guides/create-task.html
6-
task("accounts", "Prints the list of accounts", async () => {
7-
const accounts = await ethers.getSigners();
8-
9-
for (const account of accounts) {
10-
console.log(account.address);
11-
}
12-
});
13-
1+
require('dotenv').config()
2+
require('@nomiclabs/hardhat-waffle')
3+
require('@nomiclabs/hardhat-etherscan')
144
// You need to export an object to set up your config
155
// Go to https://hardhat.org/config/ to learn more
166

177
/**
188
* @type import('hardhat/config').HardhatUserConfig
199
*/
2010

11+
let accounts = []
12+
13+
if (process.env.PRIVATE_KEY) {
14+
accounts = [`0x${process.env.PRIVATE_KEY}`, ...accounts]
15+
}
16+
2117
module.exports = {
2218
solidity: {
23-
compilers: [
24-
{
25-
version: "0.8.0"
19+
version: '0.8.0',
20+
settings: {
21+
optimizer: {
22+
enabled: true,
23+
runs: 9999
2624
}
27-
]
28-
}
29-
};
30-
31-
const PRIVATE_KEY=process.env.PRIVATE_KEY;
32-
const RPC_APIKEY=process.env.RPC_APIKEY;
33-
34-
if(PRIVATE_KEY !== undefined && RPC_APIKEY !== undefined) {
35-
module.exports.networks = {
25+
}
26+
},
27+
networks: {
28+
mainnet: {
29+
url: process.env.MAINNET_RPC || 'https://main-light.eth.linkpool.io',
30+
accounts
31+
},
3632
goerli: {
37-
url: `https://rpc.slock.it/goerli`,
38-
accounts: [`0x${PRIVATE_KEY}`]
33+
url: process.env.GOERLI_RPC || 'https://goerli-light.eth.linkpool.io',
34+
accounts
35+
},
36+
polygon: {
37+
url: process.env.POLYGON_RPC || 'https://polygon-rpc.com',
38+
accounts
3939
},
4040
mumbai: {
41-
url: `https://rpc-mumbai.maticvigil.com/v1/${RPC_APIKEY}`,
42-
accounts: [`0x${PRIVATE_KEY}`]
41+
url: process.env.MUMBAI_RPC || 'https://rpc-mumbai.maticvigil.com',
42+
accounts
4343
}
44-
};
44+
},
45+
etherscan: {
46+
apiKey: process.env.ETHERSCAN_API_KEY
47+
}
4548
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"homepage": "https://github.com/jdkanani/fx-portal#readme",
2323
"devDependencies": {
2424
"@nomiclabs/hardhat-ethers": "^2.0.1",
25+
"@nomiclabs/hardhat-etherscan": "^2.1.6",
2526
"@nomiclabs/hardhat-waffle": "^2.0.1",
2627
"chai": "^4.2.0",
2728
"dotenv": "^8.2.0",

scripts/deploychild.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
require('dotenv').config()
2+
const config = require('../config/config.json')
3+
const hre = require('hardhat')
4+
5+
async function main () {
6+
let fxChild
7+
8+
const network = await hre.ethers.provider.getNetwork()
9+
10+
if (network.chainId === 137) { // Polygon Mainnet
11+
fxChild = config.mainnet.fxChild.address
12+
} else if (network.chainId === 80001) { // Mumbai Testnet
13+
fxChild = config.testnet.fxChild.address
14+
} else {
15+
fxChild = process.env.FX_CHILD
16+
}
17+
18+
const ERC20Token = await hre.ethers.getContractFactory('FxERC20')
19+
const erc20Token = await ERC20Token.deploy()
20+
console.log(erc20Token.deployTransaction)
21+
await erc20Token.deployTransaction.wait()
22+
console.log('FxERC20 deployed to:', erc20Token.address)
23+
24+
const ERC20 = await hre.ethers.getContractFactory('FxERC20ChildTunnel')
25+
const erc20 = await ERC20.deploy(fxChild, erc20Token.address)
26+
await erc20.deployTransaction.wait()
27+
console.log('ERC20ChildTunnel deployed to:', erc20.address)
28+
29+
const ERC721Token = await hre.ethers.getContractFactory('FxERC721')
30+
const erc721Token = await ERC721Token.deploy()
31+
console.log(erc721Token.deployTransaction)
32+
await erc721Token.deployTransaction.wait()
33+
console.log('FxERC721 deployed to:', erc721Token.address)
34+
35+
const ERC721 = await hre.ethers.getContractFactory('FxERC721ChildTunnel')
36+
const erc721 = await ERC721.deploy(fxChild, erc721Token.address)
37+
console.log(erc721.deployTransaction)
38+
await erc721.deployTransaction.wait()
39+
console.log('ERC721ChildTunnel deployed to:', erc721.address)
40+
41+
const ERC1155Token = await hre.ethers.getContractFactory('FxERC1155')
42+
const erc1155Token = await ERC1155Token.deploy()
43+
console.log(erc1155Token.deployTransaction)
44+
await erc1155Token.deployTransaction.wait()
45+
console.log('FxERC1155 deployed to:', erc1155Token.address)
46+
47+
const ERC1155 = await hre.ethers.getContractFactory('FxERC1155ChildTunnel')
48+
const erc1155 = await ERC1155.deploy(fxChild, erc1155Token.address)
49+
console.log(erc1155.deployTransaction)
50+
await erc1155.deployTransaction.wait()
51+
console.log('ERC1155ChildTunnel deployed to:', erc1155.address)
52+
}
53+
54+
main()
55+
.then(() => process.exit(0))
56+
.catch((error) => {
57+
console.error(error)
58+
process.exit(1)
59+
})

scripts/deployroot.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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

Comments
 (0)