1. 程式人生 > >eos:智慧合約

eos:智慧合約

1. 建立錢包

$ cleos wallet create --to-console
Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5JuBXoXJ8JHiCTXf...."

2. 錢包解鎖、上鎖

$ cleos wallet unlock
password:
cleos wallet lock
Locked: default

 3. 匯入私鑰到錢包

$ cleos wallet import --private-key 5KQw......
imported private key for: EOS6MRy....

4. 建立賬號

$ cleos create key --to-console
Private key: 5Jmsawgs...
Public key: EOS7ijWC...
$ cleos wallet import --private-key 5Jmsawgsp1t....
imported private key for: EOS7i...
$ cleos create account eosio user EOS7ijWC.... EOS7i.....
executed transaction: 8aedb926cc1ca31642ada8daf4350833c95cbe98b869230f44da76d70f6d6242  364 bytes  1000 cycles
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"user","owner":{"threshold":1,"keys":[{"key":"EOS7ijWCBmoXBi3CgtK7DJxentZZ...

$ cleos create account eosio tester EOS7ijWCB... EOS7ijW....
executed transaction: 414cf0dc7740d22474992779b2416b0eabdbc91522c16521307dd682051af083 366 bytes  1000 cycles
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"tester","owner":{"threshold":1,"keys":[{"key":"EOS7ijWCBmoXBi3CgtK7DJxentZZ...

5. 編譯合約(EOS筆記四 合約工具eosio.cdt使用(轉載):https://www.jianshu.com/p/f2f58eafa595

    a. 安裝(https://github.com/EOSIO/eosio.cdt)

    $ wget https://github.com/eosio/eosio.cdt/releases/download/v1.4.1/eosio.cdt-1.4.1.x86_64.deb
    $ sudo apt install ./eosio.cdt-1.4.1.x86_64.deb

     b. 編譯

// 1 在手動變異wasm檔案的同時加上--abigen flag可以同時編譯abi檔案
$ eosio-cpp hello.cpp -o hello.wasm --abigen

 

6. 部署合約

$ cleos set contract eosio contracts/eosio.bios -p [email protected]
Reading WAST...
Assembling WASM...
Publishing contract...
executed transaction: 414cf0dc7740d22474992779b2416b0eabdbc91522c16521307dd682051af083  4068 bytes  10000 cycles
#         eosio <= eosio::setcode               {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001ab011960037f7e7f0060057f7e7e7e...
#         eosio <= eosio::setabi                {"account":"eosio","abi":{"types":[],"structs":[{"name":"set_account_limits","base":"","fields":[{"n...

 7. 執行合約

# cleos push action eosio.token create '{"issuer":"eosio", "maximum_supply":"1000000000.0000 EOS", "can_freeze":0, "can_recall":0, "can_whitelist":0}' -j -p eosio.token