blockchainethereumweb3jsetherscan

What is column 'type' means at Ethereum method eth_getTransactionByHash?


As the title said, I can't find any document that has a type column description, and don't know the value means. Is anyone has an idea?

{
    "jsonrpc":"2.0",
    "id":1,
    "result":{
        "blockHash":"0xf64a12502afc36db3d29931a2148e5d6ddaa883a2a3c968ca2fb293fa9258c68",
        "blockNumber":"0x70839",
        "from":"0x0000000000000000000000000000000000000000",
        "gas":"0x30d40",
        "gasPrice":"0xba43b7400",
        "hash":"0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1",
        "input":"0xfc36e15b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a4861636b65726e65777300000000000000000000000000000000000000000000",
        "nonce":"0xa7",
        "to":"0x03fca6077d38dd99d0ce14ba32078bd2cda72d74",
        "transactionIndex":"0x0",
        "value":"0x0",
        "type":"0x0", // <- here
        "v":"0x1c",
        "r":"0xe7ccdba116aa95ae8d9bdd02f619a0cdfc1f60c5740b3899865822a80cd70218",
        "s":"0xf200df1921ea988d16280a0873b69cb782a54e8a596d15e700710c820c8d2a9e"
    }
}

And an additional question here, as an above result, how can I know the transaction has been completed or failed?


Solution

  • It's the Typed transaction envelope added in the EIP-2718. Implementation of this EIP was deployed in April 2021 in the Berlin hardfork (source).

    The field allows to use future transaction types without backwards compatibility. An example of a new incompatible tx type (value 0x01) is in the EIP-2930, also deployed in the Berlin hardfork.

    Probably because it's a new field, it's not yet (June 2021) included in the JSON-RPC documentation. But other documentations, such as ethers.js, already started covering it.


    You can get the transaction status (if it succeeded or reverted) from the transaction receipt field status. It's not included in the regular getTransactionByHash method used in your question.

    Mind that the status is not included in pre-Byznatium (October 2017) transactions and can also be missing in some future transaction types.