2

I use web3js to send transaction to block. And save some information in it.

I find that Parity client can show the parameters directly.

But when I get the block data with JSONRPC, I can't figure out which is my data that I put in.

For example I get a block by hash, and the return is like this:

"jsonrpc": "2.0",
"result": {
    "author": "0x00d190002eae6a467af8dc7ac3215b41028ac06f",
    "difficulty": "0xfffffffffffffffffffffffffffffff7",
    "extraData": "0xd5830107008650617269747986312e31382e30826c69",
    "gasLimit": "0x47b760",
    "gasUsed": "0x31d67",
    "hash": "0xf8e135dbadc405d6bc16cb5a0e3ac8dbe560927ba96e3844fa9ec838aca475bd",
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "miner": "0x00d190002eae6a467af8dc7ac3215b41028ac06f",
    "number": "0x2ef",
    "parentHash": "0xaec5be937a53721e2fa1795408e81f01df4144e401d97e1d580deb29688c332d",
    "receiptsRoot": "0x4b68641d219b1d8e82adc485b1920db42b3eec1099c692ab52899779d3edbf61",
    "sealFields": [
        "0x8411ddd280",
        "0xb8410ba11be8900cea08c411b10bbe990a252187452f956ae8fb48851675499af011478f858f9d5a5f80b46bbf726f91f330fff2fbac240855c11e86beabf32335a200"
    ],
    "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "signature": "0ba11be8900cea08c411b10bbe990a252187452f956ae8fb48851675499af011478f858f9d5a5f80b46bbf726f91f330fff2fbac240855c11e86beabf32335a200",
    "size": "0x4f1",
    "stateRoot": "0xabe536a30aa59d297b71984091c8d31c158ad2e7551dafb3fb5ff420313a4372",
    "step": "299750016",
    "timestamp": "0x59551c7f",
    "totalDifficulty": "0x2eeffffffffffffffffffffffffee242a91",
    "transactions": [
        {
            "blockHash": "0xf8e135dbadc405d6bc16cb5a0e3ac8dbe560927ba96e3844fa9ec838aca475bd",
            "blockNumber": "0x2ef",
            "condition": null,
            "creates": "0x2825f034088137cd65328112bd4b0d7906cb2f94",
            "from": "0x0048e5a10050c9b566ea23d0b1393d188ef950bd",
            "gas": "0x47b760",
            "gasPrice": "0x18e14af0",
            "hash": "0x9433191bb9a8cdeee26c68ae20f0c710c6b922238847da8dc29e45d2d5d2a870",
            "input": "0x6060604052341561000c57fe5b5b6102378061001c6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063962939b81461003b575bfe5b341561004357fe5b6100d6600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506101d9565b604051808060200180602001838103835285818151815260200191508051906020019080838360008314610129575b80518252602083111561012957602082019150602081019050602083039250610105565b505050905090810190601f1680156101555780820380516001836020036101000a031916815260200191505b5083810382528481815181526020019150805190602001908083836000831461019d575b80518252602083111561019d57602082019150602081019050602083039250610179565b505050905090810190601f1680156101c95780820380516001836020036101000a031916815260200191505b5094505050505060405180910390f35b6101e16101f7565b6101e96101f7565b8383915091505b9250929050565b6020604051908101604052806000815250905600a165627a7a7230582001aded1229b1914c79dcc0d6069eee9b46740ef09d66002b4427444d6f4afa130029",
            "networkId": 8995,
            "nonce": "0xd",
            "publicKey": "0x1bc1dd59eeaeb546ffa85598378b1a1b623317dd231bfd65fdc19b0a13c379b77c7334d91973149f7d5246b65c6c8658aecd1162439af2776aceeb7f78b927c1",
            "r": "0x3e82009ebbe3b7d1559b44c6f7ac0e4a3e1f0d7399b21dbdbd3462382de50c14",
            "raw": "0xf902a70d8418e14af08347b7608080b902536060604052341561000c57fe5b5b6102378061001c6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063962939b81461003b575bfe5b341561004357fe5b6100d6600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506101d9565b604051808060200180602001838103835285818151815260200191508051906020019080838360008314610129575b80518252602083111561012957602082019150602081019050602083039250610105565b505050905090810190601f1680156101555780820380516001836020036101000a031916815260200191505b5083810382528481815181526020019150805190602001908083836000831461019d575b80518252602083111561019d57602082019150602081019050602083039250610179565b505050905090810190601f1680156101c95780820380516001836020036101000a031916815260200191505b5094505050505060405180910390f35b6101e16101f7565b6101e96101f7565b8383915091505b9250929050565b6020604051908101604052806000815250905600a165627a7a7230582001aded1229b1914c79dcc0d6069eee9b46740ef09d66002b4427444d6f4afa130029824669a03e82009ebbe3b7d1559b44c6f7ac0e4a3e1f0d7399b21dbdbd3462382de50c14a0478c96ece0763d198c1dd1786796008038944e1d65939aa79eb7d2eb552beb2d",
            "s": "0x478c96ece0763d198c1dd1786796008038944e1d65939aa79eb7d2eb552beb2d",
            "standardV": "0x0",
            "to": null,
            "transactionIndex": "0x0",
            "v": "0x4669",
            "value": "0x0"
        }
    ],
    "transactionsRoot": "0x4107bfd073f20a1bf82939bc7d1058bd31b108d9830e5b6e0985361b62b578d9",
    "uncles": []
},
"id": 1

}

In these information, which is I input? Or is there a JSONRPC that can return the data which I input? I read some document but not get correct answer. Can you give me some advice? Thanks. :)

  • To get the dats sent along with txn you need to look at the txn message not block info. – niksmac Jun 29 '17 at 16:36
  • Emmmmm.... What is txn? I read a tx in this JSONRPC, github.com/paritytech/parity/wiki/…, do you mean it? So I need to sign my transaction to get the data which I save? – YangYifei Jun 29 '17 at 16:48
  • Maybe you mean transaction? But I call get transaction by hash also returns something like this... I think it not very useful... I will update the transaction information later. – YangYifei Jun 29 '17 at 16:58
  • What/how are you sending the information to web3? Is 0x0048e5a10050c9b566ea23d0b1393d188ef950bd your address? – Sawyer Jun 29 '17 at 20:40
  • @SawyerYes. It's the address of my account which send transaction. I will put my web3js later. Thanks~ – YangYifei Jun 29 '17 at 21:14
0

I find a project on github: https://github.com/ConsenSys/abi-decoder

It can help you to exchange your tx data to readable data. But it need the ABI.

Follow the README of this project, I can get the input information which I sent to transaction.

Thanks a lot. :)

0

You can 'dissect' the result from getTransaction. Here's an example for retrieving integer values that were stored...

        web3.eth.getTransaction(txHash, function(error, trans){
        let input = trans.input.slice(10);
        let sample = [];
        if (trans) {
            let sliceFrom = 0;
            let sliceTo = 64;
            for (let i = 0; i < 12; i++) {
                sample[i] = (parseInt(input.slice(sliceFrom, sliceTo), 16));
                sliceFrom += 64;
                sliceTo += 64;
                console.log(i+": "+sample[i]);
            }
        }
    });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.