上次编译了facebook的区块链,好几天没用了,今天就接下来尝试运行基本操作
先在编译的基础下运行:
编译运行facebook区块链libra(1)--by Skyh
1. 运行测试网
./scripts/cli/start_cli_testnet.sh
然后出现: Running target/debug/client --host ac.testnet.libra.org --port 80 -s ./scripts/cli/trusted_peers.config.toml
Not able to connect to validator at ac.testnet.libra.org:80, error RpcFailure(RpcStatus { status: DeadlineExceeded, details: Some("Deadline Exceeded") })
怎么会有时间错误,查看issue
https://github.com/libra/libra/issues/38 image.png
需要修改libra/client/src/grpc_client.rs 增大
image.png
重新调用即可打开
./scripts/cli/start_cli_testnet.sh
image.png
显示可以运行的基本命令
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_in_micro_libras (default=0)] [max_gas_amount_in_micro_libras (default 10000)] Suffix 'b' is for blocking.
Transfer coins (in libra) from account to another.
help | h
Prints this help
quit | q!
Exit this client
2. 运行命令
查看account子命令(文中命令缩写)
libra% a
usage: a <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_path>
Save Libra wallet mnemonic recovery seed to disk
mint | mintb | m | mb <receiver_account_ref_id>|<receiver_account_address> <number_of_coins>
Mint coins to the account. Suffix 'b' is for blocking
自己本地创建2个账户
libra% a c
>> Creating/retrieving next account from wallet
Created/retrieved account #0 address 4c52e97c3219c731be98f3f228a05324afc46200462c33ceea4f0964b7baf68c
libra% a c
>> Creating/retrieving next account from wallet
Created/retrieved account #1 address 9e6ae041beb3048007f285f70f56e16ec252a4545573ca36e60e9ee52c81bf56
列出所有账户
libra% a la
User account index: 0, address: 4c52e97c3219c731be98f3f228a05324afc46200462c33ceea4f0964b7baf68c, sequence number: 0, status: Local
User account index: 1, address: 9e6ae041beb3048007f285f70f56e16ec252a4545573ca36e60e9ee52c81bf56, sequence number: 0, status: Local
image.png
吐槽: libra的account创建只能从索引0开始递增,账号只有索引码不够形象,如果账号多起来比较难分辨,只能通过数据库一一对应, 不像EOS那样可以直接字符账号
3. 创建libra并转帐
创建110个libra并添加到0账户, 和52个到2账户
a m 0 110
a m 1 52
返回只有 Mint request submitted并没有详细信息
image.png
下面查看余额,先看看query有什么命令:
查看0和1的余额(直接代码不图片了)
libra% q b 0
Balance is: 110
libra% q b 1
Balance is: 52
进行转账,先看看转账有什么操作
libra% t 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
可看到记录上链的信息(失败信息还没模拟)
image.png
** 查看某账号交易数**,这时可以看到0 和1 的交易数, 还有余额
libra% q s 0
>> Getting current sequence number
Sequence number is: 1
libra% q s 1
>> Getting current sequence number
Sequence number is: 0
libra% q b 0
Balance is: 100
libra% q b 1
Balance is: 62
libra%
1 已经收到了 0 号的10个libra
注意: 发现对0账号 交易数有1, 而1账号收到账并没有显示交易数,这跟其他链也不一样, 可能通过其他方法查
如果需要确认状态转账成功, 可以用阻塞转账命令,本地目测也是1s左右完成吧
libra% tb 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>
4 附加:一些实用命令:
查询用户状态
libra% query account_state 0
>> Getting latest account state
Latest account state is:
Account: 4c52e97c3219c731be98f3f228a05324afc46200462c33ceea4f0964b7baf68c
State: Some(
AccountStateBlob {
Raw: 0x010000002100000001217da6c6b3e19f1825cfb2676daecce3bf3de03cf26647c78df00b371b25cc9744000000200000004c52e97c3219c731be98f3f228a05324afc46200462c33ceea4f0964b7baf68c00e1f50500000000000000000000000001000000000000000100000000000000
Decoded: Ok(
AccountResource {
balance: 100000000,
sequence_number: 1,
authentication_key: 0x4c52e97c3219c731be98f3f228a05324afc46200462c33ceea4f0964b7baf68c,
sent_events_count: 1,
received_events_count: 0,
},
)
},
)
Blockchain Version: 150463
另外,找到一个可以1账号查收到账的命令, 就是
#查0转账index 0 开始
query event 0 sent 0 true 10
#查1收账index 0 开始
query event 1 received 0 true 10
下面是收账返回信息,也能看到些内部结构,好像还有gas:
libra% query event 1 received 0 true 10
>> Getting events by account and event type.
EventWithProof {
transaction_version: 149925,
event_index: 1,
event: ContractEvent { access_path: AccessPath { address: 9e6ae041beb3048007f285f70f56e16ec252a4545573ca36e60e9ee52c81bf56, type: Resource, hash: "217da6c6b3e19f1825cfb2676daecce3bf3de03cf26647c78df00b371b25cc97", suffix: "/received_events_count/" } , index: 0, event_data: AccountEvent { account: 4c52e97c3219c731be98f3f228a05324afc46200462c33ceea4f0964b7baf68c, amount: 10000000 } },
proof: EventProof { ledger_info_to_transaction_info_proof: AccumulatorProof { siblings: [HashValue(3b342420dc970d4e9350453a77f6a97bf8c9d60c8284c21f025ee3a80ac95c52), HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000), HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000), HashValue(389b0d4d7d8eb44d705729199509ee7ac08aafd5d932dd54ec1046cbd6a7a87a), HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000), HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000), HashValue(af4806596ecbab864e31f6532c83d2d2303f24eb5582b4159c391ac8da66ffef), HashValue(53671a19a48ffbe6df7105dc1d94657e254b9461863ebc7bfe00158bec419ec8), HashValue(645eda211c45342c69010cfef4169b4981fb0528ceeef5f7e03dc511abc154a2), HashValue(5be76e228b159f938adfcc90d3211ebaa335c23ffca7dea1bdad3d54140f935d), HashValue(e9a6711073d8e619222529e0efc59772fc095aff05f6ec1a4a191694f1a8805c), HashValue(0b01b71012350bb57fbfa8eb23c7d995a642d07281863aabd9ecc87eaca9d772), HashValue(c1e0c1f62429cddc0262dc8b6576bb27be9f084d8f8cdf12378f13018b58cd44), HashValue(232ebe41afb342a23a34ca10baeb0f1557b8b40dcb39333d7a7e5216f35810ee), HashValue(276dec7d6a0689432ec72c007d96e18d1d2b19ef5cec57ecc8aa1413f5422676), HashValue(768ed78b9431e0bfbfc2356c9d17fd488de7f874189691abc4005a47cd1f0884), HashValue(102cb89d7f44b854a0aef1e7731096e1642987113766db28e548aa5076a66674), HashValue(5b484e9aa4b8fa5073a3e43f0ee3c714b4de1738e32bfd092607931d04f663e4)] }, transaction_info: TransactionInfo { signed_transaction_hash: HashValue(00c6fed4783aa8ef272fea60531f33c07f7bbfad0666a038cdca415b4493b5d3), state_root_hash: HashValue(080f88799b737d81bf53c7cd071c5ee563ad64847293138272de367b70b97658), event_root_hash: HashValue(54b54918efc77a0813d962377c93633759bd67bc4003136c8bb1a8d45b37d529), gas_used: 0 }, transaction_info_to_event_proof: AccumulatorProof { siblings: [HashValue(dc2d9ea0bb02c9dc84356866512d0fbb40a3e97cd5312d8ec06fcde33493bce8)] } }
}
EventWithProof {
transaction_version: 150524,
event_index: 1,
event: ContractEvent { access_path: AccessPath { address: 9e6ae041beb3048007f285f70f56e16ec252a4545573ca36e60e9ee52c81bf56, type: Resource, hash: "217da6c6b3e19f1825cfb2676daecce3bf3de03cf26647c78df00b371b25cc97", suffix: "/received_events_count/" } , index: 1, event_data: AccountEvent { account: 4c52e97c3219c731be98f3f228a05324afc46200462c33ceea4f0964b7baf68c, amount: 10000000 } },
proof: EventProof { ledger_info_to_transaction_info_proof: AccumulatorProof { siblings: [HashValue(3b342420dc970d4e9350453a77f6a97bf8c9d60c8284c21f025ee3a80ac95c52), HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000), HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000), HashValue(389b0d4d7d8eb44d705729199509ee7ac08aafd5d932dd54ec1046cbd6a7a87a), HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000), HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000), HashValue(af4806596ecbab864e31f6532c83d2d2303f24eb5582b4159c391ac8da66ffef), HashValue(53671a19a48ffbe6df7105dc1d94657e254b9461863ebc7bfe00158bec419ec8), HashValue(6294cd1ab1d4f8eb1fbdc96956d36eef07fb8022bd299f7f18c8175fc7bd501b), HashValue(be0f7ef139cb8441d18419663bda4b2643e0773c97612305d560f40ceeef18f9), HashValue(ed8dfb38a78b751da46d758d29ed5677c33f9e29a30558017121d7d2a3dad38f), HashValue(2fc217589d9ee44a1bdcf5112f0c82294c7f5f4f66ffcded6f5a62f1740a7001), HashValue(00e30fd02d94863bab545c27b2e133db26406e72603e380d1ad3de8ca39fe231), HashValue(1f6ab1430e68100bdb288126ec8e89901ce4e3c194ac2ceaa9a0f17ea5122ebb), HashValue(0b86a068b5f678cfe5ecd5a8f9e3aa19e53500f62c983344b07828b33195a370), HashValue(070ded7498800c95a468431cd2f6fd61f02b90515699efdefc77bc478b4339ed), HashValue(1083fdcad633bd68847339e2bcb0706a60cabe3b0757f369e98115ed5f62eccb), HashValue(4a34bc3bea54e9cb46a5ba651bce159c080b206bbf70ef3b4b68643153b8a52c)] }, transaction_info: TransactionInfo { signed_transaction_hash: HashValue(ea57c467ee653d7aa37d77985aeae2aec5814235e8a01e49c9eb3c363262c326), state_root_hash: HashValue(c2447717240ceba88719b62c6a22bddc4927bd7409956bb46c8bfe731cb57f32), event_root_hash: HashValue(190ecafcc8b782cc883a4346076a2b0158c85f1cc523203cf80c8d13525b1ac5), gas_used: 0 }, transaction_info_to_event_proof: AccumulatorProof { siblings: [HashValue(30fca70df8fedd17190044c3b0aca5e3387fae8be55594713c315bed01702c81)] } }
}
Last event state: Some(
AccountStateWithProof {
version: 150628,
blob: Some(
AccountStateBlob {
Raw: 0x010000002100000001217da6c6b3e19f1825cfb2676daecce3bf3de03cf26647c78df00b371b25cc9744000000200000009e6ae041beb3048007f285f70f56e16ec252a4545573ca36e60e9ee52c81bf5600a24a0400000000020000000000000000000000000000000000000000000000
Decoded: Ok(
AccountResource {
balance: 72000000,
sequence_number: 0,
authentication_key: 0x9e6ae041beb3048007f285f70f56e16ec252a4545573ca36e60e9ee52c81bf56,
sent_events_count: 0,
received_events_count: 2,
},
)
},
),
proof: AccountStateProof {
ledger_info_to_transaction_info_proof: AccumulatorProof {
siblings: [
HashValue(3b342420dc970d4e9350453a77f6a97bf8c9d60c8284c21f025ee3a80ac95c52),
HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000),
HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000),
HashValue(389b0d4d7d8eb44d705729199509ee7ac08aafd5d932dd54ec1046cbd6a7a87a),
HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000),
HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000),
HashValue(af4806596ecbab864e31f6532c83d2d2303f24eb5582b4159c391ac8da66ffef),
HashValue(9896b5fcbe23ac775dfa8f64238c90b9e42edfe5d3a3374a1f2abe1c845d95e5),
HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000),
HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000),
HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000),
HashValue(32efcd702dfc2f5969882a13c0ccfeded345cb5d35a6de677425d2d3f4465a9e),
HashValue(c9362c10d99f6d3ea311cf73c61384cbe42a725abaf5a1d00d6404ccc8c17e98),
HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000),
HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000),
HashValue(829690ea41f6e50472deeb7a3c4dd54c3bfd3b577baac7a1feccfd60c147f820),
HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000),
HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000),
],
},
transaction_info: TransactionInfo {
signed_transaction_hash: HashValue(49192c8afcde3b37118e2147b65fec558a7c924a7c1f140140a3abaa5b4d535d),
state_root_hash: HashValue(5abcbcc86b6a2cc8456c9d941e064528bb74b751bbb0f3ccca4f08a1be58dce8),
event_root_hash: HashValue(414343554d554c41544f525f504c414345484f4c4445525f4841534800000000),
gas_used: 0,
},
transaction_info_to_account_proof: SparseMerkleProof {
leaf: Some(
(
HashValue(c13f4d69f7dd1a6261f08d7cd03a61d6a60e74ddcb62b3a291fa43d0f56c4e57),
HashValue(2d0c8c8820f292fa2b747c204007bfa3367eb368684783f157536bfab4992220),
),
),
siblings: [
HashValue(09c54224f5eaafc068897ef2aad7608102f7d0bd01103bed93a780cb422b406d),
HashValue(4f0be28f5e325e1f4aa70c66ce62c78a83bb8d1a1f8426269141d5af3920e8c6),
HashValue(9639297a75f94d705c964c3f6d38a91763dd64c1387543ab72fecbaa621d4857),
HashValue(55719ef71a5da8982b35533cbc424d99862ae8cb93127935ae0dc867051a48f3),
HashValue(511adf8c26b4c0ad8e73db9c67231e15f3ffcd4cf595cecc825f33154f7baa36),
HashValue(9fe9d01186cdd15295f956993245c751653bc4009d5cba5189292e0ddf41347e),
HashValue(ec55e5b87d25de5e804bbf2a9db03388cef9b0f601882d2c08c6e6b107cfbbf8),
HashValue(09decea516251e976e97faf109734dd77fc4ccde18f4f8e827dc886edd2a3f91),
HashValue(7b94d60e8b1b20d8ce01b5077c608e3120744bca43169481821bc2fd3a41cda9),
HashValue(e44b146da15da79cf180d7b0cb2831716f80837a32c1818283d53793b3c31a8b),
HashValue(86fd33d0d5b6722f91ae0ab12a451f567a9fc5c7bb5ac19e380e4363bfdcbcfd),
HashValue(58ca9d203ca9d6628b26a2f960b7ef8d28c65dbb0aa2c22bbfeff3a7fd18c56a),
HashValue(bef67d936df31c2b5adeb1414d3f2758534320aa7d20ecaedda65dd03291d252),
],
},
},
},
)
还是贴上第一手资料,直接开发者网站进去(套路不开始贴了,求赞)https://developers.libra.org/docs/my-first-transaction
今天先探索到这里,熟悉了基本转账查询的操作,前期还有些问题和解决方法,主要账号没有明显的字符名,从0开始,查询也略不方便, 下次再探索下Move智能合约
网友评论