Skip to content

Dev2 Deployment

Aalavandhan edited this page Sep 30, 2022 · 10 revisions
  1. Setup deployer key
# create keyfile
export KEYFILE=[Path to key file]
export PASSPHRASE=
  1. Deploy AMPL contracts
# create new deployment
yarn hardhat --network dev2GoerliBaseChain testnet:deploy:ampleforth \
  --keyfile $KEYFILE --passphrase $PASSPHRASE 

# deploy vault
yarn hardhat --network dev2GoerliBaseChain deploy:token_vault \
  --bridge "matic" \
  --keyfile $KEYFILE --passphrase $PASSPHRASE 

yarn hardhat --network dev2GoerliBaseChain deploy:token_vault \
  --bridge "chainBridge" \
  --keyfile $KEYFILE --passphrase $PASSPHRASE 

# deploy on mumbai testnet
yarn hardhat \
  --network dev2MumbaiSatChain \
  deploy:ampleforth_xc \
  --keyfile $KEYFILE --passphrase $PASSPHRASE \
  --token-name "Ampleforth secured by Matic" \
  --token-symbol "AMPL" \
  --base-chain-network dev2GoerliBaseChain

# deploy on meter testnet
yarn hardhat \
  --network dev2MeterTestnetSatChain \
  deploy:ampleforth_xc \
  --keyfile $KEYFILE --passphrase $PASSPHRASE \
  --token-name "Ampleforth secured by Matic" \
  --token-symbol "AMPL" \
  --base-chain-network dev2GoerliBaseChain
  1. Deploy gateway contracts
yarn hardhat --network dev2GoerliBaseChain deploy:matic_base_chain \
  --keyfile $KEYFILE --passphrase $PASSPHRASE \
  --checkpoint-manager "0x2890bA17EfE978480615e330ecB65333b880928e" \
  --fx-root "0x3d1d3E34f7fB6D26245E6640E1c50710eFFf15bA"

yarn hardhat --network dev2MumbaiSatChain deploy:matic_satellite_chain \
  --keyfile $KEYFILE --passphrase $PASSPHRASE \
  --fx-child "0xCf73231F28B7331BBe3124B907840A94851f9f11"

yarn hardhat deploy:matic_connection \
  --keyfile $KEYFILE --passphrase $PASSPHRASE \
  --base-chain-network "dev2GoerliBaseChain" \
  --sat-chain-network "dev2MumbaiSatChain"

yarn hardhat --network dev2GoerliBaseChain deploy:chain_bridge_use_deployed \
  --bridge-address "0x2Ff19376B6F27A03B621b5c018f852BFAa416835" \
  --generic-handler-address "0xEe373E583e313B0bd9d7dc6DEc694dc074212e86"

yarn hardhat --network dev2GoerliBaseChain deploy:chain_bridge_base_chain \
  --keyfile $KEYFILE --passphrase $PASSPHRASE \
  --use-deployed true

yarn hardhat --network dev2MeterTestnetSatChain deploy:chain_bridge_use_deployed \
  --bridge-address "0xcE785E92bc448de7c58D3f7D74F2BDcEd9Cc7c49" \
  --generic-handler-address "0x64BBA8492a0CfaB65a954860Cf1D99b28eD2D418"

yarn hardhat --network dev2MeterTestnetSatChain deploy:chain_bridge_satellite_chain \
  --keyfile $KEYFILE --passphrase $PASSPHRASE \
  --use-deployed true
  1. Deploy and setup rebase report batcher utility if not already deployed
yarn hardhat --network dev2GoerliBaseChain deploy:rebase_reporter \
  --keyfile $KEYFILE --passphrase $PASSPHRASE 

yarn hardhat --network dev2GoerliBaseChain deploy:rebase_reporter:prep_tx \
  --keyfile $KEYFILE --passphrase $PASSPHRASE \
  --bridges "[\"matic\", \"chainBridge\"]" \
  --satellite-chain-networks "[\"dev2MumbaiSatChain\",\"dev2MeterTestnetSatChain\" ]"
  1. Inspect state
# prints ampl state
yarn hardhat info:ampl \
  --networks "[\"dev2GoerliBaseChain\", \"dev2MumbaiSatChain\"]" \
  --bridge "matic"

yarn hardhat info:ampl \
  --networks "[\"dev2GoerliBaseChain\", \"dev2MeterTestnetSatChain\"]" \
  --bridge "chainBridge"

# prints bridge info
yarn hardhat info:chain_bridge \
  --networks "[\"dev2GoerliBaseChain\", \"dev2MeterTestnetSatChain\", ]"

# prints ampl balances across chains
yarn hardhat info:ampl:balance \
  --networks "[\"dev2GoerliBaseChain\", \"dev2MumbaiSatChain\", \"dev2MeterTestnetSatChain\" ]" \
  --wallet "0x3b2b9EfdaE5291F3Bb9C7e6508C7e67534511585"
  1. Cross-chain transactions
yarn hardhat --network dev2GoerliBaseChain testnet:rebase:base_chain \
  --keyfile $KEYFILE --passphrase $PASSPHRASE \
  --rebase-perc 10

# report rebase from base-chain to satellite-chains
yarn hardhat --network dev2GoerliBaseChain matic:report_rebase \
  --keyfile $KEYFILE --passphrase $PASSPHRASE

yarn hardhat --network dev2GoerliBaseChain chain_bridge:report_rebase \
  --satellite-chain-network "dev2MeterTestnetSatChain" \
  --keyfile $KEYFILE --passphrase $PASSPHRASE

# wait for relayer to report rebase execute rebase on satellite chains
yarn hardhat rebase:satellite_chain \
  --networks "[\"dev2MumbaiSatChain\", \"dev2MeterTestnetSatChain\"]" \
  --keyfile $KEYFILE --passphrase $PASSPHRASE


# cross-chain transfer from base to satellite
yarn hardhat --network dev2GoerliBaseChain matic:xc_transfer \
  --keyfile $KEYFILE --passphrase $PASSPHRASE \
  --recipient-address "0x3b2b9EfdaE5291F3Bb9C7e6508C7e67534511585" \
  --amount 100

yarn hardhat --network dev2GoerliBaseChain chain_bridge:xc_transfer \
  --target-chain-network dev2MeterTestnetSatChain \
  --keyfile $KEYFILE --passphrase $PASSPHRASE \
  --recipient-address "0x3b2b9EfdaE5291F3Bb9C7e6508C7e67534511585" \
  --amount 100

# cross-chain transfer from satellite to base
yarn hardhat --network dev2MumbaiSatChain matic:xc_transfer \
  --keyfile $KEYFILE --passphrase $PASSPHRASE \
  --recipient-address "0x3b2b9EfdaE5291F3Bb9C7e6508C7e67534511585" \
  --amount 50

yarn hardhat matic:xc_transfer:commit \
 --keyfile $KEYFILE --passphrase $PASSPHRASE \
 --base-chain-network "dev2GoerliBaseChain" \
 --sat-chain-network "dev2MumbaiSatChain" \
 --tx-hash "PASTE_FROM_PREV"

yarn hardhat --network dev2MeterTestnetSatChain chain_bridge:xc_transfer \
  --target-chain-network dev2GoerliBaseChain \
  --keyfile $KEYFILE --passphrase $PASSPHRASE \
  --recipient-address "0x3b2b9EfdaE5291F3Bb9C7e6508C7e67534511585" \
  --amount 50