切换到eos/build/programs/cleos路径下面。

1. 钱包设置

秘钥需要保存好,后面解锁时会用到。

liyuechun:cleos yuechunli$ ./cleos wallet create
Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5HtkrzGaNKGNKVGXc6icWiWdo7PFsjWJAdE2dJbt5bSnbwb7spd"

2. 为账号部署合约

liyuechun:cleos yuechunli$ ./cleos set contract eosio ../../contracts/eosio.bios -p eosio
liyuechun:cleos yuechunli$ ./cleos set contract eosio ../../contracts/eosio.bios -p eosio
Reading WAST/WASM from ../../contracts/eosio.bios/eosio.bios.wast...
Assembling WASM...
Publishing contract...
executed transaction: 32735994889238e18ba60341bb79f6b674738727e9d5996991f8f34b496e3a18  3288 bytes  2200576 cycles
#         eosio <= eosio::setcode               {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001581060037f7e7f0060057f7e7e7e7e...
#         eosio <= eosio::setabi                {"account":"eosio","abi":{"types":[],"structs":[{"name":"set_account_limits","base":"","fields":[{"n...
liyuechun:cleos yuechunli$

3. 创建2个key,导入key的私钥

liyuechun:cleos yuechunli$ ./cleos create key
Private key: 5Kg4i6WW6mfGXGjriU552KdAQ8tQyCU4mqtevVganWWbzQf1rD1
Public key: EOS5MSkE5DGgSurc7k3Sv9kWrev6E3GBBqasdiiC3yajPwrW7c4Uqliyuechun:cleos yuechunli$ ./cleos create key
Private key: 5Kg2P7PRA7wWrW2s53JiaBur7PhDtDsCMZUwQ8Yvn8uAmu8xEMB
Public key: EOS7wERhooVJwqYLuQn5v6UDZnL5KQpGJBDMQoktkxz4baNzicwLXliyuechun:cleos yuechunli$ ./cleos wallet import 5Kg4i6WW6mfGXGjriU552KdAQ8tQyCU4mqtevVganWWbzQf1rD1
imported private key for: EOS5MSkE5DGgSurc7k3Sv9kWrev6E3GBBqasdiiC3yajPwrW7c4Uq
liyuechun:cleos yuechunli$ ./cleos wallet import 5Kg2P7PRA7wWrW2s53JiaBur7PhDtDsCMZUwQ8Yvn8uAmu8xEMB
imported private key for: EOS7wERhooVJwqYLuQn5v6UDZnL5KQpGJBDMQoktkxz4baNzicwLX
liyuechun:cleos yuechunli$ 

4. 根据生成的公钥,创建帐号

