eth_getCode
与えられたアドレスのコードを返します。
パラメータ
1. DATA
20バイト
アドレス
2. QUANTITY|TAG
ブロック番号
または、以下のいずれかの文字列
"latest"
"earliest"
"pending"
code:params.js
params: [
'0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b',
'0x2' // 2
]
戻り値
DATA
与えられたアドレスのコード
サンプル
code:example.sh
// Request
// Result
{
"id":1,
"jsonrpc": "2.0",
"result": "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"
}
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":"0x6060604052600436106100db576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063036ae6451461039157806330fb6bfb146103b857806358d2ab45146104225780635a052dff146104535780635fc9d392146104df57806387c79d1d146105045780638858adc61461055657806395a708631461058b578063978bbdb9146105d15780639ededf77146105fa578063bbc2986c1461062b578063bc6633f71461065b578063bd11f69d1461068d578063efcf4f41146106ce578063fbf2360c146107b3575b600080600560003690501415156100f157600080fd5b6101f16000366000818110151561010457fe5b90509001357f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166000366001818110151561018057fe5b90509001357f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166107e0565b915061036f6000366002818110151561020657fe5b90509001357f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166000366003818110151561028257fe5b90509001357f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916600036600481811015156102fe57fe5b90509001357f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916610836565b905061038d33838360206040519081016040528060008152506108b8565b5050005b341561039c57600080fd5b6103b6600480803561ffff16906020019091905050610b2f565b005b34156103c357600080fd5b610420600480803561ffff1690602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610bc4565b005b341561042d57600080fd5b610435610c9a565b604051808261ffff1661ffff16815260200191505060405180910390f35b6104dd600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803561ffff1690602001909190803562ffffff1690602001909190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506108b8565b005b34156104ea57600080fd5b61050260048080351515906020019091905050610ca0565b005b341561050f57600080fd5b610517610d0c565b604051808261271060200280838360005b83811015610543578082015181840152602081019050610528565b5050505090500191505060405180910390f35b341561056157600080fd5b610589600480803561ffff1690602001909190803562ffffff16906020019091905050610d83565b005b341561059657600080fd5b6105cf600480803561ffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610e3e565b005b34156105dc57600080fd5b6105e4610f57565b6040518082815260200191505060405180910390f35b341561060557600080fd5b61060d610f5c565b604051808261ffff1661ffff16815260200191505060405180910390f35b341561063657600080fd5b610659600480803561ffff16906020019091908035906020019091905050610f61565b005b341561066657600080fd5b61068b600480803561ffff169060200190919080351515906020019091905050611004565b005b341561069857600080fd5b6106ae60048080359060200190919050506110ba565b604051808262ffffff1662ffffff16815260200191505060405180910390f35b34156106d957600080fd5b6106f3600480803561ffff169060200190919050506110e9565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018060200184815260200183151515158152602001828103825285818151815260200191508051906020019080838360005b8381101561077557808201518184015260208101905061075a565b50505050905090810190601f1680156107a25780820380516001836020036101000a031916815260200191505b509550505050505060405180910390f35b34156107be57600080fd5b6107c6611338565b604051808215151515815260200191505060405180910390f35b60006064827f0100000000000000000000000000000000000000000000000000000000000000900402837f0100000000000000000000000000000000000000000000000000000000000000900401905092915050565b6000817f01000000000000000000000000000000000000000000000000000000000000009004610100847f010000000000000000000000000000000000000000000000000000000000000090040262010000867f0100000000000000000000000000000000000000000000000000000000000000900402010190509392505050565b60008060008061271061ffff168761ffff161015156108d657600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff161415151561091257600080fd5b6000341415151561092257600080fd5b61092b876110e9565b9091508094508195508296505050506001151582151514151561094d57600080fd5b34831115151561095c57600080fd5b60643481151561096857fe5b0490508373ffffffffffffffffffffffffffffffffffffffff166108fc8234039081150290604051600060405180830381858888f1935050505015156109ad57600080fd5b734f6896af8c26d1a3c464a4a03705fb78fa2adb8673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501515610a0157600080fd5b6080604051908101604052808973ffffffffffffffffffffffffffffffffffffffff168152602001868152602001848152602001600015158152506103e960008961ffff1661ffff16815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001019080519060200190610abb92919061134c565b506040820151816002015560608201518160030160006101000a81548160ff0219169083151502179055509050508560008861ffff1661271081101515610afe57fe5b600a91828204019190066003026101000a81548162ffffff021916908362ffffff1602179055505050505050505050565b73f1fa618d4661a8e20f665be3bd46caad828b583773ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b7d57600080fd5b60206040519081016040528060008152506103e960008361ffff1661ffff1681526020019081526020016000206001019080519060200190610bc09291906113cc565b5050565b600115156103e860009054906101000a900460ff161515141515610be757600080fd5b816103e960008261ffff1661ffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c6157600080fd5b816103e960008561ffff1661ffff1681526020019081526020016000206001019080519060200190610c949291906113cc565b50505050565b61271081565b73f1fa618d4661a8e20f665be3bd46caad828b583773ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cee57600080fd5b806103e860006101000a81548160ff02191690831515021790555050565b610d1461144c565b60006127108060200260405190810160405280929190826127108015610d79576020028201916000905b82829054906101000a900462ffffff1662ffffff1681526020019060030190602082600201049283019260010382029150808411610d3e5790505b5050505050905090565b816103e960008261ffff1661ffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610dfd57600080fd5b8160008461ffff1661271081101515610e1257fe5b600a91828204019190066003026101000a81548162ffffff021916908362ffffff160217905550505050565b816103e960008261ffff1661ffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610eb857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610ef457600080fd5b816103e960008561ffff1661ffff16815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050565b606481565b606481565b816103e960008261ffff1661ffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610fdb57600080fd5b816103e960008561ffff1661ffff16815260200190815260200160002060020181905550505050565b816103e960008261ffff1661ffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561107e57600080fd5b816103e960008561ffff1661ffff16815260200190815260200160002060030160006101000a81548160ff021916908315150217905550505050565b600081612710811015156110ca57fe5b600a9182820401919006600302915054906101000a900462ffffff1681565b60006110f361147c565b6000806110fe611490565b60006103e960008861ffff1661ffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156111c957608060405190810160405280734f6896af8c26d1a3c464a4a03705fb78fa2adb8673ffffffffffffffffffffffffffffffffffffffff16815260200160206040519081016040528060008152508152602001662386f26fc100008152602001600115158152509050611311565b6103e960008761ffff1661ffff168152602001908152602001600020608060405190810160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600182018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156112e05780601f106112b5576101008083540402835291602001916112e0565b820191906000526020600020905b8154815290600101906020018083116112c357829003601f168201915b50505050508152602001600282015481526020016003820160009054906101000a900460ff16151515158152505090505b80600001518160200151826040015183606001518292509450945094509450509193509193565b6103e860009054906101000a900460ff1681565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061138d57805160ff19168380011785556113bb565b828001600101855582156113bb579182015b828111156113ba57825182559160200191906001019061139f565b5b5090506113c891906114d7565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061140d57805160ff191683800117855561143b565b8280016001018555821561143b579182015b8281111561143a57825182559160200191906001019061141f565b5b50905061144891906114d7565b5090565b6204e20060405190810160405280612710905b600062ffffff1681526020019060019003908161145f5790505090565b602060405190810160405280600081525090565b608060405190810160405280600073ffffffffffffffffffffffffffffffffffffffff1681526020016114c16114fc565b8152602001600081526020016000151581525090565b6114f991905b808211156114f55760008160009055506001016114dd565b5090565b90565b6020604051908101604052806000815250905600a165627a7a72305820330b7b162016403273a1ad06f8fe60c7dadb44d4f75b3ee4fe71f28d2674a8c10029"}
動作サンプル
code:demo.js
$(document.body).append('<div><h1>eth_getCode</h1></div>')
$(document.body).append('<div>address: <input type="text" id="address" size="60"></input></div>')
$(document.body).append('<div><textarea id="result" cols="100" rows="30" readonly></textarea></div>')
$('#address').on('input', function(event) {
let address = $('#address').val()
if (address.length == 42) {
.then((response) => {
console.log(response)
$('#result').html(JSON.stringify(response, null, '\t'))
})
}
})
参考
メモ
#todo ただ、bytecode と完全に一致しているわけではない。ここでのコードが何を意味するか調べる。