eosiopowncoin 合约开箱

源码下载和合约生成

git clone https://github.com/NedAmarril/eosiopowcoin cd eosiopowcoin eosio-cpp -I . eosiopowcoin.cpp –abigen

可以生成 eosiopowcoin.wasm 和 eosiopowcoin.abi 。 其实我觉得一个合约仓库代码可以把这两个文件直接加入 git 仓库。可以让别人不需要再去安装 eosio-cpp , 不过如果直接使用编译好的 wasm ,说不定有被植入后门啥的。只是测试的话可以,如果要上主网的话,还是风险太高了。

eosiopowcoin 合约特点

eosiopowcoin 是我目前看到的最有亮点的EOS合约了, 把比特币的 POW 理念运用得很好,同时借用 EOS 上的 CPU 算力来进行挖矿。很优雅的方式。后面会详细阅读源码。

先简单理解就是转账给这个合约账号后,转出的代币会被完整退还,并且同时会附带回赠一些 POW 代币。 所以大家会拼命转账去赚取 POW 代币,至于有多拼命,就要看每个人自己的 EOS 抵押 CPU 的资源了。 这就是 转账挖矿 的说法缘由。

eosiopowcoin 合约用法

准备一个测试网账号,来承载这个合约。这次选用 rplmnxyrvggo 这个账号。

首先第一个事情就是先买内存,毕竟合约消耗的就是内存。内存不足则会上传合约失败。

cleos -u https://api.testnet.eos.io system buyram rplmnxyrvggo rplmnxyrvggo "10 TNT" -p rplmnxy
rvggo@owner
executed transaction: ff25f2c14c05f32441d400a44ef7f7d4048bd84429421fa4b07ce23f28f92d70  128 bytes  608 us
#         eosio <= eosio::buyram                {"payer":"rplmnxyrvggo","receiver":"rplmnxyrvggo","quant":"10.0000 TNT"}
#   eosio.token <= eosio.token::transfer        {"from":"rplmnxyrvggo","to":"eosio.ram","quantity":"9.9500 TNT","memo":"buy ram"}
#  rplmnxyrvggo <= eosio.token::transfer        {"from":"rplmnxyrvggo","to":"eosio.ram","quantity":"9.9500 TNT","memo":"buy ram"}
#     eosio.ram <= eosio.token::transfer        {"from":"rplmnxyrvggo","to":"eosio.ram","quantity":"9.9500 TNT","memo":"buy ram"}
#   eosio.token <= eosio.token::transfer        {"from":"rplmnxyrvggo","to":"eosio.ramfee","quantity":"0.0500 TNT","memo":"ram fee"}
#  rplmnxyrvggo <= eosio.token::transfer        {"from":"rplmnxyrvggo","to":"eosio.ramfee","quantity":"0.0500 TNT","memo":"ram fee"}
#  eosio.ramfee <= eosio.token::transfer        {"from":"rplmnxyrvggo","to":"eosio.ramfee","quantity":"0.0500 TNT","memo":"ram fee"}>>>>>>>
cleos -u https://api.testnet.eos.io set contract rplmnxyrvggo ./ eosiopowcoin.wasm eosiopowcoin.abi -p rplmnxyrvggo@owner
Reading WASM from /home/yanyiwu/eosiopowcoin.wasm...
Publishing contract...
executed transaction: 5fc2504f458e5063770e03da32bf1263ca8bf252cd5605888095aae741a26e9b  11096 bytes  1692 us
#         eosio <= eosio::setcode               {"account":"rplmnxyrvggo","vmtype":0,"vmversion":0,"code":"0061736d0100000001ae011d60000060017e00600...
#         eosio <= eosio::setabi                {"account":"rplmnxyrvggo","abi":"0e656f73696f3a3a6162692f312e310009076163636f756e7400010762616c616e6...}>"}>

转载请注明出处: EOS命令行智能合约部署