前提
- macOSとLinuxのみ
筆者は最新のmacOSで試しました。
Libraをクローンする
git clone https://github.com/libra/libra.git && cd libra
依存をインストール
./scripts/dev_setup.sh
30-60分位かかった?
CLIを実行
./scripts/cli/start_cli_testnet.sh
Libra CLIの使い方
Connected to validator at: ac.testnet.libra.org:80
usage: <command> <args>
Use the following commands:
account | a
Account operations
query | q
Query operations
transfer | transferb | t | tb
<sender_account_address>|<sender_account_ref_id> <receiver_account_address>|<receiver_account_ref_id> <number_of_coins> [gas_unit_price (default=0)] [max_gas_amount (default 10000)] Suffix 'b' is for blocking.
Transfer coins from account to another.
help | h
Prints this help
quit | q!
Exit this client
Please, input commands:
初めてのトランザクションを実行
ステップ1: CLIクライアントが動くかチェック
accountと打って以下がでるか確認
libra% account
usage: account <arg>
Use the following args for this command:
create | c
Create an account. Returns reference ID to use in other operations
list | la
Print all accounts that were created or loaded
recover | r <file path>
Recover Libra wallet from the file path
write | w <file name>
Save Libra wallet mnemonic recovery seed to disk
mint | mintb | m | mb <receiver account> <number of coins>
Mint coins to the account. Suffix 'b' is for blocking
ステップ2: アリスのアカウントを作成
libra% account create
サンプルのアウトプットは以下のようなもの
>> Creating/retrieving next account from wallet
Created/retrieved account #0 address 3ed8e5fafae4147b2a105a0be2f81972883441cfaaadf93fc0868e7a0253c4a8
ステップ3: ボブのアカウントを作成
libra% account create
>> Creating/retrieving next account from wallet
Created/retrieved account #1 address 8337aac709a41fe6be03cad8878a0d4209740b1608f8a81566c9a7d4b95a2ec7
ステップ4: アカウントをリストアップ
libra% account list
サンプルのアウトプットは以下の通り
User account index: 0, address: 3ed8e5fafae4147b2a105a0be2f81972883441cfaaadf93fc0868e7a0253c4a8, sequence number: 0
User account index: 1, address: 8337aac709a41fe6be03cad8878a0d4209740b1608f8a81566c9a7d4b95a2ec7, sequence number: 0
Libraコインをアリスとボブのアカウントに追加する
ステップ1: 110 Libraをアリスのアカウントに追加
libra% account mint 0 110
>> Minting coins
Mint request submitted
ステップ2: 52 Libraをボブのアカウントに追加
libra% account mint 1 52
>> Minting coins
Mint request submitted
ステップ3: 残高をチェックする
libra% query balance 0
トランザクションを送信する
トランザクションを送る前にシーケンス番号をクエリーする
libra% query sequence 0
>> Getting current sequence number
Sequence number is: 0
libra% query sequence 1
>> Getting current sequence number
Sequence number is: 0
お金を送る
アリスからボブに10リブラを送金
libra% transfer 0 1 10
アウトプット
>> Transferring
Transaction submitted to validator
To query for transaction status, run: query txn_acc_seq 0 0 <fetch_events=true|false>
トランザクションのステータスを見る
query txn_acc_seq 0 0 true
アウトプット
libra% query txn_acc_seq 0 0 true
>> Getting committed transaction by account and sequence number
Committed transaction: SignedTransaction {
raw_txn: RawTransaction {
sender: 425cdae8f25189aaa993180636a7e9e906601bfb8b9d1d8f398066bf6cf929e5,
sequence_number: 0,
payload: {,
transaction: peer_to_peer_transaction,
args: [
{ADDRESS: 1902f3e2e3e752124048eb260b2eeb83df8c17217a962daed43d66fc6d037f02},
{U64: 10000000},
]
},
max_gas_amount: 10000,
gas_unit_price: 0,
expiration_time: 1560852172s,
},
public_key: ab064758137ced5fa1ad3c26f7b4c32b42de4d13dd02913edfc7f4958d2319f4,
signature: Signature( R: CompressedEdwardsY: [186, 227, 192, 200, 70, 235, 253, 168, 203, 138, 73, 193, 168, 253, 18, 20, 52, 5, 162, 223, 143, 219, 194, 41, 203, 21, 45, 28, 138, 105, 0, 10], s: Scalar{
bytes: [209, 79, 193, 153, 81, 186, 148, 238, 204, 48, 164, 26, 251, 127, 158, 51, 169, 234, 241, 47, 193, 29, 84, 64, 124, 205, 94, 160, 9, 140, 2, 12],
} ),
}
Events:
ContractEvent { access_path: AccessPath { address: 425cdae8f25189aaa993180636a7e9e906601bfb8b9d1d8f398066bf6cf929e5, type: Resource, hash: "217da6c6b3e19f1825cfb2676daecce3bf3de03cf26647c78df00b371b25cc97", suffix: "/sent_events_count/" } , index: 0, event_data: AccountEvent { account: 1902f3e2e3e752124048eb260b2eeb83df8c17217a962daed43d66fc6d037f02, amount: 10000000 } }
ContractEvent { access_path: AccessPath { address: 1902f3e2e3e752124048eb260b2eeb83df8c17217a962daed43d66fc6d037f02, type: Resource, hash: "217da6c6b3e19f1825cfb2676daecce3bf3de03cf26647c78df00b371b25cc97", suffix: "/received_events_count/" } , index: 0, event_data: AccountEvent { account: 425cdae8f25189aaa993180636a7e9e906601bfb8b9d1d8f398066bf6cf929e5, amount: 10000000 } }
libra% libra% query txn_acc_seq 0 0 true
The Blocking Transferコマンド
libra% transferb 0 1 10
libra% transferb 0 1 10
>> Transferring
[waiting *
Transaction completed, found sequence number 2
Finished transaction!
To query for transaction status, run: query txn_acc_seq 0 1 <fetch_events=true|false>
参考に: トランザクションのライフサイクル
Life of a Transaction · Libra
https://developers.libra.org/docs/life-of-a-transaction
送金後のシーケンス番号のクエリー
libra% query sequence 0
>> Getting current sequence number
Sequence number is: 1
libra% query sequence 1
>> Getting current sequence number
Sequence number is: 0
送金後に2つのアカウントの残高をチェックする
libra% query balance 0
Balance is: 100
libra% query balance 1
Balance is: 62
参考
検索用語
リブラ, カリブラ, フェイスブック
Libra, Calibra, Facebook