9) Bridge Deployment
Deploy the bridge after you have reconfigured your instance.

Create additional accounts for deployment

1) Generate private keys for the following using MetaMask or MyEtherWallet. Save as json keystore file + password. Note the json location, wallet address, and password for each account.
  • DEPLOYMENT_ACCOUNT
  • FOREIGN_ADMIN_BRIDGE
  • FOREIGN_ADMIN_VALIDATOR
  • FOREIGN_OWNER
  • HOME_ADMIN_BRIDGE
  • HOME_ADMIN_VALIDATOR
  • HOME_OWNER
  • VALIDATOR
This data can not be recovered through an account after creation, so be sure to store accurately and safely.
You will need tokens for deployment on the Foreign side of the bridge. This means the DEPLOYMENT_ACCOUNT and VALIDATOR accounts will require tokens. The DEPLOYMENT_ACCOUNT will deploy bridge contracts and initialize the bridge, and VALIDATOR accounts use tokens to pay for txs on the foreign side.
2) Add the following addresses to the Certifier contract using the MyCrypto method described previously.
a) Use the Master of Ceremony address to call the certify method in the Certifier Contract. You will certify the following addresses, completing a separate transaction for each:
  • VALIDATOR
  • DEPLOYMENT_ACCOUNT
  • HOME_OWNER

Configure and Deploy Bridge Contracts

1) Clone the Repo

1
git clone -b develop https://github.com/poanetwork/tokenbridge-contracts.git
2
cd tokenbridge-contracts
Copied!
If preferred, use Docker to get the latest image. docker pull poanetwork/tokenbridge-contracts:latest

2) Copy the following example to create the deploy/.env file.

The example below uses the DAI Stablecoin for the ERC20_Token_Address. Y Mainnet | Kovan You can select your own token if desired.
If using Docker, create a standalone file and name it erc-to-native.config
Replace all variables templated with tags (<>) with actual values. Learn more about variables here
1
BRIDGE_MODE=ERC_TO_NATIVE
2
DEPLOYMENT_ACCOUNT_PRIVATE_KEY=<DEPLOYMENT_ACCOUNT_PRIVATE_KEY>
3
DEPLOYMENT_GAS_LIMIT_EXTRA=0.2
4
HOME_DEPLOYMENT_GAS_PRICE=0
5
FOREIGN_DEPLOYMENT_GAS_PRICE=10000000000
6
GET_RECEIPT_INTERVAL_IN_MILLISECONDS=3000
7
#long name
8
BRIDGEABLE_TOKEN_NAME=TEST
9
#short name
10
BRIDGEABLE_TOKEN_SYMBOL=Test
11
BRIDGEABLE_TOKEN_DECIMALS=18
12
13
HOME_RPC_URL=https://<url.to.homenet>
14
HOME_BRIDGE_OWNER=<HOME_OWNER>
15
HOME_VALIDATORS_OWNER=<HOME_ADMIN_VALIDATOR>
16
HOME_UPGRADEABLE_ADMIN=<HOME_ADMIN_BRIDGE>
17
18
HOME_DAILY_LIMIT=30000000000000000000000000
19
HOME_MAX_AMOUNT_PER_TX=1500000000000000000000000
20
HOME_MIN_AMOUNT_PER_TX=500000000000000000
21
HOME_REQUIRED_BLOCK_CONFIRMATIONS=1
22
HOME_GAS_PRICE=0
23
24
#Added in a later step
25
#BLOCK_REWARD_ADDRESS=<0x_BLOCK_REWARD_HOME>
26
27
FOREIGN_RPC_URL=https://<url.to.foreignnet>
28
FOREIGN_BRIDGE_OWNER=<FOREIGN_OWNER>
29
FOREIGN_VALIDATORS_OWNER=<FOREIGN_ADMIN_VALIDATOR>
30
FOREIGN_UPGRADEABLE_ADMIN=<FOREIGN_ADMIN_BRIDGE>
31
FOREIGN_DAILY_LIMIT=15000000000000000000000000
32
FOREIGN_MAX_AMOUNT_PER_TX=750000000000000000000000
33
FOREIGN_MIN_AMOUNT_PER_TX=500000000000000000
34
FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS=8
35
FOREIGN_GAS_PRICE=18000000000
36
37
#for bridge erc_to_erc and erc_to_native mode
38
#mainnet
39
ERC20_TOKEN_ADDRESS=0x6b175474e89094c44da98b954eedeac495271d0f
40
#kovan
41
#ERC20_TOKEN_ADDRESS=0xc4375b7de8af5a38a93548eb8453a498222c4ff2
42
#validators
43
REQUIRED_NUMBER_OF_VALIDATORS=1
44
#If several validators are used, list them separated by space without quotes
45
#E.g. VALIDATORS=0x 0x 0x
46
VALIDATORS=<address of validator>
47
48
HOME_REWARDABLE=false
49
FOREIGN_REWARDABLE=false
50
DEPLOY_REWARDABLE_TOKEN=false
Copied!
Optional: If you plan to use Etherscan or BlockScout for exploring your chain, find information on the correct parameters to include in the .env file here: https://docs.tokenbridge.net/about-tokenbridge/features/contracts-verification-in-explorers

3) Deploy Contracts

There are two options to deploy bridge contracts, you can use npm or docker. If using an official release, we recommend Docker.

Docker

Deploy with Docker (here we have named the env file erc-to-native.config rather than .env). More information on Docker deployment is available here.
1
docker run -it --env-file ./erc-to-native.config poanetwork/tokenbridge-contracts:latest deploy.sh
Copied!

NPM

1
npm i
2
npm run compile
3
cd deploy
4
npm i
5
node deploy.js
Copied!
Last modified 1yr ago