EOS Contract 合约

EOS Contract 合约

在部署合约发行token,至少需要三类用户

类型Action账户职责
合约账户createeosio.token合约托管账户,用来创建合约
发行账户issuekevin发行Token
交易账户transfercoco实现账户之间Token转移
部署合约

部署合约,需要创建一个合约托管账号eosio.token(也可以自定义)

[root@test-work2 eosio.token]# cleos wallet unlock -n kevin-wallet 
password: Unlocked: kevin-wallet

[root@test-work2 eosio.token]# cleos set contract eosio.token /root/eosio-wallet/build/contracts/eosio.contracts/contracts/eosio.token --abi eosio.token.abi -p eosio.token@active
Reading WASM from /root/eosio-wallet/build/contracts/eosio.contracts/contracts/eosio.token/eosio.token.wasm...
Publishing contract...
executed transaction: 86bf5c8cf4678828026ca890d2ded2cfcde80fa6afef9182a73b4a0791751723  6984 bytes  1673 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         ] 

[root@test-work2 ~]# cleos get scope eosio.token
{
  "rows": [{
      "code": "eosio.token",
      "scope": ".........1a43",
      "table": "stat",
      "payer": "eosio.token",
      "count": 1
    },{
      "code": "eosio.token",
      "scope": "........cda43",
      "table": "stat",
      "payer": "eosio.token",
      "count": 1
    },{
      "code": "eosio.token",
      "scope": "coco",
      "table": "accounts",
      "payer": "kevin",
      "count": 1
    },{
      "code": "eosio.token",
      "scope": "kevin",
      "table": "accounts",
      "payer": "kevin",
      "count": 1
    }
  ],
  "more": ""
}


创建令牌 Create Token

创建代币,指定代币的发行数量,精度,代币的符号。


[root@test-work2 ~]# cleos push action eosio.token create '[ "kevin", "1000000000.0000 CL"]' -p eosio.token@active
executed transaction: adcfd825568d430d7e89d92c16b7c4602a079591cc42f97fe70e0efec1a44d32  120 bytes  397 us
#   eosio.token <= eosio.token::create          {"issuer":"kevin","maximum_supply":"1000000000.0000 CL"}
warning: transaction executed locally, but may not be confirmed by the network yet         ] 
[root@test-work2 ~]# 

#另一种方法是使用命名参数
cleos push action eosio.token create '{"issuer":"kevin", "maximum_supply":"1000000000.0000 CL"}' -p eosio.token@active

发行令牌 Issue Tokens

现在我们已经生成了代币(CL), 发行者可以将新的代币发送给其他用户

[root@test-work2 ~]# cleos push action eosio.token issue '[ "kevin", "100.0000 CL", "issue token" ]' -p kevin@active
executed transaction: 6d0067e6ed7576428f552699b23ba6fb588d1add864eab289eb330eab341fad7  128 bytes  378 us
#   eosio.token <= eosio.token::issue           {"to":"kevin","quantity":"100.0000 CL","memo":"issue token"}
warning: transaction executed locally, but may not be confirmed by the network yet         ] 
[root@test-work2 ~]# 




托管合约的abi描述信息

每个部署的托管合约,都需要指定一个账户

[root@test-work2 ~]# cleos get abi eosio.token

响应结果如下:

{
  "version": "eosio::abi/1.1",
  "types": [],
  "structs": [{
      "name": "account",
      "base": "",
      "fields": [{
          "name": "balance",
          "type": "asset"
        }
      ]
    },{
      "name": "close",
      "base": "",
      "fields": [{
          "name": "owner",
          "type": "name"
        },{
          "name": "symbol",
          "type": "symbol"
        }
      ]
    },{
      "name": "create",
      "base": "",
      "fields": [{
          "name": "issuer",
          "type": "name"
        },{
          "name": "maximum_supply",
          "type": "asset"
        }
      ]
    },{
      "name": "currency_stats",
      "base": "",
      "fields": [{
          "name": "supply",
          "type": "asset"
        },{
          "name": "max_supply",
          "type": "asset"
        },{
          "name": "issuer",
          "type": "name"
        }
      ]
    },{
      "name": "issue",
      "base": "",
      "fields": [{
          "name": "to",
          "type": "name"
        },{
          "name": "quantity",
          "type": "asset"
        },{
          "name": "memo",
          "type": "string"
        }
      ]
    },{
      "name": "open",
      "base": "",
      "fields": [{
          "name": "owner",
          "type": "name"
        },{
          "name": "symbol",
          "type": "symbol"
        },{
          "name": "ram_payer",
          "type": "name"
        }
      ]
    },{
      "name": "retire",
      "base": "",
      "fields": [{
          "name": "quantity",
          "type": "asset"
        },{
          "name": "memo",
          "type": "string"
        }
      ]
    },{
      "name": "transfer",
      "base": "",
      "fields": [{
          "name": "from",
          "type": "name"
        },{
          "name": "to",
          "type": "name"
        },{
          "name": "quantity",
          "type": "asset"
        },{
          "name": "memo",
          "type": "string"
        }
      ]
    }
  ],
  "actions": [{
      "name": "close",
      "type": "close",
      "ricardian_contract": ""
    },{
      "name": "create",
      "type": "create",
      "ricardian_contract": ""
    },{
      "name": "issue",
      "type": "issue",
      "ricardian_contract": ""
    },{
      "name": "open",
      "type": "open",
      "ricardian_contract": ""
    },{
      "name": "retire",
      "type": "retire",
      "ricardian_contract": ""
    },{
      "name": "transfer",
      "type": "transfer",
      "ricardian_contract": ""
    }
  ],
  "tables": [{
      "name": "accounts",
      "index_type": "i64",
      "key_names": [],
      "key_types": [],
      "type": "account"
    },{
      "name": "stat",
      "index_type": "i64",
      "key_names": [],
      "key_types": [],
      "type": "currency_stats"
    }
  ],
  "ricardian_clauses": [],
  "error_messages": [],
  "abi_extensions": [],
  "variants": []
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

半山猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值