Web3API
HomeAPI EndpointsContactTwitter
  • ​🚀 Welcome to Web3API
  • Introduction
    • ✨Getting Started
    • 📡 Choosing A Network
  • Developers
    • 🔌API Endpoints
      • eth_hashrate
      • eth_gasPrice
      • eth_blockNumber
      • eth_getBalance
      • eth_getStorageAt
      • eth_getTransactionCount
      • eth_getBlockTransactionCountByHash
      • eth_getBlockTransactionCountByNumber
      • eth_getCode
      • eth_sendRawTransaction
      • eth_call
      • eth_getBlockByHash
      • eth_getBlockByNumber
      • eth_getTransactionByHash
      • eth_getTransactionByBlockHashAndIndex
      • eth_getTransactionByBlockNumberAndIndex
      • eth_getTransactionReceipt
      • eth_getUncleByBlockHashAndIndex
      • eth_getUncleByBlockNumberAndIndex
      • eth_getUncleCountByBlockHash
      • eth_getUncleCountByBlockNumber
      • eth_estimateGas
      • eth_syncing
    • 😟API Errors and Troubleshooting
  • Tutorials
    • ⚡Adding a Custom RPC to Metamask
  • Dashboard
    • 🔑Forgot Password
  • Resources
    • ❓ FAQ
    • 🤝 Support
Powered by GitBook
On this page

Was this helpful?

  1. Developers
  2. API Endpoints

eth_getCode

Returns the compiled smart contract code, if any, at a given address.

Example

## using block numbers 

curl https://bsc-<network>.web3api.com/v1/YOUR-API-KEY 
-X POST 
-H "Content-Type: application/json"  
-d "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCode\",\"params\": [\"0x06012c8cf97bead5deae237070f9587f8e7a266d\", \"0x6DF5C6\"],\"id\":1}" 

## using pre-defined strings

curl https://bsc-<network>.web3api.com/v1/YOUR-API-KEY 
-X POST 
-H "Content-Type: application/json"  
-d "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCode\",\"params\": [\"0x06012c8cf97bead5deae237070f9587f8e7a266d\", \"latest\"],\"id\":1}"
## using block numbers 

curl -X POST 'https://bsc-<network>.web3api.com/v1/YOUR-API-KEY' \
-H 'Content-Type: application/json' \
--data-raw '{"jsonrpc":"2.0","method":"eth_getCode","params": ["0x06012c8cf97bead5deae237070f9587f8e7a266d", "0x6DF5C6"],"id":1}' 

## using pre-defined strings 

curl -X POST 'https://bsc-<network>.web3api.com/v1/YOUR-API-KEY' \
-H 'Content-Type: application/json' \
--data-raw '{"jsonrpc":"2.0","method":"eth_getCode","params": ["0x06012c8cf97bead5deae237070f9587f8e7a266d", "latest"],"id":1}' 
  1. ADDRESS - A string representing the address to check for code.

  2. BLOCK PARAMETER - An int block number in the form of hex, appended with 0x such as 0x6D7FE0, or pre-defined strings latest, earliest, pending.

Web3API's Composer accepts int block numbers, which will be auto-converted to a hex representation before being sent to a node.

Result Fields

CODE - A hex of the compiled smart contract code at the specified address. Empty entries are denoted with 0x.

Body

{
   "jsonrpc":"2.0",
   "id":1,
   "result":"0x"
}

Previouseth_getBlockTransactionCountByNumberNexteth_sendRawTransaction

Last updated 3 years ago

Was this helpful?

🔌