美文网首页
2019-03-15 ewasm在以太坊私有链测试(2)

2019-03-15 ewasm在以太坊私有链测试(2)

作者: oracle3 | 来源:发表于2019-03-15 17:05 被阅读0次

    参考2018-11-26 ewasm在以太坊私有链测试
    2019-03-14 通过rpc发布和调用以太坊合约
    我们也使用rpc来发布ewasm合约

    1、发布合约

    {
        "jsonrpc": "2.0",
        "id": 171,
        "method": "eth_sendTransaction",
        "params": [
            {
                "data": "0x0061736d0100000001090260027f7f0060000002130108657468657265756d0666696e6973680000030201010503010064071102066d656d6f72790200046d61696e00010a0b010900410041dc0110000b0be301010041000bdc010061736d01000000011e0760027f7f006000017e60000060017e0060027f7f006000017e60017e00025c0408657468657265756d0c73746f7261676553746f7265000408657468657265756d0b73746f726167654c6f6164000408657468657265756d0e676574426c6f636b4e756d626572000508657468657265756d067573654761730006030201020503010001071102046d61696e0004066d656d6f727902000a380136004213100341800441d80036020041800841e3003602004120100237030041800441201000418004418010100141800841801010000b",
                "from": "0xea22f69e45d10287ad90e4c184c5ffcfbde151b6",
                "gas": "0x773594",
                "value": "0x3e8"
            }
        ]
    }
    

    返回

    {
        "jsonrpc": "2.0",
        "id": 171,
        "result": "0xa5ccd7a56bf8c63937492305894db71963ba653ceefe6efd2f018feba7f30072"
    }
    

    查询:

    {
        "jsonrpc": "2.0",
        "id": 2192787296,
        "method": "eth_getTransactionReceipt",
        "params": [
            "0xa5ccd7a56bf8c63937492305894db71963ba653ceefe6efd2f018feba7f30072"
        ]
    }
    

    返回:

    {
        "jsonrpc": "2.0",
        "id": 2192787296,
        "result": {
            "blockHash": "0xa41270f428899fab3719a67106b9734e58015d236fc5202fb77a073a3a99c68c",
            "blockNumber": "0x2a0",
            "contractAddress": "0xf958a7ef4b49289a9b3c4a4979db6d9110af5c9d",
            "cumulativeGasUsed": "0x1d3b8",
            "from": "0xea22f69e45d10287ad90e4c184c5ffcfbde151b6",
            "gasUsed": "0x1d3b8",
            "logs": [],
            "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
            "status": "0x1",
            "to": null,
            "transactionHash": "0xa5ccd7a56bf8c63937492305894db71963ba653ceefe6efd2f018feba7f30072",
            "transactionIndex": "0x0"
        }
    }
    

    获得合约地址:0xf958a7ef4b49289a9b3c4a4979db6d9110af5c9d

    在geth终端检查code:

    eth.getCode("0xf958a7ef4b49289a9b3c4a4979db6d9110af5c9d")
    
    "0x0061736d01000000011e0760027f7f006000017e60000060017e0060027f7f006000017e60017e00026e0508657468657265756d0c73746f7261676553746f7265000408657468657265756d0b73746f726167654c6f6164000408657468657265756d0e676574426c6f636b4e756d626572000508657468657265756d06757365476173000608657468657265756d067573654761730003030201020503010001071102046d61696e0005066d656d6f727902000a3c013a00421510044213100341800441d80036020041800841e3003602004120100237030041800441201000418004418010100141800841801010000b"
    

    2、调用合约

    {
        "jsonrpc": "2.0",
        "id": 171,
        "method": "eth_sendTransaction",
        "params": [
            {
                "data": "",
                "from": "0xea22f69e45d10287ad90e4c184c5ffcfbde151b6",
                "to": "0xf958a7ef4b49289a9b3c4a4979db6d9110af5c9d",
                "gas": "0x773594",
                "value": "0x3e8"
            }
        ]
    }
    

    返回

    {
        "jsonrpc": "2.0",
        "id": 171,
        "result": "0x44aa45ea81508d4b417099e4a5b971973e1a2bb58e9a9174ed815bd626f4473b"
    }
    

    查询

    {
        "jsonrpc": "2.0",
        "id": 2192787296,
        "method": "eth_getTransactionReceipt",
        "params": [
            "0x44aa45ea81508d4b417099e4a5b971973e1a2bb58e9a9174ed815bd626f4473b"
        ]
    }
    

    返回:

    {
        "jsonrpc": "2.0",
        "id": 2192787296,
        "result": {
            "blockHash": "0x490a13f593ee4cf30f40527634a3394f206c88a30bf87645f5a46f74e6eae830",
            "blockNumber": "0x3ab",
            "contractAddress": null,
            "cumulativeGasUsed": "0xef3a",
            "from": "0xea22f69e45d10287ad90e4c184c5ffcfbde151b6",
            "gasUsed": "0xef3a",
            "logs": [],
            "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
            "status": "0x1",
            "to": "0xf958a7ef4b49289a9b3c4a4979db6d9110af5c9d",
            "transactionHash": "0x44aa45ea81508d4b417099e4a5b971973e1a2bb58e9a9174ed815bd626f4473b",
            "transactionIndex": "0x0"
        }
    }
    

    相关文章

      网友评论

          本文标题:2019-03-15 ewasm在以太坊私有链测试(2)

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