3

Every Ethereum transaction that represents a function call on a smart contract holds an input field with data that corresponds to the data sent through the interface of the function. For example, this transaction ( https://etherscan.io/tx/0x3a7d091970d7931dd5ef4872e59093234e132f861139403d2b69db80ac2d0ecb) is a newProposal function on The DAO. You can that etherscan separates the data into 32 byte chunks. It's relatively easy to pick off the first 'address' and the second 'debatingPeriod,' but I'm having trouble from there. I'm assuming that the next 32 byte second is the start of the string description, and I am further assuming that it is in RLP format as described here: https://github.com/ethereum/wiki/wiki/RLP, but I'm not so sure.

According the RLP document, a third 32 byte section should be only a single byte long and if it represents 0xca it means an empty list (see examples at the bottom).

So two questions: (1) how does one parse the input data (particularly strings) of the data provided by ehterscan.io, and (2) does etherscan represent the data as it actually exists on the blockchain?

Function: newProposal(address _recipient, uint256 _amount, string _description, bytes _transactionData, uint256 _debatingPeriod, bool _newCurator)

1 Answer 1

2

Q1 how does one parse the input data (particularly strings) of the data provided by etherscan.io

You will find the information to encode the arguments at Ethereum Contract ABI.

To decode the parameters, see Encoding/Decoding contract ABI data.

And here is a JavaScript version of ethabi - https://github.com/jacogr/ethabi-js.

Here's an example using ethabi. I've created a shell script decodeIt with the following contents:

#!/bin/sh

#    function newProposal(
#        address _recipient,
#        uint _amount,
#        string _description,
#        bytes _transactionData,
#        uint _debatingPeriod,
#        bool _newCurator
#    ) onlyTokenholders returns (uint _proposalID);

# Transaction Data Without MethodId

ethabi decode params -t address -t uint256 -t string -t bytes -t uint256 -t bool 000000000000000000000000bb9bc244d798123fde783fcc1c72d3bb8c189413000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000005a00000000000000000000000000000000000000000000000000000000000127500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004b252616973696e67207468652050726f706f73616c204465706f73697420746f2031312045544820205c6e2020546869732050726f706f73616c2077696c6c20726169736520746865206465706f73697420726571756972656420746f206d616b6520612050726f706f73616c20746f205468652044414f2066726f6d20322045544820746f203131204554482e205c6e205c6e20416e20696e637265617365206f66207468652050726f706f73616c204465706f73697420746f202a2a3131204554482a2a20697320657870656374656420746f3a5c6e205c6e205c6e205c6e202d20646563726561736520746865206e756d626572206f6620706f6f726c792074686f756768742d6f75742070726f706f73616c732e205c6e205c6e202d2068656c702061766f69642074686520636f6e667573696f6e20616e6420636f6e6365726e207468617420636f756c64206265206361757365642062792068756e6472656473206f662070726f706f73616c7320746861742063616e6e6f742062652061646571756174656c792061737365737365642062792044414f20546f6b656e20486f6c646572732e205c6e205c6e202d2072656475636520746865206e756d626572206f66207370616d2070726f706f73616c7320616e6420616d6f756e74206f662070726f706f73616c2d6772616666697469206f6e205468652044414f2e205c6e205c6e205c6e2020204d6f72656f7665722c207468652074696d65207370656e74206f6e20726576696577696e672070726f706f73616c732062792044414f20546f6b656e20486f6c646572732073686f756c642062652076616c7565642e20205468657265666f72652c206164646974696f6e616c2076616c75652077696c6c2061636372756520746f205468652044414f2062656361757365206f6620746869732050726f706f73616c2066726f6d207468652070726f706f73616c206465706f73697473207468617420737461792077697468205468652044414f207768656e2070726f706f73616c73206661696c20746f2072656163682071756f72756d2e205c6e205c6e205768696c6520616e20696e637265617365206973206e65636573736172792c202a2a313120455448206973207374696c6c2077697468696e20726561636820666f7220736d616c6c2073746172742d75707320616e6420696e646976696475616c732a2a20746861742077696c6c2077616e7420746f206f6666657220736572766963657320746f205468652044414f2e20205c6e205c6e205b4a6f696e2074686520636f6e766572736174696f6e2061626f757420746869732070726f706f73616c206f6e2044414f6875622e6f72675d2868747470733a2f2f666f72756d2e64616f6875622e6f72672f742f72616973696e672d7468652d70726f706f73616c2d6465706f7369742d746f2d31312d6574682f34313036292020205c6e205c6e20215b477261706869633a2064656372656173652070726f706f73616c732c20696e637265617365207175616c6974795d2868747470733a2f2f697066732e706963732f697066732f516d63673267654a326543534d454242536250385a3536415a6767366d6e6654486f353674345342433734383733292020205c6e205c6e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024e33734fd00000000000000000000000000000000000000000000000098a7d9b8314c000000000000000000000000000000000000000000000000000000000000

And here is the output when I run decodeIt:

user@Kumquat:~$ ./decodeIt 
address bb9bc244d798123fde783fcc1c72d3bb8c189413
uint256 0000000000000000000000000000000000000000000000000000000000000000
string Raising the Proposal Deposit to 11 ETH  \n  This Proposal will raise the deposit required to make a Proposal to The DAO from 2 ETH to 11 ETH. \n \n An increase of the Proposal Deposit to **11 ETH** is expected to:\n \n \n \n - decrease the number of poorly thought-out proposals. \n \n - help avoid the confusion and concern that could be caused by hundreds of proposals that cannot be adequately assessed by DAO Token Holders. \n \n - reduce the number of spam proposals and amount of proposal-graffiti on The DAO. \n \n \n   Moreover, the time spent on reviewing proposals by DAO Token Holders should be valued.  Therefore, additional value will accrue to The DAO because of this Proposal from the proposal deposits that stay with The DAO when proposals fail to reach quorum. \n \n While an increase is necessary, **11 ETH is still within reach for small start-ups and individuals** that will want to offer services to The DAO.  \n \n [Join the conversation about this proposal on DAOhub.org](https://forum.daohub.org/t/raising-the-proposal-deposit-to-11-eth/4106)   \n \n ![Graphic: decrease proposals, increase quality](https://ipfs.pics/ipfs/Qmcg2geJ2eCSMEBBSbP8Z56AZgg6mnfTHo56t4SBC74873)   \n \n
bytes e33734fd00000000000000000000000000000000000000000000000098a7d9b8314c0000
uint256 0000000000000000000000000000000000000000000000000000000000127500
bool false

And here is the code from github.com/ethcore/ethabi/.../decoder.rs, lines 43 to 214:

impl Decoder {
    /// Decodes ABI compliant vector of bytes into vector of tokens described by types param.
    pub fn decode(types: &[ParamType], data: Vec<u8>) -> Result<Vec<Token>, Error> {
        let slices = try!(slice_data(data));
        let mut tokens = vec![];
        let mut offset = 0;
        for param in types {
            let res = try!(Self::decode_param(param, &slices, offset));
            offset = res.new_offset;
            tokens.push(res.token);
        }
        Ok(tokens)
    }

    fn peek(slices: &Vec<[u8; 32]>, position: usize) -> Result<&[u8; 32], Error> {
        slices.get(position).ok_or(Error::InvalidData)
    }

    fn take_bytes(slices: &Vec<[u8; 32]>, position: usize, len: usize) -> Result<BytesTaken, Error> {
        let slices_len = (len + 31) / 32;

        let mut bytes_slices = vec![];
        for i in 0..slices_len {
            let slice = try!(Self::peek(slices, position + i)).clone();
            bytes_slices.push(slice);
        }

        let bytes = bytes_slices.into_iter()
            .flat_map(|slice| slice.to_vec())
            .take(len)
            .collect();

        let taken = BytesTaken {
            bytes: bytes,
            new_offset: position + slices_len,
        };

        Ok(taken)
    }

    fn decode_param(param: &ParamType, slices: &Vec<[u8; 32]>, offset: usize) -> Result<DecodeResult, Error> {
        match *param {
            ParamType::Address => {
                let slice = try!(Self::peek(slices, offset));
                let mut address = [0u8; 20];
                unsafe {
                    ptr::copy(slice.as_ptr().offset(12), address.as_mut_ptr(), 20);
                }

                let result = DecodeResult {
                    token: Token::Address(address),
                    new_offset: offset + 1,
                };

                Ok(result)
            },
            ParamType::Int(_) => {
                let slice = try!(Self::peek(slices, offset));

                let result = DecodeResult {
                    token: Token::Int(slice.clone()),
                    new_offset: offset + 1,
                };

                Ok(result)
            },
            ParamType::Uint(_) => {
                let slice = try!(Self::peek(slices, offset));

                let result = DecodeResult {
                    token: Token::Uint(slice.clone()),
                    new_offset: offset + 1,
                };

                Ok(result)
            },
            ParamType::Bool => {
                let slice = try!(Self::peek(slices, offset));

                let b = try!(as_bool(slice));

                let result = DecodeResult {
                    token: Token::Bool(b),
                    new_offset: offset + 1,
                };

                Ok(result)
            },
            ParamType::FixedBytes(len) => {
                let taken = try!(Self::take_bytes(slices, offset, len));

                let result = DecodeResult {
                    token: Token::FixedBytes(taken.bytes),
                    new_offset: taken.new_offset,
                };

                Ok(result)
            },
            ParamType::Bytes => {
                let offset_slice = try!(Self::peek(slices, offset));
                let len_offset = (try!(as_u32(offset_slice)) / 32) as usize;

                let len_slice = try!(Self::peek(slices, len_offset));
                let len = try!(as_u32(len_slice)) as usize;

                let taken = try!(Self::take_bytes(slices, len_offset + 1, len));

                let result = DecodeResult {
                    token: Token::Bytes(taken.bytes),
                    new_offset: offset + 1,
                };

                Ok(result)
            },
            ParamType::String => {
                let offset_slice = try!(Self::peek(slices, offset));
                let len_offset = (try!(as_u32(offset_slice)) / 32) as usize;

                let len_slice = try!(Self::peek(slices, len_offset));
                let len = try!(as_u32(len_slice)) as usize;

                let taken = try!(Self::take_bytes(slices, len_offset + 1, len));

                let result = DecodeResult {
                    token: Token::String(try!(String::from_utf8(taken.bytes))),
                    new_offset: offset + 1,
                };

                Ok(result)
            },
            ParamType::Array(ref t) => {
                let offset_slice = try!(Self::peek(slices, offset));
                let len_offset = (try!(as_u32(offset_slice)) / 32) as usize;

                let len_slice = try!(Self::peek(slices, len_offset));
                let len = try!(as_u32(len_slice)) as usize;

                let mut tokens = vec![];
                let mut new_offset = len_offset + 1;

                for _ in 0..len {
                    let res = try!(Self::decode_param(t, &slices, new_offset));
                    new_offset = res.new_offset;
                    tokens.push(res.token);
                }

                let result = DecodeResult {
                    token: Token::Array(tokens),
                    new_offset: offset + 1,
                };

                Ok(result)
            },
            ParamType::FixedArray(ref t, len) => {
                let mut tokens = vec![];
                let mut new_offset = offset;
                for _ in 0..len {
                    let res = try!(Self::decode_param(t, &slices, new_offset));
                    new_offset = res.new_offset;
                    tokens.push(res.token);
                }

                let result = DecodeResult {
                    token: Token::FixedArray(tokens),
                    new_offset: new_offset,
                };

                Ok(result)
            }
        }
    }
}


Q2 does etherscan represent the data as it actually exists on the blockchain?

Yes.

For transaction 0x3a7d091970d7931dd5ef4872e59093234e132f861139403d2b69db80ac2d0ecb, the data from etherscan.io follows:

Function: newProposal(address _recipient, uint256 _amount, string _description, bytes _transactionData, uint256 _debatingPeriod, bool _newCurator)

MethodID: 0x612e45a3
[0]:000000000000000000000000bb9bc244d798123fde783fcc1c72d3bb8c189413
[1]:0000000000000000000000000000000000000000000000000000000000000000
[2]:00000000000000000000000000000000000000000000000000000000000000c0
[3]:00000000000000000000000000000000000000000000000000000000000005a0
[4]:0000000000000000000000000000000000000000000000000000000000127500
[5]:0000000000000000000000000000000000000000000000000000000000000000
[6]:00000000000000000000000000000000000000000000000000000000000004b2
[7]:52616973696e67207468652050726f706f73616c204465706f73697420746f20
[8]:31312045544820205c6e2020546869732050726f706f73616c2077696c6c2072
[9]:6169736520746865206465706f73697420726571756972656420746f206d616b
[10]:6520612050726f706f73616c20746f205468652044414f2066726f6d20322045
[11]:544820746f203131204554482e205c6e205c6e20416e20696e63726561736520
[12]:6f66207468652050726f706f73616c204465706f73697420746f202a2a313120
[13]:4554482a2a20697320657870656374656420746f3a5c6e205c6e205c6e205c6e
[14]:202d20646563726561736520746865206e756d626572206f6620706f6f726c79
[15]:2074686f756768742d6f75742070726f706f73616c732e205c6e205c6e202d20
[16]:68656c702061766f69642074686520636f6e667573696f6e20616e6420636f6e
[17]:6365726e207468617420636f756c64206265206361757365642062792068756e
[18]:6472656473206f662070726f706f73616c7320746861742063616e6e6f742062
[19]:652061646571756174656c792061737365737365642062792044414f20546f6b
[20]:656e20486f6c646572732e205c6e205c6e202d2072656475636520746865206e
[21]:756d626572206f66207370616d2070726f706f73616c7320616e6420616d6f75
[22]:6e74206f662070726f706f73616c2d6772616666697469206f6e205468652044
[23]:414f2e205c6e205c6e205c6e2020204d6f72656f7665722c207468652074696d
[24]:65207370656e74206f6e20726576696577696e672070726f706f73616c732062
[25]:792044414f20546f6b656e20486f6c646572732073686f756c64206265207661
[26]:6c7565642e20205468657265666f72652c206164646974696f6e616c2076616c
[27]:75652077696c6c2061636372756520746f205468652044414f20626563617573
[28]:65206f6620746869732050726f706f73616c2066726f6d207468652070726f70
[29]:6f73616c206465706f7369747320746861742073746179207769746820546865
[30]:2044414f207768656e2070726f706f73616c73206661696c20746f2072656163
[31]:682071756f72756d2e205c6e205c6e205768696c6520616e20696e6372656173
[32]:65206973206e65636573736172792c202a2a313120455448206973207374696c
[33]:6c2077697468696e20726561636820666f7220736d616c6c2073746172742d75
[34]:707320616e6420696e646976696475616c732a2a20746861742077696c6c2077
[35]:616e7420746f206f6666657220736572766963657320746f205468652044414f
[36]:2e20205c6e205c6e205b4a6f696e2074686520636f6e766572736174696f6e20
[37]:61626f757420746869732070726f706f73616c206f6e2044414f6875622e6f72
[38]:675d2868747470733a2f2f666f72756d2e64616f6875622e6f72672f742f7261
[39]:6973696e672d7468652d70726f706f73616c2d6465706f7369742d746f2d3131
[40]:2d6574682f34313036292020205c6e205c6e20215b477261706869633a206465
[41]:6372656173652070726f706f73616c732c20696e637265617365207175616c69
[42]:74795d2868747470733a2f2f697066732e706963732f697066732f516d636732
[43]:67654a326543534d454242536250385a3536415a6767366d6e6654486f353674
[44]:345342433734383733292020205c6e205c6e0000000000000000000000000000
[45]:0000000000000000000000000000000000000000000000000000000000000024
[46]:e33734fd00000000000000000000000000000000000000000000000098a7d9b8
[47]:314c000000000000000000000000000000000000000000000000000000000000

In geth we can retrieve the same data (I've formatted the input: data):

> eth.getTransaction("0x3a7d091970d7931dd5ef4872e59093234e132f861139403d2b69db80ac2d0ecb")
{
  blockHash: "0x78063cfb4b439abb2ddd207ab789349bcbc572ce7423f3bdb24f68fb8c1c841c",
  blockNumber: 1615403,
  from: "0x6fc4d393bcebc69dbc8a6877e098babd19504e3b",
  gas: 1146438,
  gasPrice: 20000000000,
  hash: "0x3a7d091970d7931dd5ef4872e59093234e132f861139403d2b69db80ac2d0ecb",
  input: "0x612e45a3
          000000000000000000000000bb9bc244d798123fde783fcc1c72d3bb8c189413
          0000000000000000000000000000000000000000000000000000000000000000
          00000000000000000000000000000000000000000000000000000000000000c0
          00000000000000000000000000000000000000000000000000000000000005a0
          0000000000000000000000000000000000000000000000000000000000127500
          0000000000000000000000000000000000000000000000000000000000000000
          00000000000000000000000000000000000000000000000000000000000004b2
          52616973696e67207468652050726f706f73616c204465706f73697420746f20
          31312045544820205c6e2020546869732050726f706f73616c2077696c6c2072
          6169736520746865206465706f73697420726571756972656420746f206d616b
          6520612050726f706f73616c20746f205468652044414f2066726f6d20322045
          544820746f203131204554482e205c6e205c6e20416e20696e63726561736520
          6f66207468652050726f706f73616c204465706f73697420746f202a2a313120
          4554482a2a20697320657870656374656420746f3a5c6e205c6e205c6e205c6e
          202d20646563726561736520746865206e756d626572206f6620706f6f726c79
          2074686f756768742d6f75742070726f706f73616c732e205c6e205c6e202d20
          68656c702061766f69642074686520636f6e667573696f6e20616e6420636f6e
          6365726e207468617420636f756c64206265206361757365642062792068756e
          6472656473206f662070726f706f73616c7320746861742063616e6e6f742062
          652061646571756174656c792061737365737365642062792044414f20546f6b
          656e20486f6c646572732e205c6e205c6e202d2072656475636520746865206e
          756d626572206f66207370616d2070726f706f73616c7320616e6420616d6f75
          6e74206f662070726f706f73616c2d6772616666697469206f6e205468652044
          414f2e205c6e205c6e205c6e2020204d6f72656f7665722c207468652074696d
          65207370656e74206f6e20726576696577696e672070726f706f73616c732062
          792044414f20546f6b656e20486f6c646572732073686f756c64206265207661
          6c7565642e20205468657265666f72652c206164646974696f6e616c2076616c
          75652077696c6c2061636372756520746f205468652044414f20626563617573
          65206f6620746869732050726f706f73616c2066726f6d207468652070726f70
          6f73616c206465706f7369747320746861742073746179207769746820546865
          2044414f207768656e2070726f706f73616c73206661696c20746f2072656163
          682071756f72756d2e205c6e205c6e205768696c6520616e20696e6372656173
          65206973206e65636573736172792c202a2a313120455448206973207374696c
          6c2077697468696e20726561636820666f7220736d616c6c2073746172742d75
          707320616e6420696e646976696475616c732a2a20746861742077696c6c2077
          616e7420746f206f6666657220736572766963657320746f205468652044414f
          2e20205c6e205c6e205b4a6f696e2074686520636f6e766572736174696f6e20
          61626f757420746869732070726f706f73616c206f6e2044414f6875622e6f72
          675d2868747470733a2f2f666f72756d2e64616f6875622e6f72672f742f7261
          6973696e672d7468652d70726f706f73616c2d6465706f7369742d746f2d3131
          2d6574682f34313036292020205c6e205c6e20215b477261706869633a206465
          6372656173652070726f706f73616c732c20696e637265617365207175616c69
          74795d2868747470733a2f2f697066732e706963732f697066732f516d636732
          67654a326543534d454242536250385a3536415a6767366d6e6654486f353674
          345342433734383733292020205c6e205c6e0000000000000000000000000000
          0000000000000000000000000000000000000000000000000000000000000024
          e33734fd00000000000000000000000000000000000000000000000098a7d9b8
          314c000000000000000000000000000000000000000000000000000000000000",
  nonce: 5,
  to: "0xbb9bc244d798123fde783fcc1c72d3bb8c189413",
  transactionIndex: 6,
  value: 2000000000000000000
}

You can find some further transactional information using eth.getTransactionReceipt(txHash):

> eth.getTransactionReceipt("0x3a7d091970d7931dd5ef4872e59093234e132f861139403d2b69db80ac2d0ecb")
{
  blockHash: "0x78063cfb4b439abb2ddd207ab789349bcbc572ce7423f3bdb24f68fb8c1c841c",
  blockNumber: 1615403,
  contractAddress: null,
  cumulativeGasUsed: 1172678,
  from: "0x6fc4d393bcebc69dbc8a6877e098babd19504e3b",
  gasUsed: 1046438,
  logs: [{
      address: "0xbb9bc244d798123fde783fcc1c72d3bb8c189413",
      blockHash: "0x78063cfb4b439abb2ddd207ab789349bcbc572ce7423f3bdb24f68fb8c1c841c",
      blockNumber: 1615403,
      data: "0x000000000000000000000000bb9bc244d798123fde783fcc1c72d3bb8c18941300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000004b252616973696e67207468652050726f706f73616c204465706f73697420746f2031312045544820205c6e2020546869732050726f706f73616c2077696c6c20726169736520746865206465706f73697420726571756972656420746f206d616b6520612050726f706f73616c20746f205468652044414f2066726f6d20322045544820746f203131204554482e205c6e205c6e20416e20696e637265617365206f66207468652050726f706f73616c204465706f73697420746f202a2a3131204554482a2a20697320657870656374656420746f3a5c6e205c6e205c6e205c6e202d20646563726561736520746865206e756d626572206f6620706f6f726c792074686f756768742d6f75742070726f706f73616c732e205c6e205c6e202d2068656c702061766f69642074686520636f6e667573696f6e20616e6420636f6e6365726e207468617420636f756c64206265206361757365642062792068756e6472656473206f662070726f706f73616c7320746861742063616e6e6f742062652061646571756174656c792061737365737365642062792044414f20546f6b656e20486f6c646572732e205c6e205c6e202d2072656475636520746865206e756d626572206f66207370616d2070726f706f73616c7320616e6420616d6f756e74206f662070726f706f73616c2d6772616666697469206f6e205468652044414f2e205c6e205c6e205c6e2020204d6f72656f7665722c207468652074696d65207370656e74206f6e20726576696577696e672070726f706f73616c732062792044414f20546f6b656e20486f6c646572732073686f756c642062652076616c7565642e20205468657265666f72652c206164646974696f6e616c2076616c75652077696c6c2061636372756520746f205468652044414f2062656361757365206f6620746869732050726f706f73616c2066726f6d207468652070726f706f73616c206465706f73697473207468617420737461792077697468205468652044414f207768656e2070726f706f73616c73206661696c20746f2072656163682071756f72756d2e205c6e205c6e205768696c6520616e20696e637265617365206973206e65636573736172792c202a2a313120455448206973207374696c6c2077697468696e20726561636820666f7220736d616c6c2073746172742d75707320616e6420696e646976696475616c732a2a20746861742077696c6c2077616e7420746f206f6666657220736572766963657320746f205468652044414f2e20205c6e205c6e205b4a6f696e2074686520636f6e766572736174696f6e2061626f757420746869732070726f706f73616c206f6e2044414f6875622e6f72675d2868747470733a2f2f666f72756d2e64616f6875622e6f72672f742f72616973696e672d7468652d70726f706f73616c2d6465706f7369742d746f2d31312d6574682f34313036292020205c6e205c6e20215b477261706869633a2064656372656173652070726f706f73616c732c20696e637265617365207175616c6974795d2868747470733a2f2f697066732e706963732f697066732f516d63673267654a326543534d454242536250385a3536415a6767366d6e6654486f353674345342433734383733292020205c6e205c6e0000000000000000000000000000",
      logIndex: 0,
      topics: ["0x5790de2c279e58269b93b12828f56fd5f2bc8ad15e61ce08572585c81a38756f", "0x0000000000000000000000000000000000000000000000000000000000000011"],
      transactionHash: "0x3a7d091970d7931dd5ef4872e59093234e132f861139403d2b69db80ac2d0ecb",
      transactionIndex: 6
  }],
  root: "2cc908726fde4b08750ca6bca9f641f70033039dc2b6a751fadf93556e0e0f6d",
  to: "0xbb9bc244d798123fde783fcc1c72d3bb8c189413",
  transactionHash: "0x3a7d091970d7931dd5ef4872e59093234e132f861139403d2b69db80ac2d0ecb",
  transactionIndex: 6
}

And if you want the intermediate execution details of the transaction, use debug.traceTransaction(txHash). Note that this data is not available in --fast synced blockchain data:

> debug.traceTransaction("0x3a7d091970d7931dd5ef4872e59093234e132f861139403d2b69db80ac2d0ecb")
{
  gas: 1046438,
  returnValue: "0000000000000000000000000000000000000000000000000000000000000011",
  structLogs: [{
      depth: 1,
      error: "",
      gas: 1039659,
      gasCost: 3,
      memory: null,
      op: "PUSH1",
      pc: 0,
      stack: [],
      storage: {}
  }, {
      depth: 1,
      error: "",
      gas: 1039656,
      gasCost: 3,
      memory: null,
      op: "PUSH1",
      pc: 2,
      stack: ["0000000000000000000000000000000000000000000000000000000000000060"],
      storage: {}
  }, {
  ...
  }, {
      depth: 1,
      error: "",
      gas: 100000,
      gasCost: 0,
      memory: ["290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e653", "0000000000000000000000000000000000000000000000000000000000000004", "00000000000000000000000000000000000000000000000000000000000005a0", "00000000000000000000000000000000000000000000000000000000000004b2", 
...
"75652077696c6c2061636372756520746f205468652044414f20626563617573", "65206f6620746869732050726f706f73616c2066726f6d207468652070726f70", "6f73616c206465706f7369747320746861742073746179207769746820546865", "2044414f207768656e2070726f706f73616c73206661696c20746f2072656163", "682071756f72756d2e205c6e205c6e205768696c6520616e20696e6372656173", "65206973206e65636573736172792c202a2a313120455448206973207374696c", "6c2077697468696e20726561636820666f7220736d616c6c2073746172742d75", "707320616e6420696e646976696475616c732a2a20746861742077696c6c2077", "616e7420746f206f6666657220736572766963657320746f205468652044414f", "2e20205c6e205c6e205b4a6f696e2074686520636f6e766572736174696f6e20", "61626f757420746869732070726f706f73616c206f6e2044414f6875622e6f72", "675d2868747470733a2f2f666f72756d2e64616f6875622e6f72672f742f7261", "6973696e672d7468652d70726f706f73616c2d6465706f7369742d746f2d3131", "2d6574682f34313036292020205c6e205c6e20215b477261706869633a206465", "6372656173652070726f706f73616c732c20696e637265617365207175616c69", "74795d2868747470733a2f2f697066732e706963732f697066732f516d636732", "67654a326543534d454242536250385a3536415a6767366d6e6654486f353674", "345342433734383733292020205c6e205c6e0000000000000000000000000000"],
      op: "RETURN",
      pc: 2423,
      stack: ["00000000000000000000000000000000000000000000000000000000612e45a3", "0000000000000000000000000000000000000000000000000000000000000020", "00000000000000000000000000000000000000000000000000000000000005a0"],
      storage: {
        0000000000000000000000000000000000000000000000000000000000000000: "0000000000000000000000000000000000000000000000000000000000000012",
        000000000000000000000000000000000000000000000000000000000000000d: "000000000000000000000000000000000000000000000000a688906bd8b00000",
        290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e651: "000000000000000000000000bb9bc244d798123fde783fcc1c72d3bb8c189413",
        ...
        2bf8633ec7e4240fec55e476732a268c55bfe5c6e7b9cd4c2ca674f500268164: "345342433734383733292020205c6e205c6e0000000000000000000000000000"
      }
  }]
}
4
  • How do I parse the input data? I see the first four bytes of the input are the function call, the next 32 bytes are the recipient address, the next 32 bytes are the amount, and the next 32 bytes are 0x0000....0ca which I think are a flag saying "a string follows" (this based on the function photo). The next 32 bytes look like a string length, and then the string. But why the 0x0000...0000 word? And--and this is what I'm asking--is there a specification for the data. I thought it was RLP which I referenced in my post, but in the doc I reference is says 0xca means empty string, so I'm confused. Jul 31, 2016 at 16:30
  • I will take a look at the javascript code you linked to. I think that should get me what I want, but is there a specification for the encoding/decoding, or is the code the specification? Jul 31, 2016 at 16:32
  • 1
    This completely worked. Thanks. I can now fully parse all input data from any Ethereum transaction using the ABI from any contract! Super excited. Thanks so much. Aug 1, 2016 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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