build

Centrifuge - Ethereum Bridge

Bridge Contract & Accounts

Token Supply

The bridge supply can be audited by comparing the number of tokens stored on the Centrifuge Chain bridge account with the ERC20 token supply of wCFG on Ethereum.

  • Centrifuge Chain (CFG): 4dpEcgqFp8UL6eA3b7hhtdj7qftHRZE7g1uadHyuw1WSNSgH
  • Ethereum (wCFG): 0xc221b7e65ffc80de234bbb6667abdd46593d34f0

Relayer Threshold

You can submit an RPC call to a full node and query chainBridge.relayerThreshold. This will give you the number of confirmations needed on the Centrifuge Chain to trigger a transfer.

On Ethereum, you can query the Chainbridge public method _relayerThreshold()(uint8):

1seth call 0xFe50BA7241b635Eda23a32875c383A34E8a3596c '_relayerThreshold()(uint8)'

Install ChainBridge Client tool

1export CB_DEPLOY=${CB_DEPLOY:-v1.0.0}
2CB_SOL_COMMIT=${CB_SOL_COMMIT:-v1.0.0}
3
4cd $PARENT_DIR
5git clone https://github.com/ChainSafe/chainbridge-deploy.git
6cd $PARENT_DIR/chainbridge-deploy
7git checkout $CB_CB_DEPLOY
8
9BRIDGE_DEPLOYMENT_DIR=$PARENT_DIR/chainbridge-deploy/cb-sol-cli
10cd $BRIDGE_DEPLOYMENT_DIR
11GIT_COMMIT=$CB_SOL_COMMIT make install

Script Dependencies

Install subkey [Optional]

In the bash snippet below, we use subkey to convert the SS58 address into its public key representation, required by the deposit operation.

Follow instructions here: https://github.com/paritytech/substrate/tree/master/bin/utils/subkey

Or run the docker image: https://hub.docker.com/r/parity/subkey

Install Jq [Optional]

In the bash snippet below, we use jq to parse a JSON output. You can choose to omit that and paste the address manually. Otherwise, follow instructions here to install in your distribution: https://stedolan.github.io/jq/.

Set environment variables

Please submit a ticket on Discord for contract addresses.

1export ETH_RPC_URL="YOUR_ETH_CLIENT_URL"
2ETH_PRIVATE_KEY="YOUR_PRIVATE_KEY"
3ETH_GAS_LIMIT=300000
4BRIDGE_ERC20_RESOURCE_ID="0x00000000000000000000000000000009e974040e705c10fb4de576d6cc261900"

Amber (Kovan) Config:

1export ERC20_ADDRESS="AMBER_ERC20_CONTRACT"
2BRIDGE_ADDRESS="AMBER_BRIDGE_CONTRACT"
3BRIDGE_ERC20_HANDLER="AMBER_ERC20_HANDLER"
4ETH_GAS_PRICE=10000000000

Mainnet Config:

1export ERC20_ADDRESS="MAINNET_ERC20_CONTRACT"
2BRIDGE_ADDRESS="MAINNET_BRIDGE_CONTRACT"
3BRIDGE_ERC20_HANDLER="MAINNET_ERC20_HANDLER"
4ETH_GAS_PRICE=40000000000

Substrate Native to ERC20 Ethereum

In the substrate UI, select the Extrinsics tab and call palletBridge.transferNative with these parameters:

  • Amount: 1000000000000000000 (= 1 CFG)
  • Recipient: YOUR_ETH_TARGET_ACCOUNT
  • Dest Id: 0

Depending on environment and network state, this may take some time.

You can query the recipients balance on Ethereum:

1cb-sol-cli --url $ETH_RPC_URL erc20 balance --address YOUR_ETH_TARGET_ACCOUNT --erc20Address $ERC20_ADDRESS

ERC20 to Substrate Native

Approve ERC20 Handler to move tokens on your behalf:

1cb-sol-cli --gasLimit $ETH_GAS_LIMIT --gasPrice $ETH_GAS_PRICE --privateKey $ETH_PRIVATE_KEY --url $ETH_RPC_URL erc20 approve --amount 1000000000000000000 --recipient $BRIDGE_ERC20_HANDLER --erc20Address $ERC20_ADDRESS

Trigger Deposit against target chain and address:

1TARGET_SUBSTRATE_ADDR="YOUR_SUBSTRATE_SS58_ADDRESS"
2TARGET_PUBLICKEY=`subkey inspect --output-type json $TARGET_SUBSTRATE_ADDR | jq -r '.publicKey'`
3
4cb-sol-cli --gasLimit $ETH_GAS_LIMIT --gasPrice $ETH_GAS_PRICE --privateKey $ETH_PRIVATE_KEY --url $ETH_RPC_URL erc20 deposit --amount 1000000000000000000 --dest 1 --recipient $TARGET_PUBLICKEY --resourceId $BRIDGE_ERC20_RESOURCE_ID --bridge $BRIDGE_ADDRESS