Skip to content

Dev2 Deployment

Aalavandhan edited this page Sep 12, 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 "0xBd2949F67DcdC549c6Ebe98696449Fa79D988A9F" \
  --generic-handler-address "0xa023E6f6B4862EA38cbe45e377abD908abAb2f82"

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 "0xCf6ba7Eb4962e559f45CF61be1a1dB72872e3306" \
  --generic-handler-address "0xCD9211E3057313da2682F63d3410Bf231B38d769"

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 \
  --bridge "matic" \
  --satellite-chain-networks "[\"dev2MumbaiSatChain\" ]"

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

# prints ampl balances across chains
yarn hardhat info:ampl:balance \
  --networks "[\"dev2GoerliBaseChain\", \"dev2MumbaiSatChain\" ]" \
  --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:base_chain \
  --keyfile $KEYFILE --passphrase $PASSPHRASE

# wait for relayer to report rebase execute rebase on satellite chains
yarn hardhat rebase:satellite_chain \
  --networks "[\"dev2MumbaiSatChain\"]" \
  --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

# 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"