> ## 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.

# eth_getCode | Monad

> Monad API method that returns the code at a given address. This is used to check if an address is a smart contract and retrieve its bytecode.

Monad API method that returns the code at a given address. This is used to check if an address is a smart contract and retrieve its bytecode.

<Note>
  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](/docs/request-units#archive-state-methods).
</Note>

## Parameters

* `data` — the 20-byte address.
* `quantity or tag` — integer block number, or the string `latest`, `earliest`, or `pending`.

## Response

* `result` — the code from the given address. Returns `0x` for externally owned accounts (EOAs).

## `eth_getCode` code examples

<CodeGroup>
  ```javascript ethers.js theme={"system"}
  const { ethers } = require("ethers");

  const provider = new ethers.JsonRpcProvider("CHAINSTACK_NODE_URL");

  async function getCode() {
    const address = "0xAc586b65F3cd0627D2D05AdB8EF551C9d2D76E12";
    const code = await provider.getCode(address);

    if (code === "0x") {
      console.log("Address is an EOA (not a contract)");
    } else {
      console.log(`Contract bytecode: ${code}`);
    }
  }

  getCode();
  ```

  ```python web3.py theme={"system"}
  from web3 import Web3

  node_url = "CHAINSTACK_NODE_URL"

  web3 = Web3(Web3.HTTPProvider(node_url))

  address = "0xAc586b65F3cd0627D2D05AdB8EF551C9d2D76E12"
  code = web3.eth.get_code(address)

  if code == b'':
      print("Address is an EOA (not a contract)")
  else:
      print(f'Contract bytecode: {code.hex()}')
  ```
</CodeGroup>

## Use case

A practical use case for `eth_getCode` is verifying whether an address is a smart contract before interacting with it, which helps prevent errors and potential security issues.


## OpenAPI

````yaml openapi/monad_node_api/accounts_info/eth_getCode.json POST /
openapi: 3.0.0
info:
  title: Monad Node API
  version: 1.0.0
  description: This is an API for interacting with a Monad node.
servers:
  - url: https://monad-testnet.core.chainstack.com/9c5b265f20b3ea5df4f54f70eb74b800
security: []
paths:
  /:
    post:
      tags:
        - Accounts info
      summary: eth_getCode
      operationId: eth_getCode
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: integer
                  default: 1
                jsonrpc:
                  type: string
                  default: '2.0'
                method:
                  type: string
                  default: eth_getCode
                params:
                  type: array
                  items:
                    type: string
                  default:
                    - '0xAc586b65F3cd0627D2D05AdB8EF551C9d2D76E12'
                    - latest
      responses:
        '200':
          description: The bytecode at the given address.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: string

````