本篇主要是介紹如何部署Token合約,發(fā)布Token以及交易Token.
1匀油、流程
獲取合約代碼
為合約創(chuàng)建賬號(hào)(eosio.token)
編譯合約
部署Token合約
創(chuàng)建Token
發(fā)布Token
轉(zhuǎn)賬Token
2缘缚、關(guān)鍵步驟
創(chuàng)建賬號(hào):
查看上面的交易id:
SummerdeMacBook-Pro:eosio.token summer$ cleos get transaction 92d8337cf3c6b6977c751e7698a1b240a8c35d2b525fd1b96951c69dce1d76bc
Warning: Failed to set locale category LC_NUMERIC to en_CN.
Warning: Failed to set locale category LC_TIME to en_CN.
Warning: Failed to set locale category LC_COLLATE to en_CN.
Warning: Failed to set locale category LC_MONETARY to en_CN.
Warning: Failed to set locale category LC_MESSAGES to en_CN.
{
? "id": "92d8337cf3c6b6977c751e7698a1b240a8c35d2b525fd1b96951c69dce1d76bc",
? "trx": {
? ? "receipt": {
? ? ? "status": "executed",
? ? ? "cpu_usage_us": 8613,
? ? ? "net_usage_words": 25,
? ? ? "trx": [
? ? ? ? 1,{
? ? ? ? ? "signatures": [
? ? ? ? ? ? "SIG_K1_K1pGDVcT7cNoq7z5MDC9ejSbodFNQzjQpk7y46md3rqpRz3X83mpC2VqeBwHTUM23DwWdNWSSLypLXpR7X1usMiVH4zAnU"
? ? ? ? ? ],
? ? ? ? ? "compression": "none",
? ? ? ? ? "packed_context_free_data": "",
? ? ? ? ? "packed_trx": "2a012f5e9422971c730200000000010000000000ea305500409e9a2264b89a010000000000ea305500000000a8ed3232660000000000ea305500a6823403ea305501000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf0100000001000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf0100000000"
? ? ? ? }
? ? ? ]
? ? },
? ? "trx": {
? ? ? "expiration": "2020-01-27T15:26:34",
? ? ? "ref_block_num": 8852,
? ? ? "ref_block_prefix": 41098391,
? ? ? "max_net_usage_words": 0,
? ? ? "max_cpu_usage_ms": 0,
? ? ? "delay_sec": 0,
? ? ? "context_free_actions": [],
? ? ? "actions": [{
? ? ? ? ? "account": "eosio",
? ? ? ? ? "name": "newaccount",
? ? ? ? ? "authorization": [{
? ? ? ? ? ? ? "actor": "eosio",
? ? ? ? ? ? ? "permission": "active"
? ? ? ? ? ? }
? ? ? ? ? ],
? ? ? ? ? "data": {
? ? ? ? ? ? "creator": "eosio",
? ? ? ? ? ? "name": "eosio.token",
? ? ? ? ? ? "owner": {
? ? ? ? ? ? ? "threshold": 1,
? ? ? ? ? ? ? "keys": [{
? ? ? ? ? ? ? ? ? "key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
? ? ? ? ? ? ? ? ? "weight": 1
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ],
? ? ? ? ? ? ? "accounts": [],
? ? ? ? ? ? ? "waits": []
? ? ? ? ? ? },
? ? ? ? ? ? "active": {
? ? ? ? ? ? ? "threshold": 1,
? ? ? ? ? ? ? "keys": [{
? ? ? ? ? ? ? ? ? "key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
? ? ? ? ? ? ? ? ? "weight": 1
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ],
? ? ? ? ? ? ? "accounts": [],
? ? ? ? ? ? ? "waits": []
? ? ? ? ? ? }
? ? ? ? ? },
? ? ? ? ? "hex_data": "0000000000ea305500a6823403ea305501000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf0100000001000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf01000000"
? ? ? ? }
? ? ? ],
? ? ? "transaction_extensions": [],
? ? ? "signatures": [
? ? ? ? "SIG_K1_K1pGDVcT7cNoq7z5MDC9ejSbodFNQzjQpk7y46md3rqpRz3X83mpC2VqeBwHTUM23DwWdNWSSLypLXpR7X1usMiVH4zAnU"
? ? ? ],
? ? ? "context_free_data": []
? ? }
? },
? "block_time": "2020-01-27T15:26:05.000",
? "block_num": 8854,
? "last_irreversible_block": 9150,
? "traces": [{
? ? ? "action_ordinal": 1,
? ? ? "creator_action_ordinal": 0,
? ? ? "closest_unnotified_ancestor_action_ordinal": 0,
? ? ? "receipt": {
? ? ? ? "receiver": "eosio",
? ? ? ? "act_digest": "6e828864f5a8a23daeab1be9bbdff03b9e1aae7cf7d46af17228a0001b636c13",
? ? ? ? "global_sequence": 8863,
? ? ? ? "recv_sequence": 8860,
? ? ? ? "auth_sequence": [[
? ? ? ? ? ? "eosio",
? ? ? ? ? ? 8857
? ? ? ? ? ]
? ? ? ? ],
? ? ? ? "code_sequence": 0,
? ? ? ? "abi_sequence": 0
? ? ? },
? ? ? "receiver": "eosio",
? ? ? "act": {
? ? ? ? "account": "eosio",
? ? ? ? "name": "newaccount",
? ? ? ? "authorization": [{
? ? ? ? ? ? "actor": "eosio",
? ? ? ? ? ? "permission": "active"
? ? ? ? ? }
? ? ? ? ],
? ? ? ? "data": {
? ? ? ? ? "creator": "eosio",
? ? ? ? ? "name": "eosio.token",
? ? ? ? ? "owner": {
? ? ? ? ? ? "threshold": 1,
? ? ? ? ? ? "keys": [{
? ? ? ? ? ? ? ? "key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
? ? ? ? ? ? ? ? "weight": 1
? ? ? ? ? ? ? }
? ? ? ? ? ? ],
? ? ? ? ? ? "accounts": [],
? ? ? ? ? ? "waits": []
? ? ? ? ? },
? ? ? ? ? "active": {
? ? ? ? ? ? "threshold": 1,
? ? ? ? ? ? "keys": [{
? ? ? ? ? ? ? ? "key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
? ? ? ? ? ? ? ? "weight": 1
? ? ? ? ? ? ? }
? ? ? ? ? ? ],
? ? ? ? ? ? "accounts": [],
? ? ? ? ? ? "waits": []
? ? ? ? ? }
? ? ? ? },
? ? ? ? "hex_data": "0000000000ea305500a6823403ea305501000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf0100000001000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf01000000"
? ? ? },
? ? ? "context_free": false,
? ? ? "elapsed": 4326,
? ? ? "console": "",
? ? ? "trx_id": "92d8337cf3c6b6977c751e7698a1b240a8c35d2b525fd1b96951c69dce1d76bc",
? ? ? "block_num": 8854,
? ? ? "block_time": "2020-01-27T15:26:05.000",
? ? ? "producer_block_id": null,
? ? ? "account_ram_deltas": [{
? ? ? ? ? "account": "eosio.token",
? ? ? ? ? "delta": 2724
? ? ? ? }
? ? ? ],
? ? ? "except": null,
? ? ? "error_code": null
? ? }
? ]
}
部署合約:
SummerdeMacBook-Pro:eosio.token summer$ cleos set contract eosio.token /Users/summer/study/blockchain/eos/contracts/eosio.contracts/contracts/eosio.token --abi eosio.token.abi -p eosio.token@active
Warning: Failed to set locale category LC_NUMERIC to en_CN.
Warning: Failed to set locale category LC_TIME to en_CN.
Warning: Failed to set locale category LC_COLLATE to en_CN.
Warning: Failed to set locale category LC_MONETARY to en_CN.
Warning: Failed to set locale category LC_MESSAGES to en_CN.
Reading WASM from /Users/summer/study/blockchain/eos/contracts/eosio.contracts/contracts/eosio.token/eosio.token.wasm...
Publishing contract...
executed transaction: cd9dae9fefad3820779d580da7586001785cdfdf4de966a1500773e5af7ff739? 6984 bytes? 8591 us
#? ? ? ? eosio <= eosio::setcode? ? ? ? ? ? ? {"account":"eosio.token","vmtype":0,"vmversion":0,"code":"0061736d0100000001a0011b60000060017e006002...
#? ? ? ? eosio <= eosio::setabi? ? ? ? ? ? ? ? {"account":"eosio.token","abi":"0e656f73696f3a3a6162692f312e310008076163636f756e7400010762616c616e63...
warning: transaction executed locally, but may not be confirmed by the network yet? ? ? ? ]
SummerdeMacBook-Pro:eosio.token summer$ cleos get transaction cd9dae9fefad3820779d580da7586001785cdfdf4de966a1500773e5af7ff739
Warning: Failed to set locale category LC_NUMERIC to en_CN.
Warning: Failed to set locale category LC_TIME to en_CN.
Warning: Failed to set locale category LC_COLLATE to en_CN.
Warning: Failed to set locale category LC_MONETARY to en_CN.
Warning: Failed to set locale category LC_MESSAGES to en_CN.
{
? "id": "cd9dae9fefad3820779d580da7586001785cdfdf4de966a1500773e5af7ff739",
? "trx": {
? ? "receipt": {
? ? ? "status": "executed",
? ? ? "cpu_usage_us": 8591,
? ? ? "net_usage_words": 873,
? ? ? "trx": [
? ? ? ? 1,{
? ? ? ? ? "signatures": [
? ? ? ? ? ? "SIG_K1_KaaRhoYdZVMtzFBWZgQb5AsEoWyBxExhierBYnMS4EiJiFsR4Mh8aRpZRDFqGGvgBufg5fCGnroRWhdVTT8GB4ww5AMVnn"
? ? ? ? ? ],
? ? ? ? ? "compression": "zlib",
? ? ? ? ? "packed_context_free_data": "",
? ? ? ? ? "packed_trx": "...省略..."
? ? ? ? }
? ? ? ]
? ? },
? ? "trx": {
? ? ? "expiration": "2020-01-28T08:12:43",
? ? ? "ref_block_num": 10450,
? ? ? "ref_block_prefix": 1108516220,
? ? ? "max_net_usage_words": 0,
? ? ? "max_cpu_usage_ms": 0,
? ? ? "delay_sec": 0,
? ? ? "context_free_actions": [],
? ? ? "actions": [{
? ? ? ? ? "account": "eosio",
? ? ? ? ? "name": "setcode",
? ? ? ? ? "authorization": [{
? ? ? ? ? ? ? "actor": "eosio.token",
? ? ? ? ? ? ? "permission": "active"
? ? ? ? ? ? }
? ? ? ? ? ],
? ? ? ? ? "data": {
? ? ? ? ? ? "account": "eosio.token",
? ? ? ? ? ? "vmtype": 0,
? ? ? ? ? ? "vmversion": 0,
? ? ? ? ? ? "code": "...省略..."
? ? ? ? ? },
? ? ? ? ? "hex_data": "...省略..."
? ? ? ? },{
? ? ? ? ? "account": "eosio",
? ? ? ? ? "name": "setabi",
? ? ? ? ? "authorization": [{
? ? ? ? ? ? ? "actor": "eosio.token",
? ? ? ? ? ? ? "permission": "active"
? ? ? ? ? ? }
? ? ? ? ? ],
? ? ? ? ? "data": {
? ? ? ? ? ? "account": "eosio.token",
? ? ? ? ? ? "abi": "...省略..."
? ? ? ? ? },
? ? ? ? ? "hex_data": "...省略..."
? ? ? ? }
? ? ? ],
? ? ? "transaction_extensions": [],
? ? ? "signatures": [
? ? ? ? "SIG_K1_KaaRhoYdZVMtzFBWZgQb5AsEoWyBxExhierBYnMS4EiJiFsR4Mh8aRpZRDFqGGvgBufg5fCGnroRWhdVTT8GB4ww5AMVnn"
? ? ? ],
? ? ? "context_free_data": []
? ? }
? },
? "block_time": "2020-01-28T08:12:14.000",
? "block_num": 10452,
? "last_irreversible_block": 10499,
? "traces": [{
? ? ? "action_ordinal": 1,
? ? ? "creator_action_ordinal": 0,
? ? ? "closest_unnotified_ancestor_action_ordinal": 0,
? ? ? "receipt": {
? ? ? ? "receiver": "eosio",
? ? ? ? "act_digest": "4968524b5efc487f30038d68701904766730a9de666018f621325f018d395c14",
? ? ? ? "global_sequence": 10462,
? ? ? ? "recv_sequence": 10459,
? ? ? ? "auth_sequence": [[
? ? ? ? ? ? "eosio.token",
? ? ? ? ? ? 1
? ? ? ? ? ]
? ? ? ? ],
? ? ? ? "code_sequence": 0,
? ? ? ? "abi_sequence": 0
? ? ? },
? ? ? "receiver": "eosio",
? ? ? "act": {
? ? ? ? "account": "eosio",
? ? ? ? "name": "setcode",
? ? ? ? "authorization": [{
? ? ? ? ? ? "actor": "eosio.token",
? ? ? ? ? ? "permission": "active"
? ? ? ? ? }
? ? ? ? ],
? ? ? ? "data": {
? ? ? ? ? "account": "eosio.token",
? ? ? ? ? "vmtype": 0,
? ? ? ? ? "vmversion": 0,
? ? ? ? ? "code": "...省略..."
? ? ? ? },
? ? ? ? "hex_data": "...省略..."
? ? ? },
? ? ? "context_free": false,
? ? ? "elapsed": 5063,
? ? ? "console": "",
? ? ? "trx_id": "cd9dae9fefad3820779d580da7586001785cdfdf4de966a1500773e5af7ff739",
? ? ? "block_num": 10452,
? ? ? "block_time": "2020-01-28T08:12:14.000",
? ? ? "producer_block_id": null,
? ? ? "account_ram_deltas": [{
? ? ? ? ? "account": "eosio.token",
? ? ? ? ? "delta": 176370
? ? ? ? }
? ? ? ],
? ? ? "except": null,
? ? ? "error_code": null
? ? },{
? ? ? "action_ordinal": 2,
? ? ? "creator_action_ordinal": 0,
? ? ? "closest_unnotified_ancestor_action_ordinal": 0,
? ? ? "receipt": {
? ? ? ? "receiver": "eosio",
? ? ? ? "act_digest": "50542fbc8ed43fda3716646894b4d4cbe409381b53e970737a37909a12216964",
? ? ? ? "global_sequence": 10463,
? ? ? ? "recv_sequence": 10460,
? ? ? ? "auth_sequence": [[
? ? ? ? ? ? "eosio.token",
? ? ? ? ? ? 2
? ? ? ? ? ]
? ? ? ? ],
? ? ? ? "code_sequence": 0,
? ? ? ? "abi_sequence": 0
? ? ? },
? ? ? "receiver": "eosio",
? ? ? "act": {
? ? ? ? "account": "eosio",
? ? ? ? "name": "setabi",
? ? ? ? "authorization": [{
? ? ? ? ? ? "actor": "eosio.token",
? ? ? ? ? ? "permission": "active"
? ? ? ? ? }
? ? ? ? ],
? ? ? ? "data": {
? ? ? ? ? "account": "eosio.token",
? ? ? ? ? "abi": "...省略..."
? ? ? ? },
? ? ? ? "hex_data": "...省略..."
? ? ? },
? ? ? "context_free": false,
? ? ? "elapsed": 476,
? ? ? "console": "",
? ? ? "trx_id": "cd9dae9fefad3820779d580da7586001785cdfdf4de966a1500773e5af7ff739",
? ? ? "block_num": 10452,
? ? ? "block_time": "2020-01-28T08:12:14.000",
? ? ? "producer_block_id": null,
? ? ? "account_ram_deltas": [{
? ? ? ? ? "account": "eosio.token",
? ? ? ? ? "delta": 508
? ? ? ? }
? ? ? ],
? ? ? "except": null,
? ? ? "error_code": null
? ? }
? ]
}
創(chuàng)建token:
應(yīng)該是必須用部署合約的那個(gè)賬號(hào)創(chuàng)建token
創(chuàng)建token的命令中包括以下內(nèi)容:
指定哪個(gè)賬號(hào)是token的issuer
指定token的總量
指定token的代號(hào)
發(fā)布token:
必須用創(chuàng)建token時(shí)指定的issuer來(lái)發(fā)布
SummerdeMacBook-Pro:eosio.token summer$ cleos get transaction f3359e2aa45e7d237a0584c4475f310c417c35c9df0f2ef3f831f8f683d3b53d
Warning: Failed to set locale category LC_NUMERIC to en_CN.
Warning: Failed to set locale category LC_TIME to en_CN.
Warning: Failed to set locale category LC_COLLATE to en_CN.
Warning: Failed to set locale category LC_MONETARY to en_CN.
Warning: Failed to set locale category LC_MESSAGES to en_CN.
{
? "id": "f3359e2aa45e7d237a0584c4475f310c417c35c9df0f2ef3f831f8f683d3b53d",
? "trx": {
? ? "receipt": {
? ? ? "status": "executed",
? ? ? "cpu_usage_us": 583,
? ? ? "net_usage_words": 16,
? ? ? "trx": [
? ? ? ? 1,{
? ? ? ? ? "signatures": [
? ? ? ? ? ? "SIG_K1_KkjaEJPa9GybAPUYa6rv9gyq6ZRnvbQ4KLJ1HnGYPuiYV9h5Kiw6a9ZCTWhWwJvtx92qBBK34YmcHBCyLjv2L77Lq7WSkc"
? ? ? ? ? ],
? ? ? ? ? "compression": "none",
? ? ? ? ? "packed_context_free_data": "",
? ? ? ? ? "packed_trx": "5bf02f5e922f9afd66d8000000000100a6823403ea30550000000000a53176010000000000855c3400000000a8ed32321d0000000000855c34a0860100000000000353595300000000046d656d6f00"
? ? ? ? }
? ? ? ]
? ? },
? ? "trx": {
? ? ? "expiration": "2020-01-28T08:27:07",
? ? ? "ref_block_num": 12178,
? ? ? "ref_block_prefix": 3630628250,
? ? ? "max_net_usage_words": 0,
? ? ? "max_cpu_usage_ms": 0,
? ? ? "delay_sec": 0,
? ? ? "context_free_actions": [],
? ? ? "actions": [{
? ? ? ? ? "account": "eosio.token",
? ? ? ? ? "name": "issue",
? ? ? ? ? "authorization": [{
? ? ? ? ? ? ? "actor": "alice",
? ? ? ? ? ? ? "permission": "active"
? ? ? ? ? ? }
? ? ? ? ? ],
? ? ? ? ? "data": {
? ? ? ? ? ? "to": "alice",
? ? ? ? ? ? "quantity": "100.000 SYS",
? ? ? ? ? ? "memo": "memo"
? ? ? ? ? },
? ? ? ? ? "hex_data": "0000000000855c34a0860100000000000353595300000000046d656d6f"
? ? ? ? }
? ? ? ],
? ? ? "transaction_extensions": [],
? ? ? "signatures": [
? ? ? ? "SIG_K1_KkjaEJPa9GybAPUYa6rv9gyq6ZRnvbQ4KLJ1HnGYPuiYV9h5Kiw6a9ZCTWhWwJvtx92qBBK34YmcHBCyLjv2L77Lq7WSkc"
? ? ? ],
? ? ? "context_free_data": []
? ? }
? },
? "block_time": "2020-01-28T08:26:38.000",
? "block_num": 12180,
? "last_irreversible_block": 12315,
? "traces": [{
? ? ? "action_ordinal": 1,
? ? ? "creator_action_ordinal": 0,
? ? ? "closest_unnotified_ancestor_action_ordinal": 0,
? ? ? "receipt": {
? ? ? ? "receiver": "eosio.token",
? ? ? ? "act_digest": "d61ba9d45a3f68f1cfd0d2fe7ad3458be4b201552f64bc38d2d7f2209ff72bd9",
? ? ? ? "global_sequence": 12193,
? ? ? ? "recv_sequence": 2,
? ? ? ? "auth_sequence": [[
? ? ? ? ? ? "alice",
? ? ? ? ? ? 3
? ? ? ? ? ]
? ? ? ? ],
? ? ? ? "code_sequence": 1,
? ? ? ? "abi_sequence": 1
? ? ? },
? ? ? "receiver": "eosio.token",
? ? ? "act": {
? ? ? ? "account": "eosio.token",
? ? ? ? "name": "issue",
? ? ? ? "authorization": [{
? ? ? ? ? ? "actor": "alice",
? ? ? ? ? ? "permission": "active"
? ? ? ? ? }
? ? ? ? ],
? ? ? ? "data": {
? ? ? ? ? "to": "alice",
? ? ? ? ? "quantity": "100.000 SYS",
? ? ? ? ? "memo": "memo"
? ? ? ? },
? ? ? ? "hex_data": "0000000000855c34a0860100000000000353595300000000046d656d6f"
? ? ? },
? ? ? "context_free": false,
? ? ? "elapsed": 439,
? ? ? "console": "",
? ? ? "trx_id": "f3359e2aa45e7d237a0584c4475f310c417c35c9df0f2ef3f831f8f683d3b53d",
? ? ? "block_num": 12180,
? ? ? "block_time": "2020-01-28T08:26:38.000",
? ? ? "producer_block_id": null,
? ? ? "account_ram_deltas": [{
? ? ? ? ? "account": "alice",
? ? ? ? ? "delta": 240
? ? ? ? }
? ? ? ],
? ? ? "except": null,
? ? ? "error_code": null
? ? }
? ]
}
轉(zhuǎn)賬token
3肠仪、概念:
eosio.token:這是一個(gè)系統(tǒng)合約浦楣,貌似也叫賬號(hào)
能感受到eos創(chuàng)建token的便利性甲喝。
問(wèn)題:
合約和賬號(hào)的關(guān)系撤摸?如eosio.token