We're now supporting Polygon zkEVM!
Learn more here.

Contents

eth_getCode RPC Method

The API credit value for this method is 2 . To learn more about API credits and each method's value, visit the API Credits page.

Parameters:

  1. address - string - The address of the smart contract from which the bytecode will be obtained
  2. blockNumber - string - The block number as a string in hexadecimal format or tags. The supported tag values include earliest for the earliest/genesis block, latest for the latest mined block, pending for the pending state/transactions, safe for the most recent secure block, and finalized for the most recent secure block accepted by more than 2/3 of validators. safe and finalized are only supported on Ethereum, Gnosis, Arbitrum, Arbitrum Nova, and Avalanche C-chain

Returns:

  1. result - The bytecode from a given address returned as a string

Code Examples:

require 'eth'

client = Eth::Client.create 'http://sample-endpoint-name.network.quiknode.pro/token-goes-here/'
payload = {
    "jsonrpc": "2.0",
    "method": "eth_getCode",
    "params": ["0x5B56438000bAc5ed2c6E0c1EcFF4354aBfFaf889", "latest"],
    "id": "1"
}

response = client.send(payload.to_json)
puts response
Ready to get started? Create a free account