クロスチェーンの価値移転
This section will explain how to enable ERC-20 value transfer between Baobab network and your ServiceChain with the provided test code. You will add KLAY to the operator account and deploy bridge and ERC-20 contracts. その後、SCNに契約アドレスを登録します。 そして、ERC-20の値を転送するテストを行う。
前提条件
- We assume that you installed the ServiceChain, and connected the ServiceChain to the Baobab EN by the instructions in Connecting to Baobab.
- リポジトリservicechain-value-transfer-examplesをクローンします。
Node.js
(v14) とnpm
をインストールする (インストール方法)- この例では、axiosとcaver-jsという2つのパッケージを利用しているが、どちらもv14をサポートしている。
ERC-20トークン転送(ワンステップ)
Step 1: Add KLAY to the operator accounts.
SCN に接続し、subbridge.parentOperator
と subbridge.childOperator
を実行してアカウントアドレスを確認する。
$ kscn attach --datadir ~/data> subbridge.childOperator"0x10221f7f9355017cd0c11444e7eecb99621bacce"> subbridge.parentOperator"0x3ce216beeafc62d20547376396e89528e1d778ca"
subbridge.parentOperator
と subbridge.childOperator
はトランザクションを送信するのに十分なKAIAを持っていなければならない。 subbridge.parentOperator
はKairosネットワークのアカウントで、subbridge.childOperator
はServiceChainネットワークのアカウントであることに注意してください。
https://toolkit.kaia.io/account/accountKeyLegacy](https://toolkit.kaia.io/account/accountKeyLegacy)でテストアカウントを作成し、[the faucet](https://faucet.kaia.io/)からテストKAIAを入手する。 その後、KAIAをparentOperator
に送る。 childOperator
has to get KLAY from the test account generated by homi
(Refer to EN Setup and SCN Connection Guide).
$ kscn account import ~/homi-output/keys_test/testkey1Your new account is locked with a password. Please give a password. Do not forget this password.Passphrase:Repeat passphrase:Address: {80119c31cdae67c42c8296929bb4f89b2a52cec4}
$ kscn attach --datadir ~/data> personal.unlockAccount("80119c31cdae67c42c8296929bb4f89b2a52cec4")Unlock account 80119c31cdae67c42c8296929bb4f89b2a52cec4Passphrase:True> kaia.sendTransaction({from:"80119c31cdae67c42c8296929bb4f89b2a52cec4", to:subbridge.childOperator, value: web3.toPeb(1000, "KAIA")})"0x84caab84ebf0c4bb4ecf0a7849f1de3e479f1863a95f70c51047a7ca7bc64b33"
オペレーターの口座に十分な残高があるか確認する。 サブブリッジがインストールされている SCN ノードのコンソールから、以下のように問い合わせることができます:
> kaia.getBalance(subbridge.childOperator)1e+21> subbridge.childOperatorBalance1e+21> subbridge.parentOperatorBalance1e+18