curl --request POST \
--url https://nd-363-550-219.p2pify.com/942aad90bb6a082676497030b81e40ba \
--header 'Content-Type: application/json' \
--data '{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",
"latest"
]
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": {}
}
curl --request POST \
--url https://nd-363-550-219.p2pify.com/942aad90bb6a082676497030b81e40ba \
--header 'Content-Type: application/json' \
--data '{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",
"latest"
]
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": {}
}
address
— the address of the smart contract to query.
quantity or tag
— the integer of a block encoded as hexadecimal or the string with:
latest
— the most recent block in the blockchain and the current state of the blockchain at the most recent block. A chain reorganization is to be expected.safe
— the block that received justification from the beacon chain. Although this block could be involved in a chain reorganization, it would necessitate either a coordinated attack by the majority of validators or an instance of severe propagation latency.finalized
— the block accepted as canonical by more than 2/3 of the validators. A chain reorganization is extremely unlikely, and it would require at least 1/3 of the staked ETH to be burned.earliest
— the earliest available or genesis blockpending
— the pending state and transactions block. The current state of transactions that have been broadcast to the network but have not yet been included in a block.data
— the compiled bytecode of a smart contract. Returns 0x
if the address is not associated with a smart contract.
eth_getCode
code examplesconst { Web3 } = require("web3");
const NODE_URL = "CHAINSTACK_NODE_URL";
const web3 = new Web3(NODE_URL);
async function getCode(address, block) {
const code = await web3.eth.getCode(address, block)
console.log(code)
}
getCode("0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9", "latest" )
eth_getcode
method is verifying whether an address is associated with a smart contract. This can be particularly useful for blockchain explorers, auditors, and DApp developers, who must ensure that the account they interact with is legitimate.The smart contract code.
The response is of type object
.
Was this page helpful?