Optimism
هل أنت مستعد لاستدعاء هذا في الإنتاج؟
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
Optimism
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
eth_getCode returns the EVM bytecode deployed at an address on OP Mainnet, captured at whichever block you specify. Because OP Mainnet runs the OP Stack (Bedrock) and stays EVM-equivalent with Ethereum L1, the bytecode for a contract such as a Velodrome pool or a Synthetix module is identical in form to what you would read on L1, while gas is still paid in ETH. Point the request at https://optimism.therpc.io/YOUR_API_KEY (chain ID 10, 0xa). The response is the hex-encoded bytecode at the given address and block, or 0x when there is no code there.
0x.| # | الاسم | النوع | مطلوب | الوصف |
|---|---|---|---|---|
| 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 Optimism 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 covers both EOAs and self-destructed contracts on OP Mainnet — absence of code alone does not tell you which case you hit.eth_getStorageAt) to read the logic contract.المعاملات
0x-prefixed 20-byte address
hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"