什么是Libra(天秤座)

什么是Libra,Libra是有Facebook主導發(fā)行的一種數(shù)字貨幣.數(shù)字貨幣在最近幾年的時間中,因為比特幣的暴漲和暴跌走入人們的視野中,飽受各種爭議。有人賺錢、有人虧錢,但是我們更應該關心的是區(qū)塊鏈技術能給人們的生活帶來什么改變。

Libra’s mission is to enable a simple global currency and financial infrastructure that empowers billions of people.

上面的是Libra 對自己的描述,或者理解為定位,如果全球都使用同一種貨幣進行交易的話,里面會有多大的想象力以及前景,雖然現(xiàn)在Libra面臨著各種各樣的法律問題和風險,但是如果能慢慢解決的話,我還是非常看好它的前景的。

Libra 使用Facebook開發(fā)的Move語言,接下來我們簡單的來跑個demo,了解一下Libra,現(xiàn)在它只能在macOS和Linux 上運行

Move 語言的三大用處

  • 發(fā)行數(shù)字貨幣、Token、數(shù)字資產(chǎn)
  • 靈活處理區(qū)塊鏈交易
  • 驗證器(Validator)管理

Clone Libra

下載代碼到本地

git clone https://github.com/libra/libra.git && cd libra
#結(jié)果
Cloning into 'libra'...
remote: Enumerating objects: 3799, done.
remote: Total 3799 (delta 0), reused 0 (delta 0), pack-reused 3799
Receiving objects: 100% (3799/3799), 3.47 MiB | 1.09 MiB/s, done.
Resolving deltas: 100% (1874/1874), done.

安裝依賴

./scripts/dev_setup.sh
#結(jié)果
Installing Rust......
info: downloading installer
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: latest update on 2019-07-04, rust version 1.36.0 (a53f9df32 2019-07-03)
info: downloading component 'rustc'
 82.2 MiB /  82.2 MiB (100 %)   8.8 MiB/s in 10s ETA:  0s
info: downloading component 'rust-std'
 55.8 MiB /  55.8 MiB (100 %)   8.6 MiB/s in  6s ETA:  0s
info: downloading component 'cargo'
info: downloading component 'rust-docs'
 11.1 MiB /  11.1 MiB (100 %)   8.6 MiB/s in  1s ETA:  0s
info: installing component 'rustc'
 82.2 MiB /  82.2 MiB (100 %)  12.6 MiB/s in  6s ETA:  0s
info: installing component 'rust-std'
 55.8 MiB /  55.8 MiB (100 %)  16.2 MiB/s in  3s ETA:  0s
info: installing component 'cargo'
info: installing component 'rust-docs'
 11.1 MiB /  11.1 MiB (100 %)   2.2 MiB/s in  5s ETA:  0s
info: default toolchain set to 'stable'

  stable installed - rustc 1.36.0 (a53f9df32 2019-07-03)


Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH 
environment variable. Next time you log in this will be done automatically.

To configure your current shell run source $HOME/.cargo/env
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: checking for self-updates

  stable-x86_64-apple-darwin unchanged - rustc 1.36.0 (a53f9df32 2019-07-03)

info: syncing channel updates for 'nightly-2019-07-08-x86_64-apple-darwin'
info: latest update on 2019-07-08, rust version 1.38.0-nightly (6e310f2ab 2019-07-07)
info: downloading component 'rustc'
 58.9 MiB /  58.9 MiB (100 %)   1.5 MiB/s in 57s ETA:  0s     
info: downloading component 'rust-std'
168.6 MiB / 168.6 MiB (100 %)   2.2 MiB/s in  1m  5s ETA:  0s
info: downloading component 'cargo'
  3.6 MiB /   3.6 MiB (100 %)   2.8 MiB/s in  1s ETA:  0s
info: downloading component 'rust-docs'
 11.6 MiB /  11.6 MiB (100 %)   2.3 MiB/s in  5s ETA:  0s
info: installing component 'rustc'
 58.9 MiB /  58.9 MiB (100 %)  12.7 MiB/s in  4s ETA:  0s
