Ethereum
¿Listo para usar esto en producción?
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
Ethereum
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
eth_getCode returns the EVM bytecode living at an address on Ethereum mainnet (chain ID 1), the network where every contract call and deployment is paid for in ETH. Pass an address and a block, and the node reads the codeHash recorded in that account's state and hands back the actual bytecode behind it. Externally owned accounts hold no code, so they answer 0x; a deployed contract answers with its full runtime bytecode. Point the call at https://ethereum.therpc.io/YOUR_API_KEY, and because the block argument is honoured, you can read the code as it stood at any height, not just the chain head.
0x answer means an EOA, anything longer means deployed code. Wallets gate "this is a smart contract" warnings on exactly this check.SELFDESTRUCTed at a given height by reading its code at that block and seeing 0x come back where bytecode used to be.| # | Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|---|
| 1 | address | string (hex) | Sí | The address to read code from. |
| 2 | blockTag | string | No | Block at which to read the code.Predeterminado: latest |
| Tipo | Descripción |
|---|---|
| string (hex) | Hex-encoded EVM bytecode, or "0x" if the address is an EOA, the contract was self-destructed, or no code existed at that block. |
Try it live in the Ethereum playground.
| Código | Mensaje | Causa |
|---|---|---|
-32602 | Invalid params | Address is malformed or block tag is unrecognised. |
-32000 | Missing trie node | Historical block has been pruned on a non-archive node. |
0x is ambiguous: a never-deployed EOA and a contract that already self-destructed look identical. To tell them apart you need history — read the code at an earlier block, or check whether the account ever had a non-empty codeHash.eth_getStorageAt first, then call eth_getCode on that address.-32000 missing-trie-node error instead of bytecode.Parámetros
0x-prefixed 20-byte address
hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"