Search…
Smart Contracts Configuration
In this example, we would like to show how to config to setup a connection between ICON and Moonriver networks. For other cases, there might be a different configuration
Attention: This configuration step must be executed after completely deploying smart contracts (BSH, BMC, and BMV) on both connecting networks and generating keystore files of both BTP Message Relays (BMRs)

1. ICON-BMC Configuration

Generate Owner and Register Owner of BMC

1
cd $PROJECT_DIR/btp
2
3
# Replace YOUR_PASSWORD if needed
4
YOUR_PASSWORD=1234
5
6
goloop ks gen --out $CONFIG_DIR/bmc-owner.json --password $YOUR_PASSWORD
7
8
# Create a secret file 'bmc-owner.secret' and save $YOUR_PASSWORD into that file
9
echo -n $YOUR_PASSWORD > $CONFIG_DIR/bmc-owner.secret
10
11
# Save bmc-owner address to a file
12
echo $(jq -r '.address' "$CONFIG_DIR/bmc-owner.json") > $CONFIG_DIR/bmc-owner.addr
13
14
# Register Owner
15
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx call --to $(cat $CONFIG_DIR/bmc.icon) \
16
--key_store $CONFIG_DIR/goloop.keystore.json \
17
--key_password $(cat $CONFIG_DIR/goloop.keysecret) \
18
--nid $(cat $CONFIG_DIR/nid.icon) \
19
--step_limit 13610920001 \
20
--method addOwner \
21
--param _addr=$(cat $CONFIG_DIR/bmc-owner.addr) \
22
| jq -r . > $CONFIG_DIR/tx.addBMCOwner.icon
23
# Also check whether this transaction is successful
24
# goloop rpc --uri http://127.0.0.1:9080/api/v3/icon txresult $(cat $CONFIG_DIR/tx.addBMCOwner.icon)
25
# If fail, it shows error message and status '0x0'
26
# Otherwise, status '0x1
27
28
29
# Add funds to BMC-Owner
30
AMOUNT=1000000000000000000000000
31
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx transfer \
32
--to $(cat $CONFIG_DIR/bmc-owner.addr) --value $AMOUNT \
33
--key_store $CONFIG_DIR/goloop.keystore.json \
34
--key_password $(cat $CONFIG_DIR/goloop.keysecret) \
35
--nid $(cat $CONFIG_DIR/nid.icon) \
36
--step_limit 10000000000 | jq -r . > $CONFIG_DIR/tx.bmcOwner.addFund
37
# Also check whether this transaction is successful
38
# goloop rpc --uri http://127.0.0.1:9080/api/v3/icon txresult $(cat $CONFIG_DIR/tx.bmcOwner.addFund)
39
# If fail, it shows error message and status '0x0'
40
# Otherwise, status '0x1
Copied!

Add BMV

1
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx call --to $(cat $CONFIG_DIR/bmc.icon) \
2
--key_store $CONFIG_DIR/bmc-owner.json \
3
--key_password $(cat $CONFIG_DIR/bmc-owner.secret) \
4
--nid $(cat $CONFIG_DIR/nid.icon) \
5
--step_limit 13610920001 \
6
--method addVerifier \
7
--param _net=$(cat $CONFIG_DIR/net.btp.dst) \
8
--param _addr=$(cat $CONFIG_DIR/bmv.icon) \
9
| jq -r . > $CONFIG_DIR/tx.verifier.icon
10
11
# Also check whether this transaction is successful
12
# goloop rpc --uri http://127.0.0.1:9080/api/v3/icon txresult $(cat $CONFIG_DIR/tx.verifier.icon)
13
# If fail, it shows error message and status '0x0'
14
# Otherwise, status '0x1'
Copied!
1
echo $(cat $CONFIG_DIR/bmc_perif.btp.addr) > $CONFIG_DIR/btp.dst
2
3
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx call --to $(cat $CONFIG_DIR/bmc.icon) \
4
--key_store $CONFIG_DIR/bmc-owner.json \
5
--key_password $(cat $CONFIG_DIR/bmc-owner.secret) \
6
--nid $(cat $CONFIG_DIR/nid.icon) \
7
--step_limit 13610920001 \
8
--method addLink \
9
--param _link=$(cat $CONFIG_DIR/btp.dst) \
10
| jq -r . > $CONFIG_DIR/tx.link.icon
11
# Also check whether this transaction is successful
12
# goloop rpc --uri http://127.0.0.1:9080/api/v3/icon txresult $(cat $CONFIG_DIR/tx.link.icon)
13
# If fail, it shows error message and status '0x0'
14
# Otherwise, status '0x1'
Copied!
In success, a connection link from ICON-BMC to Moonriver-BMC will be set with default setting values:
      + BLOCK_INTERVAL_MSEC: block interval of Moonriver (default = 1000ms)
      + MAX_AGGREGATION: max_aggregation value (default = 10)
      + DELAY_LIMIT: acceptance of delayed submission sending from BMR to BMC (default = 3)
  This step will help you to change default setting values
