Deploy Smart Contracts (Moonriver)
Before deploying these contracts, please make sure you have deployed a local node in the Moonriver Network. If you have not done this step, please check out this link and accomplish it

1. Deploy BMC Contracts on Moonriver Network

  • Run following commands:
1
cd $PROJECT_DIR/btp/build/contracts/solidity/bmc
2
3
SCRIPT_DIR=$PROJECT_DIR/btp/docker-compose/goloop2moonbeam/scripts
4
5
yarn
6
7
# Please run these commands one by one to avoid unexpected error
8
rm -rf .openzeppelin && truffle compile --all
9
10
# @param
11
# - BMC_BTP_NET: Chain ID and name of a network that BMC is going to deploy on, e.g. '0x501.pra'
12
export BMC_BTP_NET=0x501.pra
13
14
truffle migrate --network moonbeamlocal
15
16
# Run script to extract BMCPeriphery and BMCManagement addresses
17
# BMCPeriphery address -> $CONFIG_DIR/bmc.moonbeam
18
# BMCManagement address -> $CONFIG_DIR/bmc_management.moonbeam
19
truffle exec $SCRIPT_DIR/mb_extract_bmc.js --network moonbeamlocal
20
21
echo "btp://$BMC_BTP_NET/$(cat $CONFIG_DIR/bmc.moonbeam)" > $CONFIG_DIR/bmc_perif.btp.addr
  • After running above commands, you have succeed to deploy required BMC contracts onto the Moonriver Network. In success, you will have a result similar as follows:
1
$ yarn
2
yarn install v1.22.10
3
[1/4] 🔍 Resolving packages...
4
success Already up-to-date.
5
✨ Done in 0.51s.
6
$ BMC_BTP_NET=0x501.pra truffle migrate --network moonbeamlocal
7
8
Compiling your contracts...
9
===========================
10
> Everything is up to date, there is nothing to compile.
11
12
Starting migrations...
13
======================
14
> Network name: 'moonbeamlocal'
15
> Network id: 1281
16
> Block gas limit: 15000000 (0xe4e1c0)
17
18
1_deploy_bmc.js
19
===============
20
21
Deploying 'BMCManagement'
22
-------------------------
23
> transaction hash: 0x1397f88c212655fb3bfc2cc1ca532c03266c9c7182276e4cb519ba4806827285
24
> Blocks: 0 Seconds: 0
25
> contract address: 0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3
26
> block number: 1
27
> block timestamp: 1626149168
28
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
29
> balance: 1207825.814645268174706176
30
> gas used: 4969361 (0x4bd391)
31
> gas price: 1 gwei
32
> value sent: 0 ETH
33
> total cost: 0.004969361 ETH
34
35
36
Deploying 'ProxyAdmin'
37
----------------------
38
> transaction hash: 0xdeb734cb515dfbf5108212753d9ed4afbe1cd951239c8968643590b08d487e33
39
> Blocks: 0 Seconds: 0
40
> contract address: 0x970951a12F975E6762482ACA81E57D5A2A4e73F4
41
> block number: 2
42
> block timestamp: 1626149170
43
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
44
> balance: 1207825.814162548174706176
45
> gas used: 482720 (0x75da0)
46
> gas price: 1 gwei
47
> value sent: 0 ETH
48
> total cost: 0.00048272 ETH
49
50
51
Deploying 'TransparentUpgradeableProxy'
52
---------------------------------------
53
> transaction hash: 0x50c6c4f965c0f4edfe1628189d95d7df39f0a12b199608d608e08989d7d3d3de
54
> Blocks: 0 Seconds: 0
55
> contract address: 0x3ed62137c5DB927cb137c26455969116BF0c23Cb
56
> block number: 3
57
> block timestamp: 1626149170
58
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
59
> balance: 1207825.813502809174706176
60
> gas used: 659739 (0xa111b)
61
> gas price: 1 gwei
62
> value sent: 0 ETH
63
> total cost: 0.000659739 ETH
64
65
66
Deploying 'BMCPeriphery'
67
------------------------
68
> transaction hash: 0xe3cd1177564bf19985b9f0fcdfded6fa15105c533d0d7b97d55edae5715159b7
69
> Blocks: 0 Seconds: 0
70
> contract address: 0x962c0940d72E7Db6c9a5F81f1cA87D8DB2B82A23
71
> block number: 4
72
> block timestamp: 1626149171
73
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
74
> balance: 1207825.808977907174706176
75
> gas used: 4524902 (0x450b66)
76
> gas price: 1 gwei
77
> value sent: 0 ETH
78
> total cost: 0.004524902 ETH
79
80
81
Deploying 'TransparentUpgradeableProxy'
82
---------------------------------------
83
> transaction hash: 0xb58d34400063b7f29af1ef38cf4967b995b6093771d7ff123f409455945620d7
84
> Blocks: 0 Seconds: 0
85
> contract address: 0x5CC307268a1393AB9A764A20DACE848AB8275c46
86
> block number: 5
87
> block timestamp: 1626149172
88
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
89
> balance: 1207825.808236509174706176
90
> gas used: 741398 (0xb5016)
91
> gas price: 1 gwei
92
> value sent: 0 ETH
93
> total cost: 0.000741398 ETH
94
95
> Saving artifacts
96
-------------------------------------
97
> Total cost: 0.01137812 ETH
98
99
100
Summary
101
=======
102
> Total deployments: 5
103
> Final cost: 0.01137812 ETH

