Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,77 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 📄 Database Structure: `contracts` Table
|
| 2 |
+
|
| 3 |
+
This document describes the structure and purpose of the `contracts` table within the databases.
|
| 4 |
+
The table stores metadata and deployment details of smart contracts.
|
| 5 |
+
|
| 6 |
+
## 📌 Table Description
|
| 7 |
+
|
| 8 |
+
Each record stored in the table has the following structure and fields, with described constraints.
|
| 9 |
+
|
| 10 |
+
| Column Name | Type | Constraints | Description - |
|
| 11 |
+
|---------------------|------------|---------------------|-----------------------------------------------------------------------------|
|
| 12 |
+
| `address` | TEXT | PRIMARY KEY | The unique address of the smart contract on the blockchain. |
|
| 13 |
+
| `creator` | TEXT | NOT NULL | The address of the account that deployed the contract. |
|
| 14 |
+
| `creation_tx` | TEXT | NOT NULL | The transaction hash that created the contract. |
|
| 15 |
+
| `creation_time` | TIMESTAMP | NOT NULL | The timestamp when the contract was deployed. |
|
| 16 |
+
| `creation_block` | INTEGER | NOT NULL | The block number in which the contract was created. |
|
| 17 |
+
| `name` | TEXT | NULLABLE | The human-readable name of the contract, if available. |
|
| 18 |
+
| `source_code` | TEXT | NULLABLE | The full Solidity source code of the contract. |
|
| 19 |
+
| `abi` | TEXT | NULLABLE | The Application Binary Interface (ABI) of the contract. |
|
| 20 |
+
| `compiler_version` | TEXT | NULLABLE | The Solidity compiler version used to compile the contract. |
|
| 21 |
+
| `evm_version` | TEXT | NULLABLE | The targeted Ethereum Virtual Machine (EVM) version. |
|
| 22 |
+
| `optimization_used` | BOOLEAN | NULLABLE | Indicates whether compiler optimizations were enabled. |
|
| 23 |
+
| `runs` | INTEGER | NULLABLE | Number of optimization runs used during compilation. |
|
| 24 |
+
| `constructor_args` | TEXT | NULLABLE | Encoded constructor arguments passed during deployment. |
|
| 25 |
+
| `library` | TEXT | NULLABLE | Linked library information, if any. |
|
| 26 |
+
| `license` | TEXT | NULLABLE | License type of the source code (e.g., MIT, GPL-3.0). |
|
| 27 |
+
| `is_proxy` | BOOLEAN | NULLABLE | Flag indicating whether the contract is a proxy. |
|
| 28 |
+
| `implementation` | TEXT | NULLABLE | Address of the implementation contract, if this is a proxy. |
|
| 29 |
+
| `swarm_source` | TEXT | NULLABLE | Swarm hash / metadata URL pointing to the source code bundle. |
|
| 30 |
+
|
| 31 |
+
📝 Notes:
|
| 32 |
+
- The **primary key** `address` ensures uniqueness for each deployed contract in the corresponding chain.
|
| 33 |
+
- `creation_tx`, `creation_time`, and `creation_block` stores contract’s deployment information, i.e. transaction id, timestamp, and block number.
|
| 34 |
+
- `source_code`, `abi`, and `compiler_version` are typically available when the contract has been verified.
|
| 35 |
+
- Proxy patterns are identified through `is_proxy` and `implementation`.
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
## 🧱 Table Definition
|
| 39 |
+
|
| 40 |
+
```sql
|
| 41 |
+
CREATE TABLE IF NOT EXISTS contracts (
|
| 42 |
+
address TEXT PRIMARY KEY,
|
| 43 |
+
creator TEXT NOT NULL,
|
| 44 |
+
creation_tx TEXT NOT NULL,
|
| 45 |
+
creation_time TIMESTAMP NOT NULL,
|
| 46 |
+
creation_block INTEGER NOT NULL,
|
| 47 |
+
name TEXT,
|
| 48 |
+
source_code TEXT,
|
| 49 |
+
abi TEXT,
|
| 50 |
+
compiler_version TEXT,
|
| 51 |
+
evm_version TEXT,
|
| 52 |
+
optimization_used BOOLEAN,
|
| 53 |
+
runs INTEGER,
|
| 54 |
+
constructor_args TEXT,
|
| 55 |
+
library TEXT,
|
| 56 |
+
license TEXT,
|
| 57 |
+
is_proxy BOOLEAN,
|
| 58 |
+
implementation TEXT,
|
| 59 |
+
swarm_source TEXT
|
| 60 |
+
);
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
## 🧭 Usage Example
|
| 64 |
+
|
| 65 |
+
```sql
|
| 66 |
+
SELECT address, name, compiler_version, source_code
|
| 67 |
+
FROM contracts
|
| 68 |
+
WHERE source_code IS NOT NULL AND source_code != ""
|
| 69 |
+
ORDER BY creation_block DESC
|
| 70 |
+
LIMIT 10;
|
| 71 |
+
```
|
| 72 |
+
This query returns the 10 most recently deployed contracts with available **source code** along with their addresses, names and compiler versions.
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
---
|
| 76 |
+
license: mit
|
| 77 |
+
---
|