ots
ots_hasCode
Checks whether an address contains contract code at the specified block. This is a lightweight alternative to calling eth_getCode and checking if the result is empty.
Checks whether an address contains contract code at the specified block. This is a lightweight alternative to calling eth_getCode and checking if the result is empty.
Parameters
| # | Type | Description |
|---|---|---|
| 1 | string | Address to check. |
| 2 | string | Block tag ("latest", "earliest") or hex block number. |
Returns
| Type | Description |
|---|---|
boolean | true if the address has deployed contract code, false for externally-owned accounts (EOAs). |
Example
curl -s -X POST https://rpc.pulsechain.box \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "ots_hasCode",
"params": [
"0x2b591e99afE9f32eAA6214f7B7629768c40Eeb39",
"latest"
],
"id": 1
}'
{
"jsonrpc": "2.0",
"id": 1,
"result": true
}
TRY IT
Notes
- Returns
falsefor addresses that have never been used or are standard EOA wallets. - Since this is an archive node, you can query any historical block number to check whether an address had code at that point in time.
- More efficient than
eth_getCodewhen you only need a boolean answer.