2. Deploy BSH Contracts on Moonriver Network

  • Run following commands and make sure use a correct contract address of BMCPeriphery:
1
cd $PROJECT_DIR/btp/build/contracts/solidity/bsh
2
3
yarn
4
5
# Please run these commands one by one to avoid unexpected error
6
rm -rf .openzeppelin && truffle compile --all
7
8
# @params:
9
# - BMC_PERIPHERY_ADDRESS: an address on chain of BMCPeriphery contract
10
# This address is queried after deploying BMC contracts
11
# For example: BMC_PERIPHERY_ADDRESS = 0x5CC307268a1393AB9A764A20DACE848AB8275c46
12
# - BSH_COIN_NAME: a native coin name of Moonriver Network - DEV
13
# - BSH_COIN_FEE: a charging fee ratio of each request, e.g. 100/10000 = 1%
14
# - BSH_SERVICE: a service name of BSH contract, e.g. 'CoinTransfer'
15
# This service name is unique in one network. And it must be registered to BMC contract to activate
16
# BMC contract checks its service name whether it's already existed
17
BSH_COIN_URL=https://moonbeam.network/ \
18
BSH_COIN_NAME=DEV \
19
BSH_COIN_FEE=100 \
20
BSH_FIXED_FEE=500000 \
21
BMC_PERIPHERY_ADDRESS=$(cat $CONFIG_DIR/bmc.moonbeam) \
22
BSH_SERVICE=nativecoin \
23
truffle migrate --network moonbeamlocal
24
25
# Run script to extract BSHPeriphery and BSHCore addresses
26
# BSHPeriphery address -> $CONFIG_DIR/bsh.moonbeam
27
# BSHCore address -> $CONFIG_DIR/bsh_core.moonbeam
28
truffle exec $SCRIPT_DIR/mb_extract_bsh.js --network moonbeamlocal
  • In success, you will have a result similar as:
