📄 Database Structure: contracts Table
This document describes the structure and purpose of the contracts table within the databases.
The table stores metadata and deployment details of smart contracts.
📌 Table Description
Each record stored in the table has the following structure and fields, with described constraints.
| Column Name | Type | Constraints | Description - |
|---|---|---|---|
address |
TEXT | PRIMARY KEY | The unique address of the smart contract on the blockchain. |
creator |
TEXT | NOT NULL | The address of the account that deployed the contract. |
creation_tx |
TEXT | NOT NULL | The transaction hash that created the contract. |
creation_time |
TIMESTAMP | NOT NULL | The timestamp when the contract was deployed. |
creation_block |
INTEGER | NOT NULL | The block number in which the contract was created. |
name |
TEXT | NULLABLE | The human-readable name of the contract, if available. |
source_code |
TEXT | NULLABLE | The full Solidity source code of the contract. |
abi |
TEXT | NULLABLE | The Application Binary Interface (ABI) of the contract. |
compiler_version |
TEXT | NULLABLE | The Solidity compiler version used to compile the contract. |
evm_version |
TEXT | NULLABLE | The targeted Ethereum Virtual Machine (EVM) version. |
optimization_used |
BOOLEAN | NULLABLE | Indicates whether compiler optimizations were enabled. |
runs |
INTEGER | NULLABLE | Number of optimization runs used during compilation. |
constructor_args |
TEXT | NULLABLE | Encoded constructor arguments passed during deployment. |
library |
TEXT | NULLABLE | Linked library information, if any. |
license |
TEXT | NULLABLE | License type of the source code (e.g., MIT, GPL-3.0). |
is_proxy |
BOOLEAN | NULLABLE | Flag indicating whether the contract is a proxy. |
implementation |
TEXT | NULLABLE | Address of the implementation contract, if this is a proxy. |
swarm_source |
TEXT | NULLABLE | Swarm hash / metadata URL pointing to the source code bundle. |
📝 Notes:
- The primary key
addressensures uniqueness for each deployed contract in the corresponding chain. creation_tx,creation_time, andcreation_blockstores contract’s deployment information, i.e. transaction id, timestamp, and block number.source_code,abi, andcompiler_versionare typically available when the contract has been verified.- Proxy patterns are identified through
is_proxyandimplementation.
🧱 Table Definition
CREATE TABLE IF NOT EXISTS contracts (
address TEXT PRIMARY KEY,
creator TEXT NOT NULL,
creation_tx TEXT NOT NULL,
creation_time TIMESTAMP NOT NULL,
creation_block INTEGER NOT NULL,
name TEXT,
source_code TEXT,
abi TEXT,
compiler_version TEXT,
evm_version TEXT,
optimization_used BOOLEAN,
runs INTEGER,
constructor_args TEXT,
library TEXT,
license TEXT,
is_proxy BOOLEAN,
implementation TEXT,
swarm_source TEXT
);
🧭 Usage Example
SELECT address, name, compiler_version, source_code
FROM contracts
WHERE source_code IS NOT NULL AND source_code != ""
ORDER BY creation_block DESC
LIMIT 10;
This query returns the 10 most recently deployed contracts with available source code along with their addresses, names and compiler versions.