风险提示:理性看待区块链,提高风险意识!
EOS Currency合约部署案例分析
首页 > 币界资讯 > 区块链知识 2018-04-18 07:04
摘要
切换到eos/build/programs/cleos路径下面。1. 钱包设置秘钥需要保存好,后面解锁时会用到。liyuechun:cleos yuechunli$ ./cleos wallet createCreating wallet: defaultSave password to use i 。
币界网报道:

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

eos contract

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
}
发表评论
发表评论
暂无评论
    相关阅读
    一位备受关注的分析师认为,模因代币Floki(Floki)正在为反弹做准备,并有望创下历史新高(ATH)。
    区块链
    2025-01-08 07:45:59
    Ripple的一项新预测已经曝光,预测该代币将大幅上涨470%。XRP能再次创造历史吗?
    区块链
    2025-01-08 05:02:11
    CFTC指控Gemini提供了关于比特币价格操纵保护措施的不准确数据,但该加密货币公司否认了这一指控。
    比特币
    2025-01-08 04:39:20
    比特币btc01月07日行分析#btc#比特币
    比特币
    2025-01-07 23:31:44
    比特币的价格终于回升至10万美元以上,但尚未创下新的历史新高。然而,从目前的价格走势来看
    比特币
    2025-01-07 22:39:48
    推荐专栏
    Boss Wallet Web3 Econom Pass
    Fully On-Chain & AI-Powered Meme Trading | #Xbit #DEX #Web3 | English: @XBITDEX | Chinese 华语 : @XBITDEX_ZH | Support: @XbitHelpDesk
    一位相信价值投资的币圈KOL。稳定盈利的缠论野生交易员 #BTC行情分析师 #价值投资 #链上数据分析
    爱Web 3,爱生活,爱科技,爱炒币的老韭菜
    热门币种
    更多
    币种
    美元价格
    24H涨跌幅
    BTC比特币
    60,963.61 USDT
    ¥435,103.38
    -2.72%
    ETH以太坊
    3,368.69 USDT
    ¥24,042.67
    -0.3%
    BNB币安币
    570.68 USDT
    ¥4,073.00
    -0.28%
    USDT泰达币
    1.02 USDT
    ¥7.25
    -0.19%
    SOL
    135.96 USDT
    ¥970.36
    +7.66%
    USDC
    1.00 USDT
    ¥7.15
    -0.01%
    TON
    7.59 USDT
    ¥54.14
    +4.55%
    XRP瑞波币
    0.47720 USDT
    ¥3.41
    +0.48%
    DOGE狗狗币
    0.12210 USDT
    ¥0.87140
    +2.43%
    ADA艾达币
    0.39050 USDT
    ¥2.79
    +3.88%
    热搜币种
    更多
    币种
    美元价格
    24H涨跌幅
    狗狗币
    0.3541 USDT
    ¥2.59
    -9.65%
    Filecoin
    5.3381 USDT
    ¥39.11
    -10.48%
    比特币
    96512.03 USDT
    ¥707,090.56
    -5.13%
    Gatechain Token
    17.9689 USDT
    ¥131.65
    -2.85%
    Horizen
    23.2652 USDT
    ¥170.45
    -17.39%
    dYdX
    1.4038 USDT
    ¥10.28
    -13.8%
    Solana
    198.71 USDT
    ¥1,455.84
    -8.68%
    柚子
    0.814 USDT
    ¥5.96
    -10.6%
    Shiba Inu
    2.174E-5 USDT
    ¥0.00
    -9.45%
    艾达币
    0.998 USDT
    ¥7.31
    -8.29%
    FTX Token
    2.9131 USDT
    ¥21.34
    -13.97%
    火币积分
    0.9291 USDT
    ¥6.81
    -29.01%
    最新快讯
    更多
    美国现货比特币ETF昨日净流入5346万美元
    2025-01-08 12:00:02
    昨日美国比特币现货ETF净流入5348万美元
    2025-01-08 11:59:02
    CertiKAlert:7天前部署的IPC代币存在漏洞,黑客通过闪电贷保护机制盗取约59万美元
    2025-01-08 11:58:42
    IREN:2024全年比特币挖矿产出达3984枚BTC
    2025-01-08 11:57:41
    昨日贝莱德IBIT净流入5.9718亿美元,交易量达31亿美元
    2025-01-08 11:54:57
    IPC代币疑遭攻击,损失约59万美元
    2025-01-08 11:53:10
    NOWPayments:比特币达到10万美元里程碑后,商家加密支付激增8%
    2025-01-08 11:53:03