Polygon
Pronto para usar isso em produção?
O plano gratuito cobre projetos pessoais. O pay-as-you-go escala sem cartão de crédito.
Polygon
O plano gratuito cobre projetos pessoais. O pay-as-you-go escala sem cartão de crédito.
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.| # | Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|---|
| 1 | address | string (hex) | Sim | The address to read code from. |
| 2 | blockTag | string | Não | Block at which to read the code.Padrão: latest |
| Tipo | Descrição |
|---|---|
| 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 | Mensagem | 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"