1
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx call --to $(cat $CONFIG_DIR/bmc.icon) \
2
--key_store $CONFIG_DIR/bmc-owner.json \
3
--key_password $(cat $CONFIG_DIR/bmc-owner.secret) \
4
--nid $(cat $CONFIG_DIR/nid.icon) \
5
--step_limit 13610920001 \
6
--method setLinkRotateTerm \
7
--param _link=$(cat $CONFIG_DIR/btp.dst) \
8
--param _block_interval=0x1770 \
9
--param _max_agg=0x08 \
10
| jq -r . > $CONFIG_DIR/tx.setLinkRotateTerm.icon
11
12
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx call --to $(cat $CONFIG_DIR/bmc.icon) \
13
--key_store $CONFIG_DIR/bmc-owner.json \
14
--key_password $(cat $CONFIG_DIR/bmc-owner.secret) \
15
--nid $(cat $CONFIG_DIR/nid.icon) \
16
--step_limit 13610920001 \
17
--method setLinkDelayLimit \
18
--param _link=$(cat $CONFIG_DIR/btp.dst) \
19
--param _value=4 \
20
| jq -r . > $CONFIG_DIR/tx.setLinkDelayLimit.icon
21
22
# Also check whether these transactions are successful
23
# For example: goloop rpc --uri http://127.0.0.1:9080/api/v3/icon txresult $(cat $CONFIG_DIR/tx.setLinkRotateTerm.icon)
24
# If fail, it shows error message and status '0x0'
25
# Otherwise, status '0x1'
Copied!
1
# The link status will then be used in BMR settings. Please do not skip this step
2
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon call \
3
--to $(cat $CONFIG_DIR/bmc.icon) --method getStatus --param _link=$(cat $CONFIG_DIR/btp.dst) \
4
| jq -r . > $CONFIG_DIR/getStatus.bmc.icon
5
6
ICON_OFFSET="$(eval "echo $(jq -r '.verifier.offset' "$CONFIG_DIR/getStatus.bmc.icon")")"
7
8
echo -n $ICON_OFFSET > $CONFIG_DIR/icon.offset
Copied!

Add BSH Service contract

1
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx call --to $(cat $CONFIG_DIR/bmc.icon) \
2
--key_store $CONFIG_DIR/bmc-owner.json \
3
--key_password $(cat $CONFIG_DIR/bmc-owner.secret) \
4
--nid $(cat $CONFIG_DIR/nid.icon) \
5
--step_limit 13610920001 \
6
--method addService \
7
--param _addr=$(cat $CONFIG_DIR/nativeCoinBsh.icon) \
8
--param _svc=nativecoin \
9
| jq -r . > $CONFIG_DIR/tx.addService.icon
10
# Also check whether this transaction is successful
11
# goloop rpc --uri http://127.0.0.1:9080/api/v3/icon txresult $(cat $CONFIG_DIR/tx.addService.icon)
12
# If fail, it shows error message and status '0x0'
13
# Otherwise, status '0x1'
Copied!

Register Relay to ICON-BMC

1
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx call --to $(cat $CONFIG_DIR/bmc.icon) \
2
--key_store $CONFIG_DIR/bmc-owner.json \
3
--key_password $(cat $CONFIG_DIR/bmc-owner.secret) \
4
--nid $(cat $CONFIG_DIR/nid.icon) \
5
--step_limit 13610920001 \
6
--method addRelay \
7
--param _link=$(cat $CONFIG_DIR/btp.dst) \
8
--param _addr=$(jq -r .address $CONFIG_DIR/icon-bmr.keystore.json) \
9
| jq -r . > $CONFIG_DIR/tx.registerRelay.icon
10
# Also check whether this transaction is successful
11
# goloop rpc --uri http://127.0.0.1:9080/api/v3/icon txresult $(cat $CONFIG_DIR/tx.registerRelay.icon)
12
# If fail, it shows error message and status '0x0'
13
# Otherwise, status '0x1'
Copied!

Set FeeAggregation address to ICON-BMC

1
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx call --to $(cat $CONFIG_DIR/bmc.icon) \
2
--key_store $CONFIG_DIR/bmc-owner.json \
3
--key_password $(cat $CONFIG_DIR/bmc-owner.secret) \
4
--nid $(cat $CONFIG_DIR/nid.icon) \
5
--step_limit 13610920001 \
6
--method setFeeAggregator \
7
--param _addr=$(cat $CONFIG_DIR/feeAggregation.icon) \
8
| jq -r . > $CONFIG_DIR/tx.addFeeAggregation.icon
9
# Also check whether this transaction is successful
10
# goloop rpc --uri http://127.0.0.1:9080/api/v3/icon txresult $(cat $CONFIG_DIR/tx.addFeeAggregation.icon)
11
# If fail, it shows error message and status '0x0'
12
# Otherwise, status '0x1'
Copied!

2. Config NativeCoin BSH

    Generate Owner and Register Owner of NativeCoinBSH
1
# Replace YOUR_PASSWORD if needed
2
YOUR_PASSWORD=1234
3
4
goloop ks gen --out $CONFIG_DIR/nativecoinBSH-owner.json --password $YOUR_PASSWORD
5
6
# Create a secret file 'nativecoinBSH-owner.secret' and save $YOUR_PASSWORD into that file
7
echo -n $YOUR_PASSWORD > $CONFIG_DIR/nativecoinBSH-owner.secret
8
9
# Save nativecoinBSH-owner address to a file
10
echo $(jq -r '.address' "$CONFIG_DIR/nativecoinBSH-owner.json") > $CONFIG_DIR/nativecoinBSH-owner.addr
11
12
# Register Owner
13
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx call --to $(cat $CONFIG_DIR/nativeCoinBsh.icon) \
14
--key_store $CONFIG_DIR/goloop.keystore.json \
15
--key_password $(cat $CONFIG_DIR/goloop.keysecret) \
16
--nid $(cat $CONFIG_DIR/nid.icon) \
17
--step_limit 13610920001 \
18
--method addOwner \
19
--param _addr=$(cat $CONFIG_DIR/nativecoinBSH-owner.addr) \
20
| jq -r . > $CONFIG_DIR/tx.addNativeCoinBSHOwner.icon
21
22
# Add funds to BSH-Owner
23
AMOUNT=1000000000000000000000000
24
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx transfer \
25
--to $(cat $CONFIG_DIR/nativecoinBSH-owner.addr) --value $AMOUNT \
26
--key_store $CONFIG_DIR/goloop.keystore.json \
27
--key_password $(cat $CONFIG_DIR/goloop.keysecret) \
28
--nid $(cat $CONFIG_DIR/nid.icon) \
29
--step_limit 10000000000 | jq -r . > $CONFIG_DIR/tx.bshOwner.addFund
30
# Also check whether this transaction is successful
31
# goloop rpc --uri http://127.0.0.1:9080/api/v3/icon txresult $(cat $CONFIG_DIR/tx.bshOwner.addFund)
32
# If fail, it shows error message and status '0x0'
33
# Otherwise, status '0x1
Copied!
    Register 'DEV' token
1
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx call --to $(cat $CONFIG_DIR/nativeCoinBsh.icon) \
2
--key_store $CONFIG_DIR/nativecoinBSH-owner.json \
3
--key_password $(cat $CONFIG_DIR/nativecoinBSH-owner.secret) \
4
--nid $(cat $CONFIG_DIR/nid.icon) \
5
--step_limit 13610920001 \
6
--method register \
7
--param _name=DEV \
8
| jq -r . > $CONFIG_DIR/tx.registerCoin.icon
9
# Also check whether this transaction is successful
10
# goloop rpc --uri http://127.0.0.1:9080/api/v3/icon txresult $(cat $CONFIG_DIR/tx.registerCoin.icon)
11
# If fail, it shows error message and status '0x0'
12
# Otherwise, status '0x1'
Copied!
    Set Fee Ratio
