How do I retrieve the timestamp of a mined transaction using the JSON RPC?
1 Answer
Call https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbynumber and the time stamp is returned as part of the result.
The data returned by eth_getBlockByNumber is the same as the data returned by eth_getBlockByHash below:
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByHash","params":["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true],"id":1}'
// Result
{
"id":1,
"jsonrpc":"2.0",
"result": {
"number": "0x1b4", // 436
"hash": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
...
"timestamp": "0x54e34e8e" // 1424182926
...