eth_getCode
网络: BSC · 主网 · Chain ID 56(0x38)
计为 1 个 Request。 计费规则见 Request Counting。
返回指定地址的代码内容。可用于判断一个地址是否为智能合约地址。
参数
DATA(20 字节)— 目标地址。QUANTITY|TAG— 区块号,或"latest"、"earliest"、"pending"。
返回
DATA — 该地址上的代码。EOA(非合约地址)返回 0x。
请求
{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "latest"],
"id": 1
}响应
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x6080604052..."
}请把示例地址换成 BSC 上的合约地址。
若返回值为
"0x",表示该地址是 EOA(外部拥有账户),不是合约。
代码示例
curl -X POST https://bsc-rpc.blockreq.com/v1/rpc/public \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getCode","params":["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","latest"],"id":1}'