# eth\_getCode

Returns code at a given address.

## **Parameters**

1. `DATA`, 20 Bytes - address
2. `QUANTITY|TAG` - integer block number, or the string `"latest"`, `"earliest"` or `"pending"`, see the [default block parameter](https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block)

## Returns

`DATA` - the code from the given address.

## Example

*NOTE:* In this example we are using public Ethereum endpoint. Ideally, for your own projects, you should use your own endpoint, which you can generate for free by connecting to your wallet [here](https://www.noderpc.xyz/).

{% tabs %}
{% tab title="ethers" %}

### Query

*NOTE:* `ethers` used below is a well-known web3 library, check it out [here](https://github.com/ethers-io/ethers.js/).

```javascript
import { ethers } from 'ethers';

const provider =
  new ethers
    .providers
    .JsonRpcProvider("https://www.noderpc.xyz/rpc-mainnet/public")

provider.send('eth_getCode', ["0x5B56438000bAc5ed2c6E0c1EcFF4354aBfFaf889", "latest"]).then((result) => {
  console.log(result);
});

```

### Result

{% code overflow="wrap" %}

```json
0x6080604052600436106100555760003560e01c80631fa772501461005a57806341c0e1b51461012e5780634671212a14610145578063a034e82f146101b1578063c5afaeeb1461030f578063d6a10612146103d6575b600080fd5b34801561006657600080fd5b506100b36004803603604081101561007d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f35780820151818401526020810190506100d8565b50505050905090810190601f1680156101205780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013a57600080fd5b506101436105dd565b005b34801561015157600080fd5b5061015a610670565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561019d578082015181840152602081019050610182565b505050509050019250505060405180910390f35b61030d600480360360608110156101c757600080fd5b81019080803590602001906401000000008111156101e457600080fd5b8201836020820111156101f657600080fd5b8035906020019184600183028401116401000000008311171561021857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561027b57600080fd5b82018360208201111561028d57600080fd5b803590602001918460018302840111640100000000831117156102af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035151590602001909291905050506106fe565b005b6103d46004803603604081101561032557600080fd5b810190808035906020019064010000000081111561034257600080fd5b82018360208201111561035457600080fd5b8035906020019184600183028401116401000000008311171561037657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803515159060200190929190505050610b46565b005b3480156103e257600080fd5b5061049c600480360360208110156103f957600080fd5b810190808035906020019064010000000081111561041657600080fd5b82018360208201111561042857600080fd5b8035906020019184600183028401116401000000008311171561044a57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050610b71565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104dc5780820151818401526020810190506104c1565b50505050905090810190601f1680156105095780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6001602052816000526040600020818154811061053057fe5b90600052602060002001600091509150508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105d55780601f106105aa576101008083540402835291602001916105d5565b820191906000526020600020905b8154815290600101906020018083116105b857829003601f168201915b505050505081565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561066e57600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060028054806020026020016040519081016040528092919081815260200182805480156106f457602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116106aa575b5050505050905090565b60008090506000836040518082805190602001908083835b602083106107395780518252602082019150602081019050602083039250610716565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902060020160009054906101000a900460ff16610b405760405180608001604052803373ffffffffffffffffffffffffffffffffffffffff16815260200185815260200160011515815260200183806107c05750825b15158152506000846040518082805190602001908083835b602083106107fb57805182526020820191506020810190506020830392506107d8565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001019080519060200190610891929190610e88565b5060408201518160020160006101000a81548160ff02191690831515021790555060608201518160020160016101000a81548160ff021916908315150217905550905050600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002083908060018154018082558091505090600182039060005260206000200160009091929091909150908051906020019061094f929190610f08565b505060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490501015610a025760023390806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505b7f5c9498f331ff3062bd1b207f8738918bb293212577e936f80ed6674a1f0c4a258484336040518080602001806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838103835286818151815260200191508051906020019080838360005b83811015610a9c578082015181840152602081019050610a81565b50505050905090810190601f168015610ac95780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b83811015610b02578082015181840152602081019050610ae7565b50505050905090810190601f168015610b2f5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a15b50505050565b60008090506060610b5684610cda565b9050610b6b84828580610b665750845b6106fe565b50505050565b6060600080836040518082805190602001908083835b60208310610baa5780518252602082019150602081019050602083039250610b87565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902090508060020160009054906101000a900460ff1615610c9b57806001018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c8e5780601f10610c6357610100808354040283529160200191610c8e565b820191906000526020600020905b815481529060010190602001808311610c7157829003601f168201915b5050505050915050610cd5565b6040518060400160405280600481526020017f4641494c000000000000000000000000000000000000000000000000000000008152509150505b919050565b606060006002836040516020018082805190602001908083835b60208310610d175780518252602082019150602081019050602083039250610cf4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b60208310610d7e5780518252602082019150602081019050602083039250610d5b565b6001836020036101000a038019825116818451168082178552505050505050905001915050602060405180830381855afa158015610dc0573d6000803e3d6000fd5b5050506040513d6020811015610dd557600080fd5b810190808051906020019092919050505090506000600f905060007fffffff000000000000000000000000000000000000000000000000000000000060001b9050806006830284901b1660405160200180827cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191681526003019150506040516020818303038152906040529350505050919050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610ec957805160ff1916838001178555610ef7565b82800160010185558215610ef7579182015b82811115610ef6578251825591602001919060010190610edb565b5b509050610f049190610f88565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610f4957805160ff1916838001178555610f77565b82800160010185558215610f77579182015b82811115610f76578251825591602001919060010190610f5b565b5b509050610f849190610f88565b5090565b610faa91905b80821115610fa6576000816000905550600101610f8e565b5090565b9056fea265627a7a72315820891f46bb3aaa4cdf8cdfbaa65e75646a76f6d0a504a304b4e2e8967ea03bd5e964736f6c63430005110032
```

{% endcode %}
{% endtab %}
{% endtabs %}

###


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.noderpc.xyz/node-rpc/ethereum-api-endpoints/eth_getcode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
