EOSIO?轉(zhuǎn)帳詳解

前言:最近有許多小伙伴問關(guān)于轉(zhuǎn)賬的一些操作,筆者在這里寫一個(gè)教程進(jìn)行詳細(xì)說明。

EOS和EOS的不同之處

在EOS網(wǎng)絡(luò)中存在兩種貨幣,一種是EOS,還有一種是EOS網(wǎng)絡(luò)中的代幣。說到這里大家似乎有點(diǎn)疑惑,舉個(gè)簡(jiǎn)單的例子,就好比ETH網(wǎng)絡(luò)中的ETH,ETH網(wǎng)絡(luò)中的其他代幣。這樣大家或許都清除了吧。

在目前EOS網(wǎng)絡(luò)中可以通過合約eosio.token產(chǎn)生多種名稱為EOS的代幣。但是還有一種通過合約eosio.system合約發(fā)布的代幣,它是EOS網(wǎng)絡(luò)中真正的EOS,他會(huì)存儲(chǔ)在用戶的賬戶中。可以通過cleos transfer來交易。

通過eosio.token發(fā)布的EOS代幣

發(fā)布bios合約

cleos set contract eosio eosio.bios/

創(chuàng)建賬戶

cleos create account eosio eostea EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV

>result

executed transaction: c10ba7625be38c823426ac9c974a7c3a774594ea80f600d95c88dc9d1053a3c6? 352 bytes? 102400 cycles

#? ? ? ? eosio <= eosio::newaccount? ? ? ? ? ? {"creator":"eosio","name":"eostea","owner":{"threshold":1,"keys":[{"key":"EOS6MRyAjQq8ud7hVNYcfnVPJq...

eostea發(fā)布代幣EOS 發(fā)布合約:

> cleos set contract eostea eosio.token/

Reading WAST...

Assembling WASM...

Publishing contract...

executed transaction: 7908bd47ae2c68ffa8f0f51bc2401e9deda2e06e16fc60356afa27f316ef529f? 8032 bytes? 2200576 cycles

#? ? ? ? eosio <= eosio::setcode? ? ? ? ? ? ? {"account":"eostea","vmtype":0,"vmversion":0,"code":"0061736d01000000018a011660067f7e7f7f7f7f0060057...

#? ? ? ? eosio <= eosio::setabi? ? ? ? ? ? ? ? {"account":"eostea","abi":{"types":[],"structs":[{"name":"transfer","base":"","fields":[{"name":"fro...

創(chuàng)建代幣:

>cleos push action eostea create '["eostea","10000000 EOS",0,0,0]' -p eostea

executed transaction: ae707244932ccd9c3b5a579d1e3875de6c0188d2024447c90df9ad716ad5ac41? 248 bytes? 104448 cycles

#? ? ? ? eostea <= eostea::create? ? ? ? ? ? ? {"issuer":"eostea","maximum_supply":"10000000 EOS","can_freeze":0,"can_recall":0,"can_whitelist":0}

發(fā)布代幣:

$ cleos push action eostea issue '["eostea","100000 EOS","issue"]' -p eostea

executed transaction: 8e37f71b607d4ec0fd9ef7582b296e0b738a13948fe9cc82090cb96c1db8054e? 256 bytes? 107520 cycles

#? ? ? ? eostea <= eostea::issue? ? ? ? ? ? ? ? {"to":"eostea","quantity":"100000 EOS","memo":"issue"}

>> issue

查看代幣:

$cleos get currency balance eostea eostea

10000 TEA

100000 EOS

下面筆者來做一個(gè)實(shí)驗(yàn),用eosio再創(chuàng)建一種EOS代幣,得到的結(jié)果:

cleos get currency balance eosio eosio

10000 EOS

給eostea轉(zhuǎn)賬:

cleos push action eosio transfer '["eosio","eostea","100 EOS",""]' -p eosio

查看eostea的代幣:

lome@lome:~/eos/build/contracts$ cleos get currency balance eostea eostea

10000 TEA

100000 EOS

lome@lome:~/eos/build/contracts$ cleos get currency balance eosio eostea

100 EOS

這樣我發(fā)型了兩種EOS代幣。但是..... 看看數(shù)據(jù)庫里面是這樣的:

{

? ? "_id" : ObjectId("5af41c653c27103f203a6beb"),

? ? "name" : "eostea",

? ? "eos_balance" : "0.0000 EOS",

? ? "staked_balance" : "0.0000 EOS",

? ? "unstaking_balance" : "0.0000 EOS",

? ? "createdAt" : "2018-05-10T10:18:13.008Z",

? ? "updatedAt" : "2018-05-10T10:19:34.007Z",

? ? "abi" : {

? ? ? ? ......

? ? }

}

eos_balance是0;

發(fā)型EOS

$ cleos push action eosio issue '["eosio","10000000.0000? EOS",""]' -p eosio

executed transaction: ad53e2b11f1b90f8cb3c5edff982fde7e87f4011773e179ca5a963df14c7227c? 248 bytes? 120832 cycles

#? ? ? ? eosio <= eosio::issue? ? ? ? ? ? ? ? {"to":"eosio","quantity":"10000000.0000 EOS"}

#? ? ? ? eosio <= eosio::transfer? ? ? ? ? ? ? {"from":"eosio","to":"eosio","quantity":"10000000.0000 EOS","memo":""}

然后查看賬戶eosio:

{

? ? "_id" : ObjectId("5af41b903c27103f203a6392"),

? ? "name" : "eosio",

? ? "eos_balance" : "10000000.0000 EOS",

? ? "staked_balance" : "0.0000 EOS",

? ? "unstaking_balance" : "0.0000 EOS",

? ? "createdAt" : "2018-05-10T10:14:40.258Z",

? ? "updatedAt" : "2018-05-10T11:44:28.506Z",

? ? "abi" : {

? ? ? ? ........

? ? }

}

轉(zhuǎn)賬:

cleos transfer eosio eostea 1000000

executed transaction: 76a8b7f4ab67d8205661c0848d6dd4566830e84ca2b86a2ae44cef58c6cea4e1? 256 bytes? 107520 cycles

#? ? ? ? eosio <= eosio::transfer? ? ? ? ? ? ? {"from":"eosio","to":"eostea","quantity":"100.0000 EOS","memo":""}

#? ? ? ? eostea <= eosio::transfer? ? ? ? ? ? ? {"from":"eosio","to":"eostea","quantity":"100.0000 EOS","memo":""}

賬戶余額:

{

? ? "_id" : ObjectId("5af4336c3c27100f643add5f"),

? ? "name" : "eostea",

? ? "eos_balance" : "100.0000 EOS",

? ? "staked_balance" : "0.0000 EOS",

? ? "unstaking_balance" : "0.0000 EOS",

? ? "createdAt" : "2018-05-10T11:56:28.501Z",

? ? "updatedAt" : "2018-05-10T12:05:38.507Z",

? ? "abi" : {

? ? ? ? ........

? ? }

}

相信看完這些,大家都非常清楚了。

轉(zhuǎn)自:EOS中文社區(qū)

轉(zhuǎn)載請(qǐng)說明文章出處

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

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

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