zoukankan      html  css  js  c++  java
  • Deploy, Issue and Transfer Tokens

    Deploy, Issue and Transfer Tokens

      本例使用 eosio.token 合约来尝试发行Token.

    1、签出 eosio.contracts。

    git clone https://github.com/EOSIO/eosio.contracts --branch v1.4.0 --single-branch

      这里头有很多eosio写的标准合约。

      

      我们将使用上图中的 eosio.token 合约来练习发布 token。

    2、eosio.token非常的简单,仅包含 eosio.token.hpp、eosio.token.cpp两件文件。其中提供了6个action:

      

    3、建立一个 eosio.token account,此账户用于发布eosio.token合约。

    cleos create account eosio eosio.token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    4、在 eosio.token 目录下编译合约 

    eosio-cpp -I include -o eosio.token.wasm src/eosio.token.cpp --abigen

    5、用 eosio.token 账号发布合约 

    cleos set contract eosio.token /home/ubuntu/contracts/eosio.contracts/eosio.token --abi eosio.token.abi -p eosio.token@active

    6、一个合约可以创建多个token。使用 create 方法创建一种token。

    cleos push action eosio.token create '[ "eosio", "1000000000.0000 SYS"]' -p eosio.token@active

      因为此处是创建token,所以需要 eosio.token 账户的权限。

      it's a symbol_name type composed of two pieces of data, a maximum supply float and a symbol_name in capitalized alpha characters only, for example "1.0000 SYM".

      The issuer will be the one with authority to call issue and or perform other actions such as freezing, recalling, and whitelisting of owners.

      This command created a new token SYS with a precision of 4 decimals and a maximum supply of 1000000000.0000 SYS. To create this token requires the permission of the eosio.token contract. For this reason, -p eosio.token@active was passed to authorize the request.

    7、发行token。

      The issuer can issue new tokens to the "alice" account created earlier.

      发行者(issuer)可以给其它用户发行token。

    cleos push action eosio.token issue '[ "alice", "100.0000 SYS", "memo" ]' -p eosio@active

      注意,因为此处是发行token,所以需要发行者(issuer)的权限。

      

      To inspect the transaction, try using the -d -j options, they indicate "don't broadcast" and "return transaction as json," which you may find useful during development.

    cleos push action eosio.token issue '["alice", "100.0000 SYS", "memo"]' -p eosio@active -d -j

    8、转移 token。

    cleos push action eosio.token transfer '[ "alice", "bob", "25.0000 SYS", "m" ]' -p alice@active

      Now check if "bob" got the tokens using cleos get currency balance

    cleos get currency balance eosio.token bob SYS
    25.00 SYS

      Check "alice's" balance, notice that tokens were deducted from the account

    cleos get currency balance eosio.token alice SYS
    75.00 SYS

    参考:

    1、https://developers.eos.io/eosio-home/docs/token-contract#section-step-3-compile-the-contract

  • 相关阅读:
    Java学习笔记——动态代理
    Java学习随笔——RMI
    数据结构与算法——排序算法
    设计模式——装饰者模式
    Struts2中使用execAndWait后,在 Action中调用getXXX()方法报告java.lang.NullPointerException异常的原因和解决方法
    vs中debug的一个小技巧 -- debug时忽略某段代码
    SilverlightMVVM模式中的数据校验
    技能图谱
    MQ队列管理器损坏的处理方法
    informix数据库锁表处理方法
  • 原文地址:https://www.cnblogs.com/tekkaman/p/10001659.html
Copyright © 2011-2022 走看看