$ liyuechun:cleos yuechunli$ ./cleos create account eosio eostoken EOS5MSkE5DGgSurc7k3Sv9kWrev6E3GBBqasdiiC3yajPwrW7c4Uq EOS7wERhooVJwqYLuQn5v6UDZnL5KQpGJBDMQoktkxz4baNzicwLX
liyuechun:cleos yuechunli$ ./cleos create account eosio eostoken EOS5MSkE5DGgSurc7k3Sv9kWrev6E3GBBqasdiiC3yajPwrW7c4Uq EOS7wERhooVJwqYLuQn5v6UDZnL5KQpGJBDMQoktkxz4baNzicwLX
executed transaction: e691042df8074a25f47b8364f58a03c2c407e64d2cbc7248e1e9a611a06fe547  352 bytes  102400 cycles
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"eostoken","owner":{"threshold":1,"keys":[{"key":"EOS5MSkE5DGgSurc7k3Sv9kW...

5. 查看账号信息

liyuechun:cleos yuechunli$ ./cleos get account eostoken
liyuechun:cleos yuechunli$ ./cleos get account eostoken
{"account_name": "eostoken","permissions": [{"perm_name": "active","parent": "owner","required_auth": {"threshold": 1,"keys": [{"key": "EOS7wERhooVJwqYLuQn5v6UDZnL5KQpGJBDMQoktkxz4baNzicwLX","weight": 1}],"accounts": []}},{"perm_name": "owner","parent": "","required_auth": {"threshold": 1,"keys": [{"key": "EOS5MSkE5DGgSurc7k3Sv9kWrev6E3GBBqasdiiC3yajPwrW7c4Uq","weight": 1}],"accounts": []}}]
}
liyuechun:cleos yuechunli$

6. 检测,并部署合约

$ ./cleos get code currency
$ ./cleos set contract currency ../../contracts/currency
$ ./cleos get code currency
liyuechun:cleos yuechunli$ ./cleos get code currency
code hash: 0000000000000000000000000000000000000000000000000000000000000000
liyuechun:cleos yuechunli$ ./cleos set contract currency ../../contracts/currency
Reading WAST/WASM from ../../contracts/currency/currency.wast...
Assembling WASM...
Publishing contract...
executed transaction: eec4d42d5c1aab8785ce8e55618bf209d2e4dbcaf881e004c260c779d5571cef  7112 bytes  2200576 cycles
#         eosio <= eosio::setcode               {"account":"currency","vmtype":0,"vmversion":0,"code":"0061736d010000000199011860000060027e7e0060017...
#         eosio <= eosio::setabi                {"account":"currency","abi":{"types":[{"new_type_name":"account_name","type":"name"}],"structs":[{"n...
liyuechun:cleos yuechunli$ ./cleos get code currency
code hash: d6c891fbdfcff597d82e17c81354574399b01d533e53d412093f03e1950fb9d4
liyuechun:cleos yuechunli$

7. 创建货币

$ ./cleos push action currency create '{"issuer":"currency","maximum_supply":"1000000.0000 CUR","can_freeze":"0","can_recall":"0","can_whitelist":"0"}' --permission currency@active
liyuechun:cleos yuechunli$ ./cleos push action currency create '{"issuer":"currency","maximum_supply":"1000000.0000 CUR","can_freeze":"0","can_recall":"0","can_whitelist":"0"}' --permission currency@active
executed transaction: ae92a14b810e1437e9a0e8ae0527268a1e0fbd834d8c0a6906c8b65d9b503dc4  248 bytes  103424 cycles
#      currency <= currency::create             {"issuer":"currency","maximum_supply":"1000000.0000 CUR","can_freeze":0,"can_recall":0,"can_whitelis...
>> create
liyuechun:cleos yuechunli$

8. 发行货币

$ ./cleos push action currency issue '{"to":"currency","quantity":"1000.0000 CUR","memo":""}' --permission currency@active
liyuechun:cleos yuechunli$ ./cleos push action currency issue '{"to":"currency","quantity":"1000.0000 CUR","memo":""}' --permission currency@active
executed transaction: 7b8108d19aba6c8dcc601c321ef3c433cd2a3aedbd3ac1b217f06477792b40f7  248 bytes  106496 cycles
#      currency <= currency::issue              {"to":"currency","quantity":"1000.0000 CUR","memo":""}
>> issue
liyuechun:cleos yuechunli$

9. 查看帐号信息

$ ./cleos get table currency currency accounts
liyuechun:cleos yuechunli$ ./cleos get table currency currency accounts
{"rows": [{"balance": "1000.0000 CUR","frozen": 0,"whitelist": 1}],"more": false
}
liyuechun:cleos yuechunli$

10. 转账

$ ./cleos push action currency transfer '{"from":"currency","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}' --permission currency@active
$ ./cleos get table currency currency accounts
liyuechun:cleos yuechunli$ ./cleos push action currency transfer '{"from":"currency","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}' --permission currency@active
executed transaction: 4a24e5a9afd17abe61dcb3b3aff06a1c5ec94663f803d3d1801bd7a5046fea9e  272 bytes  109568 cycles
#      currency <= currency::transfer           {"from":"currency","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}
>> transfer
#         eosio <= currency::transfer           {"from":"currency","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}
liyuechun:cleos yuechunli$ ./cleos get table currency currency accounts
{"rows": [{"balance": "980.0000 CUR","frozen": 0,"whitelist": 1}],"more": false
}

http://liyuechun.org/2018/04/13/eos-contract/

第二篇 - EOS Currency 合约案例相关推荐

  1. 【许晓笛】 EOS智能合约案例解析(1)

    详解 EOS 智能合约的 hpp 文件 为了帮助大家熟悉 EOS 智能合约,EOS 官方提供了一个代币(资产)智能合约 Demo -- eosio.token.eosio.token 智能合约目前还不 ...

  2. 【许晓笛】 EOS智能合约案例解析(1) 1

    详解 EOS 智能合约的 hpp 文件 为了帮助大家熟悉 EOS 智能合约,EOS 官方提供了一个代币(资产)智能合约 Demo -- eosio.token.eosio.token 智能合约目前还不 ...

  3. 【许晓笛】EOS智能合约案例解析(1)

    为了帮助大家熟悉 EOS 智能合约,EOS 官方提供了一个代币(资产)智能合约 Demo -- eosio.token.eosio.token 智能合约目前还不是特别完善,个别功能还没有完成.但这个示 ...

  4. 【许晓笛】 EOS 智能合约案例解析(2)

    详解 EOS 智能合约的 cpp 文件 之前的文章介绍了 eosio.token 智能合约的 hpp 文件,这次向大家介绍 eosio.token.cpp 文件,cpp 文件即 C++ 代码文件,智能 ...

  5. 【许晓笛】EOS 智能合约案例解析(2)

    详解 EOS 智能合约的 cpp 文件 之前的文章介绍了 eosio.token 智能合约的 hpp 文件,这次向大家介绍 eosio.token.cpp 文件,cpp 文件即 C++ 代码文件,智能 ...

  6. EOS智能合约案例解析(下)

    这次向大家介绍 eosio.token 智能合约的最后一个文件 -- abi文件.ABI 全称 Application Binary Interface,中文名"应用程序二进制接口" ...

  7. 第三篇 - EOS DAWN-V3.0.0 智能合约开发之Hello World

    不管是C.C++.Java还是任何其他语言,一般刚开始学习的时候,我们都会从HelloWorld开始,这篇文章主要讲解EOS DAWN-V3.0.0 智能合约开发之Hello World. 在看这篇文 ...

  8. c++ eos智能合约开发_[EOS智能合约]第二节:用EOS开发一个To-do List小应用

    EOS Asia 本教程原文作者为EOS Asia,亚洲最具技术实力和最国际化的EOS超级节点竞选者.EOS Asia 同时也是EOS Gems和Traffic Exchange Token这两个项目 ...

  9. Python GUI案例之看图猜成语开发(第二篇)

    Python GUI案例之看图猜成语(第二篇) 前言 看图猜成语小程序开发(第二篇) 游戏选择模式页面 游戏训练模式页面 Python GUI案例之看图猜成语开发(第一篇) Python GUI案例之 ...

最新文章

  1. HTML 中的marquee标签详解
  2. 掸邦的首府---东枝【图文】
  3. php网页制作 博客,php响应式的个人博客网站设计
  4. 基于Vue项目打包上线配置
  5. LeetCode 841. 钥匙和房间(DFS/BFS)
  6. noip2013——提高组——花匠(flower)
  7. Spring MVC文件上传下载实例
  8. pandas DataFrame方法;dataframe 定义一个数值全为1的列;dataframe创建多列;如何拆分嵌套list存为dataframe;在数据集添加一个新的列
  9. 关于单片机引脚的别名定义的正确语法
  10. java获取用户地理位置_Java获取用户访问IP及地理位置的方法详解
  11. app开发快速理解——webview网页显示
  12. 南开大学计算机学院博士毕业要求,南京大学博士研究生申请学位科研成果基本要求...
  13. mysql 查询view_MySQL之视图(VIEW)
  14. [历史随笔]帝国如风--元朝的另类历史
  15. VUE项目中优雅使用EasyPlayer实时播放摄像头多种格式视频
  16. 下载网页上的视频—Flash Video Downloader插件
  17. 二手苹果手机哪个性价比高?
  18. 复杂美区块链技术专利技术之一:交易组解析
  19. 理一下CUDA、CUDA toolkit和NVCC
  20. java .gml格式_GML格式错误

热门文章

  1. Java 第7章 数组
  2. ⑧javaWeb之在例子中学习(过滤器Filter)
  3. DataGrid中添加背景
  4. Deeplearning入门篇(2)
  5. EXCEL利用VBA自由控制图表绘图区大小
  6. Sublime Text2使用ctex
  7. 【算法】一个简单的线性判别分析(LDA)原理
  8. 科大星云诗社动态20210321
  9. (Q 2)netstat命令 检测TCP/IP 网络链接是否存在异常
  10. 线性判别分析LDA的数学原理(一)