eth_getBlockByHash
ブロックハッシュに基づきブロックについての情報を返します。
パラメータ
1. DATA
32バイト
ブロックハッシュ
2. Boolean
true の場合は、すべてのトランザクションオブジェクトを返します。
false の場合は、トランザクションのハッシュのみを返します。
パラメータ
code:params.js
params: [
'0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331',
true
]
戻り値
Object - ブロックオブジェクト。ブロックが見つからなかった場合は null
number : QUANTITY
ブロック番号
未承認ブロックの場合は null
hash : DATA
32バイト
ブロックハッシュ
未承認ブロックの場合は null
parentHash : DATA
32バイト
親ブロックのハッシュ
nonce : DATA
8バイト
Proof-of-Work によって生成されたハッシュ
未承認ブロックの場合は null
sha3Uncles : DATA
32バイト
uncle データの SHA3 ハッシュ
logsBloom : DATA
256バイト
未承認ブロックの場合は null
transactionsRoot : DATA
32バイト
ブロックのトランザクションツリーのルート
stateRoot : DATA
32バイト
ブロックの最終ステートツリーのルート
receiptsRoot : DATA
32バイト
ブロックのレシートツリーのルート
miner : DATA
20バイト
difficulty : QUANTITY
ブロックの難易度
totalDifficulty : QUANTITY
このブロックまでの合計難易度
extraData : DATA
extra データフィールド
size : QUANTITY
ブロックサイズのバイト数
gasLimit : QUANTITY
ブロックガスリミット
gasUsed : QUANTITY
このブロックのすべてのトランザクションで使用されたガスの合計値
timestamp : QUANTITY
ブロックが照合された時間の UNIX タイムスタンプ
transactions : Array
トランザクションオブジェクトの配列
または、32バイトのトランザクションハッシュの配列
uncles : Array
Uncle のハッシュの配列
サンプル
code:example.sh
// Request
// Result
{
"id":1,
"jsonrpc":"2.0",
"result": {
"number": "0x1b4", // 436
"hash": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"parentHash": "0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5",
"nonce": "0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logsBloom": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff",
"miner": "0x4e65fda2159562a496f9f3522f89122a3088497a",
"difficulty": "0x027f07", // 163591
"totalDifficulty": "0x027f07", // 163591
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"size": "0x027f07", // 163591
"gasLimit": "0x9f759", // 653145
"gasUsed": "0x9f759", // 653145
"timestamp": "0x54e34e8e" // 1424182926
"transactions": ... }
}
}
Infura を使用したサンプル
GET
code:infura_example_get.sh
POST
code:infura_example_post.sh
curl -i -X POST \
-H "Content-Type: application/json" \
RESPONSE
code:infura_response.sh
{"jsonrpc":"2.0","id":1,"result":{"difficulty":"0xbfabcdbd93dda","extraData":"0x737061726b706f6f6c2d636e2d6e6f64652d3132","gasLimit":"0x79f39e","gasUsed":"0x79ccd3","hash":"0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35","logsBloom":"0x4848112002a2020aaa0812180045840210020005281600c80104264300080008000491220144461026015300100000128005018401002090a824a4150015410020140400d808440106689b29d0280b1005200007480ca950b15b010908814e01911000054202a020b05880b914642a0000300003010044044082075290283516be82504082003008c4d8d14462a8800c2990c88002a030140180036c220205201860402001014040180002006860810ec0a1100a14144148408118608200060461821802c081000042d0810104a8004510020211c088200420822a082040e10104c00d010064004c122692020c408a1aa2348020445403814002c800888208b1","miner":"0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c","mixHash":"0x3d1fdd16f15aeab72e7db1013b9f034ee33641d92f71c0736beab4e67d34c7a7","nonce":"0x4db7a1c01d8a8072","number":"0x5bad55","parentHash":"0x61a8ad530a8a43e3583f8ec163f773ad370329b2375d66433eb82f005e1d6202","receiptsRoot":"0x5eced534b3d84d3d732ddbc714f5fd51d98a941b28182b6efe6df3a0fe90004b","sha3Uncles":"0x8a562e7634774d3e3a36698ac4915e37fc84a2cd0044cb84fa5d80263d2af4f6","size":"0x41c7","stateRoot":"0xf5208fffa2ba5a3f3a2f64ebd5ca3d098978bedd75f335f56b705d8715ee2305","timestamp":"0x5b541449","totalDifficulty":"0x12ac11391a2f3872fcd","transactions":"0x8784d99762bccd03b2086eabccee0d77f14d05463281e121a62abfebcf0d2d5f","0x311be6a9b58748717ac0f70eb801d29973661aaf1365960d159e4ec4f4aa2d7f","0xe42b0256058b7cad8a14b136a0364acda0b4c36f5b02dea7e69bfd82cef252a2","0x4eb05376055c6456ed883fc843bc43df1dcf739c321ba431d518aecd7f98ca11","0x994dd9e72b212b7dc5fd0466ab75adf7d391cf4f206a65b7ad2a1fd032bb06d7","0xf6feecbb9ab0ac58591a4bc287059b1133089c499517e91a274e6a1f5e7dce53","0x7e537d687a5525259480440c6ea2e1a8469cd98906eaff8597f3d2a44422ff97","0xa762220e92bed6d77a2c19ffc60dad77d71bd5028c5230c896ab4b9552a39b50","0xf1fa677edda7e5add8e794732c7554cd5459a5c12781dc71de73c7937dfb2775","0x3220af8e317fde6dac80b1199f9ceeafe60ada4974a7e04a75fbce1ac4cb46c3","0x5566528978250828168f0d30bcc8a3689d129c75d820d604f7eb84c25b34ec81","0x646c98e323a05862778f0c9063a989b6aefd94f28842a3a09d2edb37a050717d","0xe951ea55764f7e8e0720f7042dd1db67525965302ed974a0c8e3b769bc1818e3","0x7ecf2528b7df3831712501f5c60ef156bf5fcac9912199e0a64afcb963ea91ca","0xc43b89783f68b2844918ea515cc146c006e5f162c9be9aedf5e7a6ae1f32e164","0xd74503ede63d6fd41367796433aa14439902e8f57293a0583e19aa6ebf3f128e","0x021e5b7d3ddac97b4c6cb9c3f333766a533c1ed9fbcfb8b2515c38ecd0c53f89","0xbb3a336e3f823ec18197f1e13ee875700f08f03e2cab75f0d0b118dabb44cba0","0x25f65866dba34783200c25fb1c120b36326c9ad3a47e8bc34c3edbc9208f1378","0x5336f5c4132ef00e8b469ecfd4ee0d6800f6bd60aefb1c62232cbce81c085ae2","0xb87410cfe0a75c004f7637736b3de1e8f4e08e9e2b05ab963622a40a5505664d","0x990857a27ec7cfd6dfd88015173adf81959b5abaff6eefbe8e9df6b0f40f2711","0x3563ccb5734b7b5015122a20b558723afe992ff1109a04b57e02f26edd5a6a38","0xd7885d9412cc494fbe680b016bf7402b633c34c66833b35cad59af2a4aff4f0b","0x48e60927d6fb9ae76f69a6400490b5ffcb2f9da3105fad6c61f21256ef0c217c","0x9e30af26ff3836c4b55af62ba134bc55db662cf1d396cca437d12a8195bfcbe4","0x2476eeede4764c6871f50f3235ebeb9a56d33b41bc3bb1ce3c18c5d710a0609c","0x1cd3520fbb1eb6f2f6f257ab7c3cba957806b0b87182baedb4f81c62868064c1","0x78ae3aee0ff16d8ea4f394b7b80021804e1d9f35cdbb9c6189bb6cbf58bc52c4","0xfcc75bad728b8d302ba0674ebe3122fc50e3b78fe4948ddfc0d37ee987e666ca","0xd2175464d72bcc61b2e07aa3aac742b4184480d7a9f6ae5c2ba24d9c9bb9f304","0x42b56b504e59e42a3dc94e740bb4231e6326daaac7a73ef93ee8db7b96ac5d71","0xd42681091641cd2a71f18299e8e206d5659c3076b1c63adc26f5b7740e230d2b","0x1202c354f0a00b31adf9e3d895e0c8f3896182bb3ab9fc69d6c21d31a1bf279c","0xa5cea1f6957431caf589a8dbb58c102fb191b39967fbe8d26cecf6f28bb835da","0x2045efeb2f5ea9176690ece680d3fd7ca9e945d0d572d17786810d323628f98c","0xbf55d13976616a23114b724b14049eaaf91db3f1950320b5306006a6b648b24f","0x9e5c5ea885eb1d6b1b3ffcf703e3381b7681f7420f35408d30ba93ec0cdf0792","0x6f1a61dc4306ca5e976a1706afe1f32279548df98e0373c5fee0ea189ddb77a0","0xc5c16b30c22ee4f90c3a2de70554f7975eb476592ff13c61986d760da6cf7f9d","0xb09de28497227c0537df0a78797fa00407dcd04a4f90d9de602484b61f7bf169","0x1bfea966fa7772a26b4b2c8add15ceedcb70a903618f5d4603d69f52b9954025","0xe58be9c0e3cedd4444c76d1adc098ba40cbe21ef886b2bfc2edb6ed96ba8d966","0x3a29096f712ccdafd56e9a3c635d4fe2e6224ac3666d466c21da66c8829bbfd6","0x31feab77d7c1c87eb79af54193400c8edad16645e1ea5fcc10f2eaec51fe3992","0x4e0278fce62dca8e23cfae6a020fcd3b2facc03244d54b964bbde424f902ffe1","0x300239a64a50ad0e646c232f85cfa4f3d3ed30090cd574329c782d95c2b42532","0x41755f354b06b4b8a452db1cc9b5c810c75b1bbe236603cbc0950c3c81b80c51","0x1e3fbeffc326f1ffd8559c6024c12557e6014bc02c12d65dbc1baa4e1aed94b7","0x4a459a32cf68e9b7697a3a656432b340d6d27c3d4a513e6cce770d63df99839a","0x3ef484913d185de728c787a1053ec1444ec1c7a5827eecba521d3b406b088a89","0x43afa584c21f27a2747a8397b00d3ec4b460d929b61b510d017f01037a3ded3f","0x44e6a37a6c1d8696fa0537385b9d1bb535b2b3309b5482209e95b5b6c58fc8da","0x2a8bca48147955efcfd697f1a97304ae4cc467a7778741c2c47e516610f0a876","0x4c6bd64c8974f8b949cfe265da1c1bb997e3c886f024b38c99d170acc70b83df","0x103f0cca1ae13600c5be5b217e92430a72b0471d05e283c105f5d0df36438b2a","0x00a06bf6fbd07b3a89ef9031a2108c8fa31b467b33a6edcd6eb3687c158743cf","0x0175496d8265dedd693cf88884626c33b699ebcf4f2110e4c7fb7603c53215b2","0x11fb433ab551b33f30d00a34396835fab72e316e81d1e0afcbc92e79801f30c4","0x060dc4541fd534d107f6e49b96d84f5ec6dbe4eb714890e800bd02399a6bfb7f","0x01956de9f96f9a268c6524fffb9919d7fa3de7a4c25d53c2ccc43d0cb022a7ff","0x15057378f2d223829269ec0f31ba4bb03146134220d34eb8eb7c403aa4a2e569","0x16ea0218d72b5e3f69d0ae4daa8085150f5f7e69ee22a3b054744e35e2082879","0x0baf4e8ff92058c1cac3b95c237edb4d2c12ad41d210356c209f1e0bf0d2d12a","0x1a8ac77aff614caeca16a5a3a0931375a5a4fbe0ef1e15d6d15bf6f8e3c60f4f","0xdb899136f41a3d4710907345b09d241490776383271e6b9887499fd05b80fcd4","0x1007e17b1120d37fb930f953d8a3440ca11b8fd84470eb107c8b4a402a9813fd","0x0910324706ffeebf8aa25ca0784636518bf67e5d173c22438a64dd43d5f4aa2a","0x028f2bee56aee7005abcb2258d6d9f0f078a85a65c3d669aca40564ef4bd7f94","0x14adac9bc94cde3166f4b7d42e8862a745483c708e51afbe89ecd6532acc532e","0x54bed12ccad43523ba8527d1b99f5fa04a55b3a7724cfff2e0a21ec90b08590e","0xcdf05df923f6e418505750069d6486276b15fcc3cd2f42a7044c642d19a86d51","0x0c66977ed87db75074cb2bea66b254af3b20bb3315e8095290ceb1260b1b7449","0x22626e2678da34b505b233ef08fc91ea79c5006dff00e33a442fa51a11e34c25","0xe2989560000a1fc7c434c5e9c4bba82e1501bf435292ac25acc3cb182c1c2cd0","0x348cfc85c58b7f3b2e8bdaa517dc8e3c5f8fb41e3ba235f28892b46bc3484756","0x4ac009cebc1f2416b9e39bcc5b41cd53b1a9239e8f6c0ab043b8830ef1ffc563","0xf2a96682362b9ffe9a77190bcbc47937743b6e1da2c56257f9b562f15bbd3cfa","0xf1cd627c97746bc75727c2f0efa2d0dc66cca1b36d8e45d897e18a9b19af2f60","0x241d89f7888fbcfadfd415ee967882fec6fdd67c07ca8a00f2ca4c910a84c7dd","transactionsRoot":"0xf98631e290e88f58a46b7032f025969039aa9b5696498efc76baf436fa69b262","uncles":"0x824cce7c7c2ec6874b9fa9a9a898eb5f27cbaf3991dfa81084c3af60d1db618c"}} 動作サンプル
code:demo.js
let html = '<div><h1>eth_getBlockByHash</h1></div>'
+ '<div>'
+ '<div>block hash: <input type="text" id="input" size="60"></input></div>'
+ '<div>option (Boolean): <input type="text" id="input2" size="60" value="false"></input></div>'
+ '<button onclick="run()">実行</button>'
+ '</div>'
+ '<div><textarea id="result" cols="100" rows="30" readonly></textarea></div>'
$(document.body).append(html)
function run() {
let input = $('#input').val()
let input2 = $('#input2').val()
if (input.length == 66 && input2.length > 3) {
.then((response) => {
console.log(response)
$('#result').html(JSON.stringify(response, null, '\t'))
})
}
}
参考