1
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx call --to $(cat $CONFIG_DIR/nativeCoinBsh.icon) \
2
--key_store $CONFIG_DIR/nativecoinBSH-owner.json \
3
--key_password $(cat $CONFIG_DIR/nativecoinBSH-owner.secret) \
4
--nid $(cat $CONFIG_DIR/nid.icon) \
5
--step_limit 13610920001 \
6
--method setFeeRatio \
7
--param _feeNumerator=100 \
8
| jq -r . > $CONFIG_DIR/tx.setFeeRatio.icon
9
# Also check whether this transaction is successful
10
# goloop rpc --uri http://127.0.0.1:9080/api/v3/icon txresult $(cat $CONFIG_DIR/tx.setFeeRatio.icon)
11
# If fail, it shows error message and status '0x0'
12
# Otherwise, status '0x1'
Copied!
    Set NativeCoinBSH as an Owner of IRC31Token
1
goloop rpc --uri http://127.0.0.1:9080/api/v3/icon sendtx call \
2
--to $(cat $CONFIG_DIR/irc31token.icon) \
3
--key_store $CONFIG_DIR/goloop.keystore.json \
4
--key_password $(cat $CONFIG_DIR/goloop.keysecret) \
5
--nid $(cat $CONFIG_DIR/nid.icon) \
6
--step_limit 13610920001 \
7
--method addOwner \
8
--param _addr=$(cat $CONFIG_DIR/nativeCoinBsh.icon) \
9
| jq -r . > $CONFIG_DIR/tx.addOwnerIrc31.icon
10
# Also check whether this transaction is successful
11
# goloop rpc --uri http://127.0.0.1:9080/api/v3/icon txresult $(cat $CONFIG_DIR/tx.addOwnerIrc31.icon)
12
# If fail, it shows error message and status '0x0'
13
# Otherwise, status '0x1'
Copied!

3. Config Moonriver BMC

    Preparation
      Generate Relay's address ---> follow this instruction [link] if you have not completed this step
      Prepare addresses of BMC, BSH, BMV and Relay
1
export ICON_BTP_ADDRESS=$(cat $CONFIG_DIR/btp.icon)
2
export BSH_MOONBEAM=$(cat $CONFIG_DIR/bsh.moonbeam)
3
export BMV_MOONBEAM=$(cat $CONFIG_DIR/bmv.moonbeam)
4
export RELAY_ADDRESS=$(cat $CONFIG_DIR/moon-bmr.addr)
5
export ICON_NET=$(cat $CONFIG_DIR/net.btp.icon)
Copied!
    Launch Truffle console
1
$PROJECT_DIR/btp/build/contracts/solidity/bmc
2
3
npm install -g chai
4
5
# Add BMV
6
truffle exec $SCRIPT_DIR/mb_bmc_add_verifier.js --network moonbeamlocal
7
8
# Add a connection link to ICON's BMC
9
# The below command helps to set a connection link from Moonriver-BMC to ICON-BMC with default setting values:
10
# + `BLOCK_INTERVAL_MSEC`: block interval of ICON (default = 1000ms)
11
# + `MAX_AGGREGATION`: max_aggregation value (default = 10)
12
# + `DELAY_LIMIT`: acceptance of delayed submission sending from BMR to BMC (default = 3)
13
# Then, change default setting values as:
14
# + `BLOCK_INTERVAL_MSEC`: block interval of ICON (default -> 3000ms)
15
# + `MAX_AGGREGATION`: max_aggregation value (default -> 5)
16
# + `DELAY_LIMIT`: acceptance of delayed submission sending from BMR to BMC (default -> 3)
17
# Please modify this script to change your expected settings
18
truffle exec $SCRIPT_DIR/mb_bmc_add_link.js --network moonbeamlocal
19
20
# Add services to BMCManagement
21
# The script below adds:
22
# + Register service name `nativecoin` and bind this service to BSH_MOONBEAM address
23
# + Register RELAY_ADDRESS and add to `ICON_BTP_ADDRESS`
24
truffle exec $SCRIPT_DIR/mb_bmc_add_service.js --network moonbeamlocal
25
26
# Get Link Status: please DO NOT skip this step. This output will then be used to set parameters to deploy BMR
27
truffle exec $SCRIPT_DIR/mb_bmc_get_linkStat.js --network moonbeamlocal
28
29
echo $(jq -r '.offsetMTA' "$CONFIG_DIR/bmc_linkstats.moonbeam") > $CONFIG_DIR/moon.offset
Copied!

4. Config Moonriver BSH

    Run the script to register ICX
1
cd $PROJECT_DIR/btp/build/contracts/solidity/bsh
2
3
truffle exec $SCRIPT_DIR/mb_bsh_register_coin.js --network moonbeamlocal
Copied!
Last modified 1mo ago