eth_getCode
Accounts info | Arbitrum
eth_getCode | Arbitrum
Arbitrum API method that retrieves the compiled bytecode of a smart contract providing its address as a parameter. Arbitrum via Chainstack.
POST
eth_getCode
Arbitrum API method that retrieves the compiled bytecode of a smart contract providing its address as a parameter. This method returns a hexadecimal string representing the smart contract’s bytecode. Developers can use this bytecode to verify if a smart contract is legitimate and to ensure that it performs the intended functions.Documentation Index
Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
Use this file to discover all available pages before exploring further.
When called against a block older than the latest ~128 blocks, this method is treated as an archive request (2 RUs instead of 1 RU). See request units.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.
Parameters
-
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 blockearliest— 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.
See the default block parameter.
Response
data — the compiled bytecode of a smart contract. Returns 0x if the address is not associated with a smart contract.
eth_getCode code examples
The following example retrieves the compiled bytecode from the UNI token smart contract.
Use case
A practical use case for theeth_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 code they interact with is legitimate.
Here is an example using web3.js:
index.js
verifyContractAddress function takes an address as a parameter and returns a boolean value indicating whether the address is associated with a smart contract. The function works by using the web3.eth.getCode method to retrieve the bytecode of the contract associated with the given address. If the returned bytecode is not equal to 0x, then the function assumes that the address is associated with a smart contract and returns true. If an error occurs while calling web3.eth.getCode, the function returns false and logs the error message to the console.
The main function is responsible for calling verifyContractAddress with a specific address to verify and log the results to the console. In this example, main is set up to verify the address 0xc094fd7ef80be094f3d98e227a487490ab1f9b9c. After calling verifyContractAddress, main logs either a success message indicating that the address is associated with a smart contract or a warning message indicating that it is not.
Overall, this code provides a useful utility for verifying the legitimacy of smart contract addresses on the Arbitrum blockchain. It can be useful for auditors, blockchain explorers, and DApp developers who want to ensure that they are interacting with trustworthy code on the blockchain.Last modified on May 18, 2026