> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cdp.coinbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Schema

The SQL API schema is a set of opinionated tables and columns used to organize onchain data for efficient retrieval.

## Supported Tables

| Table                                                            | Description                                                                                          |
| ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| [base.blocks](#base-blocks)                                      | Block metadata including timestamps, gas usage, and consensus fields                                 |
| [base.transactions](#base-transactions)                          | Transaction data including hash, block number, gas usage, and signatures                             |
| [base.events](#base-events)                                      | Decoded event logs with contract interactions on Base                                                |
| [base.encoded\_logs](#base-encoded-logs)                         | Encoded log data of event logs that aren't able to be decoded by our event decoder (ex: log0 opcode) |
| [base.decoded\_user\_operations](#base-decoded-user-operations)  | Decoded ERC-4337 user operations bundled into transactions                                           |
| [base.transaction\_attributions](#base-transaction-attributions) | Builder/searcher attribution metadata for transactions                                               |

## base.blocks

Block metadata including timestamps, gas usage, and consensus fields.

<Tip>
  See an example block on [Basescan](https://basescan.org/block/1000000) to understand how blockchain data corresponds to these SQL fields.
</Tip>

| Field                       | Type     | Description                                                         |
| --------------------------- | -------- | ------------------------------------------------------------------- |
| block\_number               | UInt64   | The sequential number of the block in the chain                     |
| block\_hash                 | String   | The keccak256 hash of the block header                              |
| parent\_hash                | String   | The keccak256 hash of the parent block header                       |
| timestamp                   | DateTime | The timestamp in UTC when the block was produced                    |
| miner                       | String   | The address of the miner/validator who produced the block           |
| nonce                       | UInt64   | The nonce used in the block proof-of-work (legacy, 0 post-merge)    |
| sha3\_uncles                | String   | The hash of the ommers/uncles list in the block                     |
| transactions\_root          | String   | The root of the transaction trie of the block                       |
| state\_root                 | String   | The root of the state trie after the block                          |
| receipts\_root              | String   | The root of the receipts trie of the block                          |
| logs\_bloom                 | String   | The bloom filter for log entries in the block                       |
| gas\_limit                  | UInt64   | The maximum gas allowed in the block                                |
| gas\_used                   | UInt64   | The total gas used by all transactions in the block                 |
| base\_fee\_per\_gas         | UInt64   | The base fee per gas in the block (EIP-1559)                        |
| total\_difficulty           | String   | The total difficulty of the chain up to this block                  |
| size                        | UInt64   | The size of the block in bytes                                      |
| extra\_data                 | String   | Arbitrary extra data included by the block producer                 |
| mix\_hash                   | String   | A hash used in the proof-of-work algorithm (legacy)                 |
| withdrawals\_root           | String   | The root hash of the withdrawals trie (EIP-4895)                    |
| parent\_beacon\_block\_root | String   | The root of the parent beacon block (EIP-4788)                      |
| blob\_gas\_used             | UInt64   | The total blob gas consumed by transactions in the block (EIP-4844) |
| excess\_blob\_gas           | UInt64   | The running total of excess blob gas after this block (EIP-4844)    |
| transaction\_count          | UInt64   | The number of transactions in the block                             |
| action                      | Int8     | Block state: 1=added to chain, -1=removed via re-org                |

## base.transactions

Transaction data including hash, block number, gas usage, and signatures.

<Tip>
  See an example transaction on [Basescan](https://basescan.org/tx/0x08ecc43f4394eb6a7c0c7bf89d4c95c2ba67a7d3ce9f08dc09c5f8c29b1e5de3) to understand how transaction data corresponds to these SQL fields.
</Tip>

<Note>
  `timestamp` on `base.blocks` and `base.transactions` is `DateTime` (second precision, server timezone), while `block_timestamp` on `base.events`, `base.encoded_logs`, `base.decoded_user_operations`, and `base.transaction_attributions` is `DateTime64(3, 'UTC')` (millisecond precision, UTC). When joining or comparing timestamps across these tables, cast explicitly (for example, `toDateTime64(timestamp, 3, 'UTC')`) to avoid precision loss or timezone surprises.
</Note>

| Field                        | Type          | Description                                                                 |
| ---------------------------- | ------------- | --------------------------------------------------------------------------- |
| block\_number                | UInt64        | The number of the block containing this transaction                         |
| block\_hash                  | String        | The hash of the block containing this transaction                           |
| transaction\_hash            | String        | The keccak256 hash of the transaction                                       |
| transaction\_index           | UInt64        | The index position of the transaction within the block                      |
| from\_address                | String        | The address that sent the transaction (EOA)                                 |
| to\_address                  | String        | The recipient address (EOA or contract). Empty for contract creation.       |
| value                        | String        | The value transferred in wei (decimal string)                               |
| gas                          | UInt64        | The gas limit provided by the sender                                        |
| gas\_price                   | UInt64        | The gas price in wei provided by the sender                                 |
| input                        | String        | The calldata sent with the transaction (hex-encoded)                        |
| nonce                        | UInt64        | The number of prior transactions from the sender                            |
| type                         | UInt64        | The EIP-2718 transaction type (0=legacy, 1=access list, 2=EIP-1559, 3=blob) |
| max\_fee\_per\_gas           | UInt64        | Maximum fee per gas the sender is willing to pay (EIP-1559)                 |
| max\_priority\_fee\_per\_gas | UInt64        | Maximum priority fee (tip) per gas for the validator (EIP-1559)             |
| chain\_id                    | UInt64        | The EIP-155 chain identifier                                                |
| v                            | String        | ECDSA signature recovery id                                                 |
| r                            | String        | ECDSA signature r value                                                     |
| s                            | String        | ECDSA signature s value                                                     |
| is\_system\_tx               | Bool          | Whether this is a system transaction (OP Stack)                             |
| max\_fee\_per\_blob\_gas     | String        | Maximum fee per blob gas the sender is willing to pay (EIP-4844)            |
| blob\_versioned\_hashes      | Array(String) | List of versioned blob hashes for blob transactions (EIP-4844)              |
| timestamp                    | DateTime      | The timestamp in UTC of the block containing this transaction               |
| action                       | Int8          | Transaction state: 1=added to chain, -1=removed via re-org                  |

## base.events

Decoded event logs with contract interactions on Base.

<Note>
  **B20 support:** All [B20 native token standard](https://docs.base.org/base-chain/specs/upgrades/beryl/b20) events—including token operations, factory deployments, and Policy Registry updates—are decoded into this table. See [Query B20 Events](/data/sql-api/b20-events) for indexed event signatures and example queries.
</Note>

<Warning>
  **Schema changes:** `timestamp` has been renamed to `block_timestamp`, and `transaction_index` has been removed. To retrieve a log's transaction position within its block, join to `base.transactions` on `transaction_hash` and select `transaction_index` from there.
</Warning>

<Tip>
  See example events on [Basescan](https://basescan.org/tx/0x08ecc43f4394eb6a7c0c7bf89d4c95c2ba67a7d3ce9f08dc09c5f8c29b1e5de3#eventlog) to see how event logs appear on the blockchain.
</Tip>

| Field             | Type                                                | Description                                                                                                                                                                                                          |
| ----------------- | --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| log\_id           | String                                              | A unique identifier for the log. It is derived from information inherent to the log, so if a log is processed multiple times, the unique log id will be the same.                                                    |
| block\_number     | UInt64                                              | The number of the block that the log is in                                                                                                                                                                           |
| block\_hash       | FixedString(66)                                     | The hash of the block that the log is in                                                                                                                                                                             |
| block\_timestamp  | DateTime64(3, 'UTC')                                | The timestamp in UTC of the block that the log is in                                                                                                                                                                 |
| transaction\_hash | FixedString(66)                                     | The hash of the transaction that the log is in                                                                                                                                                                       |
| transaction\_to   | FixedString(42)                                     | The address the transaction is acting against. Could be either an EOA (ex: ETH transfer) or a contract (ex: smart contract call).                                                                                    |
| transaction\_from | FixedString(42)                                     | The address that originated the transaction. Will be an EOA.                                                                                                                                                         |
| log\_index        | UInt32                                              | The index of the log within the transaction. First log is in the transaction at index 0, second is index 1, etc.                                                                                                     |
| address           | FixedString(42)                                     | The address of the contract that the log was created from                                                                                                                                                            |
| topics            | Array(FixedString(66))                              | The topics of the log. Topics are the indexed parameters of the event and the keccak256 hash of the event signature.                                                                                                 |
| event\_name       | LowCardinality(String)                              | The name of the event. Ex: `Transfer`                                                                                                                                                                                |
| event\_signature  | LowCardinality(String)                              | The signature of the event. Ex: `Transfer(address,address,uint256)`                                                                                                                                                  |
| parameters        | Map(String, Variant(Bool, Int256, String, UInt256)) | Map of parameter name to its value. Ex: `{"from": "0x1234...", "to": "0x1234...", "value": "1000000000000000000"}`                                                                                                   |
| parameter\_types  | Map(String, String)                                 | Map of parameter name to its ABI type                                                                                                                                                                                |
| action            | Enum8('removed' = -1, 'added' = 1)                  | If the log is created, it is 1. If the log is re-orged out it is -1. If the sum of all actions for a given log is greater than 0, the log is "active", meaning it is still in the chain (has not been re-orged out). |

## base.encoded\_logs

Encoded log data of event logs that aren't able to be decoded by our event decoder (ex: log0 opcode).

| Field             | Type                               | Description                                                                                                                                                                                                          |
| ----------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| log\_id           | String                             | A unique identifier for the log. It is derived from information inherent to the log, so if a log is processed multiple times, the unique log id will be the same.                                                    |
| block\_number     | UInt64                             | The number of the block that the log is in                                                                                                                                                                           |
| block\_hash       | FixedString(66)                    | The hash of the block that the log is in                                                                                                                                                                             |
| block\_timestamp  | DateTime64(3, 'UTC')               | The timestamp in UTC of the block that the log is in                                                                                                                                                                 |
| transaction\_hash | FixedString(66)                    | The hash of the transaction that the log is in                                                                                                                                                                       |
| transaction\_to   | FixedString(42)                    | The address the transaction is acting against. Could be either an EOA (ex: ETH transfer) or a contract (ex: smart contract call).                                                                                    |
| transaction\_from | FixedString(42)                    | The address that originated the transaction. Will be an EOA.                                                                                                                                                         |
| log\_index        | UInt32                             | The index of the log within the transaction. First log is in the transaction at index 0, second is index 1, etc.                                                                                                     |
| address           | FixedString(42)                    | The address of the contract that the log was created from                                                                                                                                                            |
| topics            | Array(FixedString(66))             | The topics of the log. Topics are the indexed parameters of the event and the keccak256 hash of the event signature.                                                                                                 |
| action            | Enum8('removed' = -1, 'added' = 1) | If the log is created, it is 1. If the log is re-orged out it is -1. If the sum of all actions for a given log is greater than 0, the log is "active", meaning it is still in the chain (has not been re-orged out). |

## base.decoded\_user\_operations

Decoded [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337) user operations bundled into Base transactions.

| Field                 | Type                                              | Description                                                                       |
| --------------------- | ------------------------------------------------- | --------------------------------------------------------------------------------- |
| block\_number         | UInt64                                            | The number of the block containing the bundle transaction                         |
| block\_timestamp      | DateTime64(3, 'UTC')                              | The timestamp in UTC of the block containing the bundle transaction               |
| transaction\_hash     | FixedString(66)                                   | The hash of the bundle transaction containing the user operation                  |
| transaction\_index    | UInt32                                            | The index of the bundle transaction within the block                              |
| user\_op\_hash        | FixedString(66)                                   | The unique hash identifying the user operation                                    |
| bundler               | FixedString(42)                                   | The address of the bundler that submitted the bundle transaction                  |
| entry\_point          | FixedString(42)                                   | The address of the EntryPoint contract that executed the user operation           |
| entry\_point\_version | LowCardinality(String)                            | The version of the EntryPoint contract (ex: `v0.6`, `v0.7`)                       |
| beneficiary           | FixedString(42)                                   | The address designated to receive the gas refund for the bundle                   |
| method\_name          | Enum8('handleOps' = 1, 'handleAggregatedOps' = 2) | The EntryPoint method invoked to execute the bundle                               |
| method\_signature     | LowCardinality(String)                            | The full canonical signature of the invoked EntryPoint method                     |
| sender                | FixedString(42)                                   | The smart account address that originated the user operation                      |
| user\_op\_data        | String                                            | The raw, encoded user operation payload                                           |
| actual\_gas\_cost     | String                                            | The actual gas cost paid for executing the user operation (decimal string in wei) |
| actual\_gas\_used     | String                                            | The actual amount of gas consumed by the user operation (decimal string)          |
| success               | Enum8('failure' = 0, 'success' = 1)               | Whether the user operation executed successfully                                  |
| builder\_codes        | Array(LowCardinality(String))                     | Builder attribution codes associated with the user operation                      |
| annotation\_data      | String                                            | Additional annotation metadata for the user operation                             |
| action                | Int8                                              | User operation state: 1=added to chain, -1=removed via re-org                     |

## base.transaction\_attributions

Builder/searcher attribution metadata for Base transactions.

| Field              | Type                   | Description                                                          |
| ------------------ | ---------------------- | -------------------------------------------------------------------- |
| builder\_code      | LowCardinality(String) | Identifier code attributing the transaction to a builder or searcher |
| block\_timestamp   | DateTime64(3, 'UTC')   | The timestamp in UTC of the block containing the transaction         |
| block\_number      | UInt64                 | The number of the block containing the transaction                   |
| transaction\_hash  | FixedString(66)        | The hash of the attributed transaction                               |
| transaction\_index | UInt32                 | The index of the attributed transaction within the block             |
| action             | Int8                   | Attribution state: 1=added to chain, -1=removed via re-org           |
| annotation\_data   | String                 | Additional annotation metadata for the attribution                   |
| ingested\_at       | DateTime64(3, 'UTC')   | The timestamp in UTC when the attribution record was ingested        |
