首页 技术 正文
技术 2022年11月11日
0 收藏 671 点赞 2,204 浏览 2105 个字

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写的标准合约。

  Deploy, Issue and Transfer Tokens

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

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

  Deploy, Issue and Transfer Tokens

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

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,000
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,512
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,358
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,141
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,771
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,849