美文网首页EOS开发系列程序员EOS技术
区块链技术EOS开发系列之eosc使用

区块链技术EOS开发系列之eosc使用

作者: 菠菜期权 | 来源:发表于2017-07-30 19:53 被阅读3433次

    eosc就是eos command的缩写,就是eos的命令行工具,类似bitcoin-cli,

    该命令源代码可以从https://github.com/EOSIO/eos/tree/master/programs/eosc 查看,

    大家可以通过一下方式跟踪关注我:

    github:https://github.com/philsong

    微博:http://weibo.com/bocaicfa

    本文是EOS技术研究系列的第二篇。

    第一篇.Mac下的编译:http://www.jianshu.com/p/f26ee4cf1d4a

    第二篇.eosc命令行工具:http://www.jianshu.com/p/b2db966435d0

    准备工作:

    在此之前在data-dir/config.ini需要添加plugin = eos::chain_api_plugin的支持,然后启动eosd

    转账图

    使用如下:

    /**

    *  Usage:

    *

    *  eocs create wallet walletname  ***PASS1*** ***PASS2***

    *  eosc unlock walletname  ***PASSWORD***

    *  eosc wallets -> prints list of wallets with * next to currently unlocked

    *  eosc keys -> prints list of private keys

    *  eosc importkey privatekey -> loads keys

    *  eosc accounts -> prints list of accounts that reference key

    *  eosc lock

    *  eosc do contract action { from to amount }

    *  eosc transfer from to amount memo  => aliaze for eosc

    *  eosc create account creator

    */

    由于eos还在开发阶段,实测目前为止已经(只)支持如下几个命令:

    1. 查看eosd信息:

    ➜  programs git:(master) ./eosc/eosc info

    {

    "head_block_num": 902,

    "last_irreversible_block_num": 885,

    "head_block_id": "000003863abf62f265dc9b90201e77b24e34324e2a8e963e82bd11149c51b9d6",

    "head_block_time": "2017-07-30T11:34:27",

    "head_block_producer": "inito",

    "recent_slots": "0000000000000000000000000000000000000000000000000000000000000011",

    "participation_rate": "0.03125000000000000"

    }

    2. 查看某个account账户的信息

    ➜  programs git:(master) ./eosc/eosc account inita

    {

    "name": "inita",

    "eos_balance": "100000000000000",

    "staked_balance": 0,

    "unstaking_balance": 0,

    "last_unstaking_time": "1969-12-31T23:59:59"

    }

    3.创建一对公私钥

    ➜  programs git:(master) ./eosc/eosc create key

    public: EOS86Qw3qb25CzWYhk2ZLSD2G8nHc6YMkqQVymMazUHN9Ti7vJvrz

    private: 5JrFC9S9dzdjMHcUSJ18n8cchc1jaYPrQ4zdE1irXAa7qPKxH1u

    4.查看区块信息

    ➜  programs git:(master) ./eosc/eosc block 1

    {

    "previous": "0000000000000000000000000000000000000000000000000000000000000000",

    "timestamp": "2017-07-30T03:55:03",

    "transaction_merkle_root": "0000000000000000000000000000000000000000000000000000000000000000",

    "producer": "initj",

    "producer_changes": [],

    "producer_signature": "1f12691e30bb47b47f47697a4b79cb38ef215196b950d7dc9fc8c050dacd78cd5b7f31055c37983e3b992b567d4aec3f4abe9c389e26a70afdc843862d9d83ea02",

    "cycles": [],

    "id": "0000000163980e90c736fed9ec75a5b76458ed28e6d44fe68247b0f68488b36d",

    "block_num": 1,

    "refBlockPrefix": 3657316039

    }

    5.转账命令

    ➜  programs git:(master) ./eosc/eosc transfer inita initb 9

    {

    "transaction_id": "5294319392180bb27ef99ff7454abd096dec02c791266261ebc73db2eed2cbea",

    "processed": {

    "refBlockNum": "1233",

    "refBlockPrefix": "2923796072",

    "expiration": "2017-07-30T11:53:37",

    "scope": [

    "inita",

    "initb"

    ],

    "signatures": [],

    "authorizations": [{

    "account": "inita",

    "permission": "active"

    }

    ],

    "messages": [{

    "code": "eos",

    "type": "transfer",

    "data": {

    "from": "inita",

    "to": "initb",

    "amount": 9

    },

    "hex_data": "000000008040934b000000000041934b0900000000000000"

    }

    ],

    "output": [{

    "notify": [{

    "name": "initb",

    "output": {

    "notify": [],

    "sync_transactions": [],

    "async_transactions": []

    }

    },{

    "name": "inita",

    "output": {

    "notify": [],

    "sync_transactions": [],

    "async_transactions": []

    }

    }

    ],

    "sync_transactions": [],

    "async_transactions": []

    }

    ]

    }

    }

    转账之后重新查询余额

    ➜  programs git:(master) ./eosc/eosc account initb

    {

    "name": "initb",

    "eos_balance": "100000000000009",

    "staked_balance": 0,

    "unstaking_balance": 0,

    "last_unstaking_time": "1969-12-31T23:59:59"

    }

    ➜  programs git:(master) ./eosc/eosc account inita

    {

    "name": "inita",

    "eos_balance": "99999999999990",

    "staked_balance": 0,

    "unstaking_balance": 0,

    "last_unstaking_time": "1969-12-31T23:59:59"

    }

    可以发现inita少了10个(怎么多了一个,是fee?),initb多了9个。

    6.创建一个新账号。

    usage: ./eosc/eosc create account CREATOR NEWACCOUNT OWNERKEY ACTIVEKEY

    我们利用命令创建2个key

    ➜  programs git:(master) ./eosc/eosc create key

    public: EOS5MW14wMzpWhJ442i1fy2hiFAzTzMeNED7krepABcNKGVUs2XLU

    private: 5HsWb6jen3sKcRhxbayoaB2yN4gb395EsQG9A3k23WekSDQK6Mr

    ➜  programs git:(master) ./eosc/eosc create key

    public: EOS7Buw6kLUy1fMz71gFbQ9mmv9EzjJ86DmkpLVmi9cjC5nj9j1YW

    private: 5JW88NELbEjPM3i5aYMZ1izsaZTeRXstN9o7TxoCUmhgowfYyii

    然后创建一个xxx账号,创建者是inita

    ➜  programs git:(master) ./eosc/eosc create account inita xxx EOS5MW14wMzpWhJ442i1fy2hiFAzTzMeNED7krepABcNKGVUs2XLU EOS7Buw6kLUy1fMz71gFbQ9mmv9EzjJ86DmkpLVmi9cjC5nj9j1YW

    {

    "transaction_id": "fb9418cf3fe677be7565f6efc16891fac45543ba9bc044bf97d88a2ceb631a76",

    "processed": {

    "refBlockNum": "1424",

    "refBlockPrefix": "2862183818",

    "expiration": "2017-07-30T12:03:10",

    "scope": [

    "eos",

    "inita"

    ],

    "signatures": [],

    "authorizations": [{

    "account": "inita",

    "permission": "active"

    }

    ],

    "messages": [{

    "code": "eos",

    "type": "newaccount",

    "data": "000000008040934b00000000000030c60100000001023d550a1207c79aa6eb8bf48ae0c1fcb434d8212c7b58178c5d18840429caa4a70100000100000001032ef47d9508b1c9e7d8bb85b8d4fae9246ffee8c54cc563c39dfec1b0e270d9dd010000010000000001000000008040934b00000000149be8080100010000000000000008454f5300000000"

    }

    ],

    "output": [{

    "notify": [],

    "sync_transactions": [],

    "async_transactions": []

    }

    ]

    }

    }

    7.

    ➜  programs git:(master) ✗ ./eosc/eosc setcode currency ../../contracts/currency/currency.wast ../../contracts/currency/currency.abi

    ../../contracts/currency/currency.wast{

    "transaction_id": "1b7f638377ce8f13b1d83fd6b9ca18cd28f91bc3436525e6ba3804f0547b1a1b",

    "processed": {

    "refBlockNum": "12125",

    "refBlockPrefix": "2222548827",

    "expiration": "2017-08-07T14:01:58",

    "scope": [

    "currency",

    "eos"

    ],

    "signatures": [],

    "authorizations": [{

    "account": "currency",

    "permission": "active"

    }

    ],

    "messages": [{

    "code": "eos",

    "type": "setcode",

    "data": "00000079b822651d0000dc120061736d0100000001390a60037e7e7e017f60047e7e7f7f017f60017e0060057e7e7e7f7f017f60027f7f0060027f7f017f60027e7f0060017f0060000060027e7e0002760703656e7606617373657274000403656e76086c6f61645f693634000303656e760b726561644d657373616765000503656e760a72656d6f76655f693634000003656e760b7265717569726541757468000203656e760d726571756972654e6f74696365000203656e760973746f72655f6936340001030504060708090404017000000503010001077e05066d656d6f727902002a5f5a4e3863757272656e6379313273746f72654163636f756e744579524b4e535f374163636f756e74450007355f5a4e3863757272656e637932336170706c795f63757272656e63795f7472616e7366657245524b4e535f385472616e7366657245000804696e69740009056170706c79000a0abe0c043700024020012903084200510d0020004280808080a8d7bee3082001411010061a0f0b20004280808080a8d7bee308200129030010031a0bc50504017e027f047e017f4100410028020441206b2208360204200029030021052000290308100520051005200029030010042000290300210142002105423b2104411021034200210603400240024002400240024020054206560d0020032c00002202419f7f6a41ff017141194b0d01200241a0016a21020c020b420021072005420b580d020c030b200241ea016a41002002414f6a41ff01714105491b21020b2002ad42388642388721070b2007421f83200442ffffffff0f838621070b200341016a2103200542017c2105200720068421062004427b7c2204427a520d000b420021052008420037031820082006370310200142808080c887d7c8b21d4280808080a8d7bee308200841106a411010011a200041086a2903002101423b2104411021034200210603400240024002400240024020054206560d0020032c00002202419f7f6a41ff017141194b0d01200241a0016a21020c020b420021072005420b580d020c030b200241ea016a41002002414f6a41ff01714105491b21020b2002ad42388642388721070b2007421f83200442ffffffff0f838621070b200341016a2103200542017c2105200720068421062004427b7c2204427a520d000b2008200637030020084200370308200142808080c887d7c8b21d4280808080a8d7bee3082008411010011a200841186a220329030020002903105a4120100020032003290300200029031022057d370300200520082903087c20055a41d00010002008200829030820002903107c370308200029030021050240024020032903004200510d0020054280808080a8d7bee308200841106a411010061a0c010b20054280808080a8d7bee308200829031010031a0b200041086a290300210502400240200841086a2903004200510d0020054280808080a8d7bee3082008411010061a0c010b20054280808080a8d7bee308200829030010031a0b4100200841206a3602040b970303027f057e017f4100410028020441106b220736020442002103423b210241800121014200210403400240024002400240024020034207560d0020012c00002200419f7f6a41ff017141194b0d01200041a0016a21000c020b420021052003420b580d020c030b200041ea016a41002000414f6a41ff01714105491b21000b2000ad42388642388721050b2005421f83200242ffffffff0f838621050b200141016a2101200342017c2103200520048421042002427b7c2202427a520d000b42002103423b2102411021014200210603400240024002400240024020034206560d0020012c00002200419f7f6a41ff017141194b0d01200041a0016a21000c020b420021052003420b580d020c030b200041ea016a41002000414f6a41ff01714105491b21000b2000ad42388642388721050b2005421f83200242ffffffff0f838621050b200141016a2101200342017c2103200520068421062002427b7c2202427a520d000b2007428094ebdc033703082007200637030020044280808080a8d7bee3082007411010061a4100200741106a3602040ba30303027f047e017f4100410028020441206b220836020442002105423b210441800121034200210603400240024002400240024020054207560d0020032c00002202419f7f6a41ff017141194b0d01200241a0016a21020c020b420021072005420b580d020c030b200241ea016a41002002414f6a41ff01714105491b21020b2002ad42388642388721070b2007421f83200442ffffffff0f838621070b200341016a2103200542017c2105200720068421062004427b7c2204427a520d000b024020062000520d0042002105423b210441900121034200210603400240024002400240024020054207560d0020032c00002202419f7f6a41ff017141194b0d01200241a0016a21020c020b420021072005420b580d020c030b200241ea016a41002002414f6a41ff01714105491b21020b2002ad42388642388721070b2007421f83200442ffffffff0f838621070b200341016a2103200542017c2105200720068421062004427b7c2204427a520d000b20062001520d0020084200370318200841086a4118100241174b41a0011000200841086a10080b4100200841206a3602040b0bb601070041040b04c00400000041100b086163636f756e74000041200b2c696e746567657220756e646572666c6f77207375627472616374696e6720746f6b656e2062616c616e6365000041d0000b26696e7465676572206f766572666c6f7720616464696e6720746f6b656e2062616c616e636500004180010b0963757272656e637900004190010b097472616e73666572000041a0010b1e6d6573736167652073686f72746572207468616e20657870656374656400009202046e616d650b06617373657274020000086c6f61645f6936340500000000000b726561644d6573736167650200000a72656d6f76655f693634030000000b726571756972654175746801000d726571756972654e6f7469636501000973746f72655f69363404000000002a5f5a4e3863757272656e6379313273746f72654163636f756e744579524b4e535f374163636f756e74450201300131355f5a4e3863757272656e637932336170706c795f63757272656e63795f7472616e7366657245524b4e535f385472616e73666572450901300131013201330134013501360137013804696e69740801300131013201330134013501360137056170706c7909013001310132013301340135013601370138010b4163636f756e744e616d65044e616d6502087472616e7366657200030466726f6d0b4163636f756e744e616d6502746f0b4163636f756e744e616d6506616d6f756e740655496e743634076163636f756e740002036b65790655496e7436340762616c616e63650655496e74363401000000b298e982a4087472616e736665720100000080bafac608076163636f756e74"

    }

    ],

    "output": [{

    "notify": [],

    "sync_transactions": [],

    "async_transactions": []

    }

    ]

    }

    }

    更多文档:https://eosio.github.io/eos/group__contractdev.html

    https://eosio.github.io/eos/group__eosc.html

    更多命令可以查看https://github.com/EOSIO/eos/tree/master/programs/eosc

    over!


    区块链技术EOS开发系列之eosc使用

    相关文章

      网友评论

      本文标题:区块链技术EOS开发系列之eosc使用

      本文链接:https://www.haomeiwen.com/subject/hwyklxtx.html