# Ethereum eth_getCode RPC method
Ethereum API method that returns the compiled bytecode of a smart contract.
Parameters:
address
— the address of the smart contract to retrieve the bytecode from.quantity or tag
— the integer block number, or the string with:latest
— the latest block that is to be validated. The Beacon Chain may reorg and the latest block can become orphaned.safe
— the block that is equal to the tip of the chain and is very unlikely to be orphaned.finalized
— the block that is accepted by the two thirds of the Ethereum validators.earliest
— the genesis block.pending
— the pending state and transactions block.
Returns:
result
— the string value of the compiled bytecode.
Example:
The example retrieves the bytecode of the Uniswap token (opens new window) at the state of the latest block.
Information
cURL needs a HEX String
starting with 0x
to identify the block if you want to use a hex integer block number as a parameter.
For example, block number 14000000
will be 0xD59F80
.
- web3.js
- web3.py
- eth.rb
- cURL
const Web3 = require("web3");
const node_url = "CHAINSTACK_NODE_URL";
const web3 = new Web3(node_url);
web3.eth.getCode("0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", "latest", (err, byte) => {
console.log(byte)
})