[EOS]交易所存币取币

参考

参考 https://github.com/EOSIO/eos/wiki/Tutorial-Exchange-Deposit-Withdraw,为保证运行,适当改动。

创建对应帐号

如创建可忽略。

$ cleos create account eosio exchange EOS8UCi6r82EvzxKd5KFv3um3fnfaczqZ5aWT6L4zb9ZkHGQUkVkV EOS5Kth7yY94SHU54X7dvpUnthrfnRwgWSDBsdbuYPyEAbczdxRss
executed transaction: fb57d98d11fe1d88cc6e768b3c2da00dccabce67d35df624efec9230bc2981a0  200 bytes  262 us
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"exchange","owner":{"threshold":1,"keys":[{"key":"EOS8UCi6r82EvzxKd5KFv3um...
warning: transaction executed locally, but may not be confirmed by the network yet

$ cleos get accounts EOS8UCi6r82EvzxKd5KFv3um3fnfaczqZ5aWT6L4zb9ZkHGQUkVkV
{
  "account_names": [
    "eosio.msig",
    "eosio.token",
    "exchange",
    "producernde1",
    "tester",
    "user"
  ]
}

加载exchange合约

$ cleos set contract exchange build/contracts/exchange -p exchange
Reading WAST/WASM from build/contracts/exchange/exchange.wasm...
Using already assembled WASM...
Publishing contract...
executed transaction: 80c65c29b98b9f77d90e1dbc0895325646014a3e1862d859440e3866c3239ad9  33904 bytes  4307 us
#         eosio <= eosio::setcode               {"account":"exchange","vmtype":0,"vmversion":0,"code":"0061736d0100000001bb022f60067f7e7f7f7f7f00600...
#         eosio <= eosio::setabi                {"account":"exchange","abi":"0e656f73696f3a3a6162692f312e30010c6163636f756e745f6e616d65046e616d650e0...
warning: transaction executed locally, but may not be confirmed by the network yet

从tester账户存款到交易所

$ cleos get currency balance eosio.token tester SYS
25.0000 SYS
$ cleos get currency balance eosio.token exchange SYS
$ cleos transfer tester exchange "1.0000 SYS" deposit
executed transaction: 1ce445a3e401d5c658126a7cfdcf0c1402b63b830e16e966e99751d0ed8e976d  136 bytes  1029 us
#   eosio.token <= eosio.token::transfer        {"from":"tester","to":"exchange","quantity":"1.0000 SYS","memo":"deposit"}
#        tester <= eosio.token::transfer        {"from":"tester","to":"exchange","quantity":"1.0000 SYS","memo":"deposit"}
#      exchange <= eosio.token::transfer        {"from":"tester","to":"exchange","quantity":"1.0000 SYS","memo":"deposit"}
warning: transaction executed locally, but may not be confirmed by the network yet
$ cleos get currency balance eosio.token tester SYS
24.0000 SYS
$ cleos get currency balance eosio.token exchange SYS
1.0000 SYS

没余额时,啥都不输出,真没礼貌。

查看交易记录

从以上余额变动情况,可以确认转账都是成功的。
不过查询交易记录时,可能不会有结果:

$ cleos get actions tester

原因是eos为节约内存,默认已经不记录这些日志,需要配置一下才可以看到。


配置插件

过滤账户

配置完后,第一次使用--replay选项启动,之后就不用了。

nodeos -e -p eosio --replay

交易记录有如下输出

 cleos -u http://localhost:8888 get actions tester
#  seq  when                              contract::action => receiver      trx id...   args
================================================================================================================
#    0   2018-06-01T03:58:00.500     eosio.token::transfer => tester        e050a5e8... {"from":"user","to":"tester","quantity":"25.0000 SYS","memo"...
#    1   2018-06-04T03:11:29.000     eosio.token::transfer => eosio.token   1ce445a3... {"from":"tester","to":"exchange","quantity":"1.0000 SYS","me...
#    2   2018-06-04T03:11:29.000     eosio.token::transfer => tester        1ce445a3... {"from":"tester","to":"exchange","quantity":"1.0000 SYS","me...
#    3   2018-06-04T03:11:29.000     eosio.token::transfer => exchange      1ce445a3... {"from":"tester","to":"exchange","quantity":"1.0000 SYS","me...

你可能感兴趣的:([EOS]交易所存币取币)