Polygon
¿Listo para usar esto en producción?
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
Polygon
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
eth_getCode returns the EVM bytecode deployed at an address on Polygon PoS (chain ID 137), the high-throughput EVM-equivalent network where MATIC is the gas token. Because Polygon hosts the same contracts as Ethereum — Aave, QuickSwap, the canonical USDC and USDT bridges — this call is the quickest way to tell whether an address is a smart contract or a plain externally owned account, and to grab the exact bytecode running at a chosen block. Point the request at https://polygon.therpc.io/YOUR_API_KEY and it answers with hex-encoded bytecode, or 0x when nothing is deployed there.
0x result means no code, anything longer means a deployed contract — handy before treating a Polygon address as an Aave pool or QuickSwap router.eth_getCode at that historical height.| # | 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 Polygon 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 result is ambiguous: it means the same thing for a never-used EOA and for a contract that was self-destructed — code absence alone does not tell the two cases apart.eth_getStorageAt to find the logic contract.eth_getCode at an old Polygon block requires an archive node; a pruned full node returns a missing-trie-node error for historical state.Parámetros
0x-prefixed 20-byte address
hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"