👒Development Guide

This guide provides detailed instructions for compiling, deploying, testing, and interacting with the core smart contracts essential to Shadow Bridge. The principal contracts include ShadowBridgeToken, GovernorAlpha/Timelock, Boreas, and ShadowBridge (Coin, ERC20).

Preparation

  • Install Truffle

npm install -g truffle
  • Install Dependencies

npm install
  • Install Ioctl Install ioctl, a command-line tool for blockchain interactions, as per the instructions provided in the Shadow Bridge Documentation.

Compile Contracts

npm run build:contract

Deploy Contracts

  • ShadowBridgeToken Deploy a ShadowBridgeToken sbt:

ioctl contract deploy bytecode SBG_TOKEN_BYTECODE ABI_PATH '{"_operator": "OPERATOR_ADDRESS", "_lp": "INITIAL_LP_ADDRESS"}'
  • Timelock & GovernorAlpha Deploy Timelock tl:

ioctl contract deploy bytecode TIMELOCK_BYTECODE TIMELOCK_ABI_PATH '{"admin_": DEPLOY_ADMIN_ADDRESS, "delay_": DELAY_IN_SEC}'
  • Deploy GovernorAlpha ga (e.g., voting duration: 3 days):

ioctl contract deploy bytecode GOVERNOR_BYTECODE GOVERNOR_ABI_PATH '{"timelock_": TIMELOCK_ADDRESS, "sbg_": SBG_ADDRESS, "guardian_": ADMIN_ADDRESS, "votingDuration_": 51840}'
  • Set Timelock's pending admin to GovernorAlpha ga:

ioctl contract invoke function TIMELOCK_ADDRESS TIMELOCK_ABI_PATH "setPendingAdmin" --with-arguments '{"pendingAdmin_": GOVERNOR_ADDRESS}'
  • Accept Admin from GovernorAlpha ga triggered by guardian:

ioctl contract invoke function GOVERNOR_ADDRESS GOVERNOR_ABI_PATH "__acceptAdmin"
  • Boreas Add Liquidity for SBG/IOTX on MimoFactory and receive SBG-IOTX LP Token:

ioctl contract deploy bytecode BOREAS_BYTECODE ABI_PATH '{"_sbgToken": SBG_TOKEN, "_lpToken": LP_TOKEN}'
  • Invoke sbt.addMinter() to set Boreas as minters for SBG token:

ioctl contract invoke function SBG_ADDRESS SBG_ABI_PATH "addMinter" --with-arguments '{"_minter": BOREAS_ADDRESS}'
  • ShadowBridge (Coin, ERC20) Deploy Hasher hr and Verifier vr:

ioctl contract deploy bytecode HASHER_BYTECODE ioctl contract deploy bytecode VERIFIER_BYTECODE
  • Deploy CoinShadowBridge csb and ERC20ShadowBridge esb linked by Hasher hr with Boreas, vr, sbt, mf and, if necessary, XRC20 token address:

ioctl contract deploy bytecode CoinShadowBridge_LINKED_BYTECODE CoinShadowBridge_ABI_PATH '{"_verifier": VERIFIER_ADDRESS, "_sbgToken": SBG_ADDRESS, "_mimoFactory": MIMOFACTORY_ADDRESS, "_boreas": BOREAS_ADDRESS, "_initDenomination": DENOMINATION_AMOUNT, "_denominationRound": DENOMINATION_ROUND, "_merkleTreeHeight": MERKLETREE_HEIGHT, "_operator": TIMELOCK_ADDRESS}' ioctl contract deploy bytecode ERC20ShadowBridge_LINKED_BYTECODE ERC20ShadowBridge_ABI_PATH '{"_verifier": VERIFIER_ADDRESS, "_sbgToken": SBG_ADDRESS, "_mimoFactory": MIMOFACTORY_ADDRESS, "_boreas": BOREAS_ADDRESS, "_initDenomination": DENOMINATION_AMOUNT, "_denominationRound": DENOMINATION_ROUND, "_merkleTreeHeight": MERKLETREE_HEIGHT, "_operator": TIMELOCK_ADDRESS, "_xrc20Token": XRC20TOKEN_ADDRESS}'

Testing Contracts

Use Node.js version 11.15.0 with nvm and build zk circuits using npm run build.

  • For the test network:

npm run test
  • For the development network, adjust truffle-config.js for the development network settings, then run ganache-cli -i 1337 and npm run test.

Interacting with Contracts

Refer to the detailed steps to set up your environment for depositing, withdrawing, and engaging with the governance process through the GovernorAlpha contract. These steps will guide you in proposing and voting on changes within the Shadow Bridge ecosystem.

Last updated