info: installing component 'rust-std'
168.6 MiB / 168.6 MiB (100 %)  26.8 MiB/s in  6s ETA:  0s
info: installing component 'cargo'
info: installing component 'rust-docs'
 11.6 MiB /  11.6 MiB (100 %)   2.2 MiB/s in  4s ETA:  0s
info: downloading component 'rustfmt'
  2.0 MiB /   2.0 MiB (100 %) 1005.6 KiB/s in  3s ETA:  0s
info: installing component 'rustfmt'
info: downloading component 'clippy'
  1.3 MiB /   1.3 MiB (100 %) 383.7 KiB/s in  5s ETA:  0s
info: installing component 'clippy'
Installing CMake......
Finished installing all dependencies.

You should now be able to build the project by running:
    source /Users/xxx/.cargo/env
    cargo build
#如果出現(xiàn)下面的錯誤,需要安裝 protobuf
error: failed to run custom build command for `network v0.1.0
brew install protobuf

出現(xiàn)錯誤可以查看 roubleshooting 解決
上面的過程取決與你的網(wǎng)速,有可能會很慢,通過上面的一系列操作,基本的環(huán)境配置好了,接下來就可以在測試網(wǎng)絡上開始交易了(現(xiàn)在還是測試網(wǎng)絡,現(xiàn)在還沒有辦法支持10億人的交易需求,后面會慢慢轉(zhuǎn)向私有的聯(lián)盟鏈)

命令行運行

./scripts/cli/start_cli_testnet.sh
#結(jié)果
xxxxxxxx
 Finished dev [unoptimized + debuginfo] target(s) in 3m 31s
     Running `target/debug/client --host ac.testnet.libra.org --port 8000 -s ./scripts/cli/trusted_peers.config.toml`
Connected to validator at: ac.testnet.libra.org:8000
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_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.
submit | submitb | s | sb
    <signer_account_address>|<signer_account_ref_id> <path_to_raw_transaction> Suffix 'b' is for blocking. 
    Load a RawTransaction from file and submit to the network
help | h
    Prints this help
quit | q!
    Exit this client
Please, input commands:

使用上面的命令可以構(gòu)建和運行客戶端,并將客戶端連接到test網(wǎng)絡,并列出了常用的命令

運行你第一筆交易

創(chuàng)建兩個賬戶

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_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
libra% account create
>> Creating/retrieving next account from wallet
Created/retrieved account #0 address 4be45f015f45a2968d68a2ac56ebd1bfa05a43f87fefb2f5327bea292c354ece
libra% account create
>> Creating/retrieving next account from wallet
Created/retrieved account #1 address b83ef4576f74faa787abc8233a501540dcbb9ede236ee967535051ac8c8f6fab

#0是賬戶索引,十六進制字符串是賬號地址

轉(zhuǎn)賬

libra% account mint 0 110
>> Minting coins
Mint request submitted
  • 0 是賬戶索引
  • 110 是往賬戶添加的金額

第二個賬戶也進行相同的操作,需要注意的是,只是發(fā)出了命令進行增加,還需要確認賬戶中的金額

libra% query balance 0
Balance is: 110.000000
libra% query balance 1
Balance is: 52.000000

可以看到對應的金額已經(jīng)添加到賬戶

提交交易

libra% query sequence 0
>> Getting current sequence number
Sequence number is: 0
libra% query sequence 1
>> Getting current sequence number
Sequence number is: 0

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>
libra% query sequence 0
>> Getting current sequence number
Sequence number is: 1
libra% query balance 0
Balance is: 100.000000
libra% query balance 1
Balance is: 62.000000
  • 0 是第一個賬戶
  • 1是第二個賬戶
  • 10是要從第一個轉(zhuǎn)賬到第二個賬戶的金額

通過查詢賬戶,可以看到對應的金額已經(jīng)變更

整個過程非常的簡單,試想一下,如果全球都支持使用Libra進行支付,支付將會變的更加便捷,當然支付寶也可以完成類似的操作,但是背后所涉及的交易結(jié)算是非常復雜的,還需要支付額外的手續(xù)費。那Libra是如何維持生存呢,看了一下,靠發(fā)幣是抵押的法幣產(chǎn)生的利息支付運營成本,不過這玩意要是真的流行,那就是全球羊毛收割機了,未來誰知道呢。

?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容