Polygon
Polygon
准备好在生产环境中调用了吗?
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
Polygon
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
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.| # | 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|---|
| 1 | address | string (hex) | 是 | The address to read code from. |
| 2 | blockTag | string | 否 | Block at which to read the code.默认值: latest |
| 类型 | 描述 |
|---|---|
| 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.
| 错误码 | 错误信息 | 原因 |
|---|---|---|
-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.参数
0x-prefixed 20-byte address
hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"