EOS Currency合约部署案例分析

区块链技术巴比特2018-04-18 11:53:51  阅读 -评论 0  阅读原文

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

EOS Currency合约部署案例分析

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: EOS5MSkE5DGgSurc7k3Sv9kWrev6E3GBBqasdiiC3yajPwrW7c4Uq liyuechun:cleos yuechunli$ ./cleos create key Private key: 5Kg2P7PRA7wWrW2s53JiaBur7PhDtDsCMZUwQ8Yvn8uAmu8xEMB Public key: EOS7wERhooVJwqYLuQn5v6UDZnL5KQpGJBDMQoktkxz4baNzicwLX liyuechun: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 }

声明:链世界登载此文仅出于分享区块链知识,并不意味着赞同其观点或证实其描述。文章内容仅供参考,不构成投资建议。投资者据此操作,风险自担。此文如侵犯到您的合法权益,请联系我们100@7234.cn

    参与讨论 (0 人参与讨论)

    相关推荐

    区块链投资趋势报告:巨头入场布局行业趋于成熟

    区块链投资趋势报告:巨头入场布局行业趋于成熟

    来自:https://mp.weixin.qq.com/s?__biz=MzI4NzIxOTY1NA==&amp;mid=2650632639&amp;idx=1&amp;sn=e6d1c29731d992a80410aaee82ec3ea6&amp;chksm=f3d8db16c4af520097e4a64a71b1d4743ac326b9f027

    重新发明货币

    重新发明货币

    一、货币的演化过程 先简单回顾一下人类货币的演化过程,大概有以下阶段: a. 1.0版本:自然货币(贝壳、牲口、金银……) 这个阶段,货币基于一般等价物的稀有性或者实用性,货币不可能出现人为操纵的超发。 b. 2.0版本:早期纸币、银票到本位纸币 当贸易量越来越大,实物货币太不方便了,而且大家发现其实并不在意货币本身有什么价值,在意的只是这么多的货币能不能交换到足够的物品,于是纸币这种信用货

    从比特币交易看欧洲央行虚拟货币分类

    从比特币交易看欧洲央行虚拟货币分类

      互联网对传统社会的颠覆从未停止,在其完成对信息流、商流、物流、资金流的初步改造之后,或将以虚拟货币的形式打破现有货币体系   4月18日,在中国极客张沈鹏创办的比特币交易平台(42BTC.com)上,比特币对人民币的平均交易价为576元。当天,该平台完成了100个比特币的交易量。仅仅过去一周,4月25日上午,比特币对人民币的平均交易价已达到906元。据42BTC网站统计:在过去的32个月

    欧洲央行-比特币报告

    3.1 比特币 3.1.1 基本特征          比特币可能是最成功的,也可能是最有争议的虚拟货币方案,由日本程序员中本聪(译者注:事实上,中本聪是不是日本人,甚至是不是单个人无从考证)在2009年设计并实现。该计划基于一个类似于BitTorrent的P2P网络。BitTorrent是互联网上著名的共享文件协议,应用在电影,游戏和音乐领域。比特币在全球层面上运作,可用于各类货币交易(虚

    彻底玩转比特币地址和私匙

    彻底玩转比特币地址和私匙

    比特币地址和私匙是所有比特币初学者面对的一大难题,再加上那一串超长的字符串,让人更是摸不到头脑。 现在编者以问答的形式,带你一步步的揭开比特币地址和私匙的面纱。 还不知道什么是比特币地址和私匙的同学请点这里 问题一、比特币钱包由什么组成? 答 我们知道,比特币地址和私匙组成了比特币钱包,而私匙则决定了比特币地址上比特币的归属。 地址和私匙 问题二、如果只记得私匙我们还能还原比特币地址么? 答

    用GO语言实现比特币算法

    用GO语言实现比特币算法

    本节的这个例子展示一点点高精度数学包math/big、一点点散列包hash、一点点加密包crypto,还有一点点测试包testing的知识。这里不介绍bitcoin协议和算法——尽管它们很有趣,而是试图指出,Go对多种操作系统的支持,是实现这种跨平台应用的理想语言。 位钱(bitcoin)是一种使用加密手段制作的分布式电子货币。它最初于1998年由Wei Dai提出,并由中本聪(Satoshi

    详解比特币的找零机制

    详解比特币的找零机制

    比特币的找零机制一直让人有些迷惑,明明只向一个地址发送了比特币为什么 blockchain 上面的显示的有时是1个地址对多个地址,有时是多个地址对1个地址,有时又显示多个地址对多个地址? 为什么比特币资深用户要提醒大家当比特币钱包交易100次以上时再次交易后要重新备份钱包,恢复以前的钱包备份有可能会遭遇损失? 是的,这一切都是因为比特币的找零(Change)机制。本文参考 Bitcoin的维

    玩转比特币客户端之一:C盘转移和加速下载

    玩转比特币客户端之一:C盘转移和加速下载

    C盘空间不足?交易数据下载速度太慢?别着急,乐享比特币教你轻松玩转比特币官方客户端。 所有新人开始接触比特币时做的第一件事情大多数是安装比特币的官方客户端。 安全起见大家最好直接访问官方发布渠道sourceforge的地址进行下载:http://sourceforge.net/projects/bitcoin/files/Bitcoin/ 该网页列出了各版本的官方比特币客户端,目前

    麦妖榜
    更新日期 2019-01-16
    排名用户贡献值
    1等待的宿命23695
    2BitettFan23632
    3六叶树20309
    4天下无双16192
    5lizhen00214782
    6区块大康14461
    7让时间淡忘14188
    8冷风大q11188
    9momo11174
    10linjm122710562
    返回顶部 ↑