1
Compiling your contracts...
2
===========================
3
> Everything is up to date, there is nothing to compile.
4
5
6
7
Starting migrations...
8
======================
9
> Network name: 'moonbeamlocal'
10
> Network id: 1281
11
> Block gas limit: 15000000 (0xe4e1c0)
12
13
14
1_deploy_bsh.js
15
===============
16
17
Replacing 'BSHCore'
18
-------------------
19
> transaction hash: 0xf1da60278662660dff74a4c9701f8dbf87724924780651781b442063e9c35a22
20
> Blocks: 0 Seconds: 0
21
> contract address: 0x746DFE0F96789e62CECeeA3CA2a9b5556b3AaD6c
22
> block number: 17
23
> block timestamp: 1626151632
24
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
25
> balance: 1207825.601491923174706176
26
> gas used: 4535311 (0x45340f)
27
> gas price: 20 gwei
28
> value sent: 0 ETH
29
> total cost: 0.09070622 ETH
30
31
32
Deploying 'ProxyAdmin'
33
----------------------
34
> transaction hash: 0xe515f6aff766cec9a3af1ffd0cafd8c6af9763d5d1633d630a9d7df0ad7555d4
35
> Blocks: 0 Seconds: 0
36
> contract address: 0x294c664f6D63bd1521231a2EeFC26d805ce00a08
37
> block number: 18
38
> block timestamp: 1626151633
39
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
40
> balance: 1207825.591837523174706176
41
> gas used: 482720 (0x75da0)
42
> gas price: 20 gwei
43
> value sent: 0 ETH
44
> total cost: 0.0096544 ETH
45
46
47
Deploying 'TransparentUpgradeableProxy'
48
---------------------------------------
49
> transaction hash: 0x9d4e422af278e00133dfe05b04626035fe1eb5e24972c026fa78ff42ddbcf38b
50
> Blocks: 0 Seconds: 0
51
> contract address: 0x82745827D0B8972eC0583B3100eCb30b81Db0072
52
> block number: 19
53
> block timestamp: 1626151634
54
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
55
> balance: 1207825.574454443174706176
56
> gas used: 869154 (0xd4322)
57
> gas price: 20 gwei
58
> value sent: 0 ETH
59
> total cost: 0.01738308 ETH
60
61
62
Replacing 'BSHPeriphery'
63
------------------------
64
> transaction hash: 0x50b4942f25173db2a9d7a17a749f4266e18c254c52a84d4e82f98b2bef2b0c3d
65
> Blocks: 0 Seconds: 0
66
> contract address: 0xEC69d4f48f4f1740976968FAb9828d645Ad1d77f
67
> block number: 20
68
> block timestamp: 1626151636
69
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
70
> balance: 1207825.512091723174706176
71
> gas used: 3118136 (0x2f9438)
72
> gas price: 20 gwei
73
> value sent: 0 ETH
74
> total cost: 0.06236272 ETH
75
76
77
Deploying 'TransparentUpgradeableProxy'
78
---------------------------------------
79
> transaction hash: 0x98ee35989b5b21ca4fc222e7bc639b40cc25639f6029ff7eb2f41354985b9e47
80
> Blocks: 0 Seconds: 0
81
> contract address: 0x493275370aF3f63d9ccd10a6539435121cF4fbb9
82
> block number: 21
83
> block timestamp: 1626151636
84
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
85
> balance: 1207825.497248583174706176
86
> gas used: 742157 (0xb530d)
87
> gas price: 20 gwei
88
> value sent: 0 ETH
89
> total cost: 0.01484314 ETH
90
91
> Saving artifacts
92
-------------------------------------
93
> Total cost: 0.19494956 ETH
94
95
96
Summary
97
=======
98
> Total deployments: 5
99
> Final cost: 0.19494956 ETH

3. Deploy BMV Contracts on Moonriver Network

  • Run following commands and make sure use a correct contract address of BMCPeriphery
1
cd $PROJECT_DIR/btp/build/contracts/solidity/bmv
2
3
yarn
4
5
# Please run these commands one by one to avoid unexpected error
6
rm -rf .openzeppelin && truffle compile --all
7
8
# @params
9
# - BMC_PERIPHERY_ADDRESS: an address on chain of BMCPeriphery contract
10
# This address is queried after deploying BMC contracts
11
# For example: BMC_PERIPHERY_ADDRESS = 0x5CC307268a1393AB9A764A20DACE848AB8275c46
12
# - BMV_ICON_NET: Chain ID and name of a network that BMV is going to verify BTP Message
13
# - BMV_ICON_INIT_OFFSET: a block height when ICON-BMC was deployed
14
# - BMV_ICON_LASTBLOCK_HASH: a hash of the above block
15
# - BMV_ICON_ENCODED_VALIDATORS: a result of ICON JSON-RPC method `icx_getDataByHash` with the input is
16
# PreviousBlockHeader.NextValidatorHash. So, to get this param for block N, you must get BlockHeader of N - 1
17
# User can execute to ge the result :
18
#
19
# make iconvalidators
20
#
21
# GOLOOP_RPC_URI="https://btp.net.solidwallet.io/api/v3/icon_dex" $PROJECT_DIR/bin/iconvalidators build 3453901
22
#
23
24
BMC_PERIPHERY_ADDRESS=$(cat $CONFIG_DIR/bmc.moonbeam) \
25
BMV_ICON_NET=$(cat $CONFIG_DIR/net.btp.icon) \
26
BMV_ICON_ENCODED_VALIDATORS=0xd69500b6b5791be0b5ef67063b3c10b840fb81514db2fd \
27
BMV_ICON_INIT_OFFSET=$(cat $CONFIG_DIR/block.height.icon) \
28
BMV_ICON_INIT_ROOTSSIZE=8 \
29
BMV_ICON_INIT_CACHESIZE=8 \
30
BMV_ICON_LASTBLOCK_HASH=$(cat $CONFIG_DIR/block.hash.icon) \
31
truffle migrate --network moonbeamlocal
32
33
# Run script to extract BMV address
34
# BMV address -> $CONFIG_DIR/bmv.moonbeam
35
truffle exec $SCRIPT_DIR/mb_extract_bmv.js --network moonbeamlocal
  • In success, you will have a result similar as:
1
Starting migrations...
2
======================
3
> Network name: 'Moonriverlocal'
4
> Network id: 1281
5
> Block gas limit: 15000000 (0xe4e1c0)
6
7
8
1_deploy_bmv.js
9
===============
10
11
Deploying 'DataValidator'
12
-------------------------
13
> transaction hash: 0xa91d6e664d590cbbbb21d7ec8f79525129dcb4a6749493fb8ef78ce79ecb8b8f
14
> Blocks: 0 Seconds: 0
15
> contract address: 0x38762083399e60af42e6fD694e7d430a170c9Caf
16
> block number: 23
17
> block timestamp: 1626152078
18
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
19
> balance: 1207825.453746063174706176
20
> gas used: 2127765 (0x207795)
21
> gas price: 20 gwei
22
> value sent: 0 ETH
23
> total cost: 0.0425553 ETH
24
25
26
Deploying 'ProxyAdmin'
27
----------------------
28
> transaction hash: 0x9b02f32f374892e1babba0f922975d591c82ec0dbbf4a355577f7f0775463cdc
29
> Blocks: 0 Seconds: 0
30
> contract address: 0x1377Ce7BadadB01a2D06Dc41f31e8B57d9882888
31
> block number: 24
32
> block timestamp: 1626152079
33
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
34
> balance: 1207825.444091663174706176
35
> gas used: 482720 (0x75da0)
36
> gas price: 20 gwei
37
> value sent: 0 ETH
38
> total cost: 0.0096544 ETH
39
40
41
Deploying 'TransparentUpgradeableProxy'
42
---------------------------------------
43
> transaction hash: 0x492efc4dc89f4fabb2db532923a135d5a719abddb08204e545bc52feda963443
44
> Blocks: 0 Seconds: 0
45
> contract address: 0xab7785d56697E65c2683c8121Aac93D3A028Ba95
46
> block number: 25
47
> block timestamp: 1626152079
48
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
49
> balance: 1207825.431740503174706176
50
> gas used: 617558 (0x96c56)
51
> gas price: 20 gwei
52
> value sent: 0 ETH
53
> total cost: 0.01235116 ETH
54
55
56
Deploying 'BMV'
57
---------------
58
> transaction hash: 0xde6dd1633bc9e91c9f859679bf7feb34a973ba804cff6f720a3574ae3fa1de97
59
> Blocks: 0 Seconds: 0
60
> contract address: 0xb5F73112516ebeB89c7EF67a507513b441Ac28fA
61
> block number: 26
62
> block timestamp: 1626152079
63
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
64
> balance: 1207825.342546463174706176
65
> gas used: 4459702 (0x440cb6)
66
> gas price: 20 gwei
67
> value sent: 0 ETH
68
> total cost: 0.08919404 ETH
69
70
71
Deploying 'TransparentUpgradeableProxy'
72
---------------------------------------
73
> transaction hash: 0x2dcb6a4570889e133e6c5ca919086a42e62e1ff517640c061bae208ee00372d5
74
> Blocks: 0 Seconds: 0
75
> contract address: 0x7acc1aC65892CF3547b1b0590066FB93199b430D
76
> block number: 27
77
> block timestamp: 1626152080
78
> account: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
79
> balance: 1207825.323977043174706176
80
> gas used: 928471 (0xe2ad7)
81
> gas price: 20 gwei
82
> value sent: 0 ETH
83
> total cost: 0.01856942 ETH
84
85
> Saving artifacts
86
-------------------------------------
87
> Total cost: 0.17232432 ETH
88
89
90
Summary
91
=======
92
> Total deployments: 5
93
> Final cost: 0.17232432 ETH
Attention: Please do not skip these steps. This information will later be used to register Verifier