参数
addressstring必填- 20-byte address, hex encoded.
blockstring必填- Block number in hex (e.g. "0x1208a5f") or a tag: "latest", "safe", "finalized", "earliest" or "pending". L0vd endpoints run archive nodes, so any historical block works.
返回值
string Runtime bytecode, hex encoded.
适用场景
Check whether an address is a contract and read its runtime bytecode at a block.
With a past block, learn when a contract was deployed (binary-search for the first block where code is not 0x) or what a proxy pointed to before an upgrade.
如何解读结果
"0x" means no code: an externally owned account, a contract not yet deployed, or one destroyed at that block.
Otherwise the hex string is the deployed runtime bytecode, not the constructor code you compiled.
提示
- Bytecode of large contracts is tens of kilobytes; fetch it once and cache it by address and code hash.
- For upgradeable proxies read the implementation slot with eth_getStorageAt (EIP-1967: 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc).