I'm looking at a transaction on Hashscan
Its transaction hash is:
0x89eb7e219df6f8b3b3406c8a3698d5b484a4945059af643861c878e41ffc161b2589cc82ff40b4392ceb53856c5252c1
... which does not work with the eth_getTransactionByHash RPC:
TXHASH=0x89eb7e219df6f8b3b3406c8a3698d5b484a4945059af643861c878e41ffc161b2589cc82ff40b4392ceb53856c5252c1
curl -s -X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"2","method":"eth_getTransactionByHash","params":["'"${TXHASH}"'"]}' \
http://localhost:7546 | jq
The error is:
{
"jsonrpc": "2.0",
"id": "2",
"error": {
"code": -32602,
"name": "Invalid parameter",
"message": "[Request ID: 5fda4d4a-3160-4f8f-8ed3-51ad64dada46] Invalid parameter 0: Expected 0x prefixed string representing the hash (32 bytes) of a transaction, value: 0x89eb7e219df6f8b3b3406c8a3698d5b484a4945059af643861c878e41ffc161b2589cc82ff40b4392ceb53856c5252c1"
}
How can I get a transaction hash that can be used in RPCs?
0xprefix0xprefix You need to convert from the Hedera transaction hash format to the EVM transaction hash format, in order to use it in RPC endpoints. To do so, simply truncate to the required length. You can do this in the shell withTXHASHEVM=${TXHASH:0:66}, and then usingTXHASHEVMas the 1st parameter of theeth_getTransactionByHashRPC request. Example Request:
Response: