Skip to content
Branch: master
Find file History
Latest commit 77fbc53 Dec 4, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
1_initial_migration.js
2_deploy_root_contracts.js Pass Heimdall Id to rootChain constructor Nov 25, 2019
3_initialize_state.js update deploy-migrations for stateSender flow Sep 18, 2019
4_deploy_child_contracts.js Add test for mint -> startExitForMintableBurntTokens -> depositERC721… Dec 4, 2019
5_sync_child_state_to_root.js Add test for mint -> startExitForMintableBurntTokens -> depositERC721… Dec 4, 2019
README.md Add heimdall id in migration + accept params for staking Nov 25, 2019
utils.js add predicates / tokens to deploy_migrations Sep 5, 2019

README.md

Deploy Contracts

1️⃣ We have some network configrations available.

Network Name URL Network ID
ropsten https://ropsten.infura.io/v3/${API_KEY} 3
mainnet https://mainnet.infura.io/v3/${API_KEY} 1
bor_testnet2 https://testnet2.matic.network 8995
development http://localhost:8545 *
matic_dev http://localhost:8546 *

Feel free to add your own. Update the chain url in networks.matic key in truffle-config.js.

2️⃣ Export variables

// (Optional) Only if you are using ethereum testnets
export API_KEY=<Infura PROJECT ID>

// For `developement` networks you can use the mnemonic present in package.json
export MNEMONIC=<mnemonic>

export HEIMDALL_ID=<>
e.g. export HEIMDALL_ID="heimdall-P5rXwg"

3️⃣ Compile contracts

npm run truffle:compile

4️⃣ Deploy contracts

We need to deploy our set of contracts on 2 chains:

  • Base Chain: Ideally a higher security EVM chain which can be used for dispute resolution. For testing ganache or any other EVM chain should work.
  • Child Chain: EVM compatible chain to work as our sidechain. For testing note that using ganache for child-chain is not recommended, instead invoking npm run bor:simulate would be better.
mv migrations dev-migrations && cp -r deploy-migrations migrations

// Root contracts are deployed on base chain
npm run truffle:migrate -- --reset --to 3 --network <base_chain_network_name>

// Contracts like ChildERC20Token are deployed on child chain aka BOR chain
// NOTE: You need to deploy or simulate BOR before running the below command
npm run truffle:migrate -- --reset -f 4 --to 4 --network <child_chain_network_name>


// Contracts deployed on BOR are mapped to the registry contract deployed on-chain
npm run truffle:migrate -- -f 5 --to 5 --network <base_chain_network_name>

Post successfull deployment all contract addresses will be written to a contractAddresses.json file.

Check account that you are deploying from has ether for the network you are deploying on.

5️⃣ Stake to become a validator

// (Optional) Export mnemonic or the private key (without the 0x prefix)
// This account needs to have test token
export MNEMONIC=<>

// (Optional) Infura PROJECT ID, if required
export API_KEY=<PROJECT_ID>

npm run truffle exec scripts/stake.js -- --network <base_chain_network_name> <validator_account> <# tokens to stake>
e.g. npm run truffle exec scripts/stake.js -- --network development 0xE0938d9fd679bB6B83bf31fA62c433646B9F749e 10
You can’t perform that action at this time.