美文网首页
发行代币合约

发行代币合约

作者: 树哥区块链 | 来源:发表于2019-03-31 17:53 被阅读0次

    发布发布代币合约:

    {"jsonrpc":"2.0","id":"curltext","method":"registercontracttx","params":["wfbZmzbFKKupgZKUGFzePbPEhd6BVuXbjk","/tmp/lua/mycoin.lua",110000000]}

    得到代币合约的哈希值

    {

        "result": {

            "hash": "921032776f7620c6bfbe48ce30a31b22893e279240407a8eedde7eace2d8aeaa"

        },

        "error": null,

        "id": "curltext"

    }

    然后通过哈希值得到合约的注册ID:

    {"jsonrpc":"2.0","id":"curltext","method":"getcontractregid","params":["921032776f7620c6bfbe48ce30a31b22893e279240407a8eedde7eace2d8aeaa"]}

    通过账户余额

    {"jsonrpc":"2.0","id":"curltext","method":"getcontractaccountinfo","params":["155693-1","wfbZmzbFKKupgZKUGFzePbPEhd6BVuXbjk"]}

    调用智能合约:

    {"jsonrpc":"2.0","id":"curltext","method":"callcontracttx","params":["wfbZmzbFKKupgZKUGFzePbPEhd6BVuXbjk","155693-1",0,"f0110000",1000000]}

    得到哈希值:

    {

        "result": {

            "hash": "c8add466e8d1cf0293b4a191686353cd02812540226c1a7ea2f4796cbecac76b"

        },

        "error": null,

        "id": "curltext"

    }

    得到合约的参数,此次为合约所有人

    {"jsonrpc":"2.0","id":"curltext","method":"getcontractdata","params":["155693-1","owner"]}

    {

        "result": {

            "regid": "155693-1",

            "key": "owner",

            "value": "wMV7S7YN4c6r1hLPXRJuSFoYkJ2Fu7PEAN"

        },

        "error": null,

        "id": "curltext"

    }

    查询合约地址代币数量

    {"jsonrpc":"2.0","id":"curltext","method":"getcontractaccountinfo","params":["155693-1","wMV7S7YN4c6r1hLPXRJuSFoYkJ2Fu7PEAN"]}

    结果为最初设定的2100万枚。

    调用合约转账:

    {"jsonrpc":"2.0","id":"curltext","method":"callcontracttx","params":["wMV7S7YN4c6r1hLPXRJuSFoYkJ2Fu7PEAN","155693-1",0,"f0160000774e5057717639627646436e4d6d3164646951644837665577556b3251677273324e0010a5d4e8000000",1000000]}

    得到转账哈希值:

    {

        "result": {

            "hash": "85fb72c139a53e2f07798c64cf9761d60f26c383c884b4e3345b7ba8121f3237"

        },

        "error": null,

        "id": "curltext"

    }

    查询转账结果:

    {"jsonrpc":"2.0","id":"curltext","method":"getcontractaccountinfo","params":["155693-1","wMV7S7YN4c6r1hLPXRJuSFoYkJ2Fu7PEAN"]}

    得到结果:

    但是,接受账户中,没有token余额,如下图:

    通过哈希值查询,发现转移的是WICC,而非token。

    原因是转账的地址是如下:(见转账参数)

    通过地址转化为真实的地址。

    通过这个真实地址查询得到转账数值:

    相关文章

      网友评论

          本文标题:发行代币合约

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