| Yes | None | Error message. |
# Ethereum Schema
### Blocks
```sql
CREATE EXTERNAL TABLE `eth.blocks`(
`timestamp` timestamp,
`number` bigint,
`hash` string,
`parent_hash` string,
`nonce` string,
`sha3_uncles` string,
`logs_bloom` string,
`transactions_root` string,
`state_root` string,
`receipts_root` string,
`miner` string,
`difficulty` double,
`total_difficulty` double,
`size` bigint,
`extra_data` string,
`gas_limit` bigint,
`gas_used` bigint,
`transaction_count` bigint,
`base_fee_per_gas` bigint)
PARTITIONED BY (
`date` string)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
's3://aws-public-blockchain/v1.0/eth/blocks'
TBLPROPERTIES (
)
```
### Transactions
```sql
CREATE EXTERNAL TABLE `eth.transactions`(
`hash` string,
`nonce` bigint,
`transaction_index` bigint,
`from_address` string,
`to_address` string,
`value` double,
`gas` bigint,
`gas_price` bigint,
`input` string,
`receipt_cumulative_gas_used` bigint,
`receipt_gas_used` bigint,
`receipt_contract_address` string,
`receipt_root` string,
`receipt_status` bigint,
`block_timestamp` timestamp,
`block_number` bigint,
`block_hash` string,
`max_fee_per_gas` bigint,
`max_priority_fee_per_gas` bigint,
`transaction_type` bigint,
`receipt_effective_gas_price` bigint)
PARTITIONED BY (
`date` string)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
's3://aws-public-blockchain/v1.0/eth/transactions'
TBLPROPERTIES (
)
```
### Contracts
```sql
CREATE EXTERNAL TABLE `eth.contracts`(
`address` string,
`bytecode` string,
`block_timestamp` timestamp,
`block_number` bigint,
`block_hash` string)
PARTITIONED BY (
`date` string)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
's3://aws-public-blockchain/v1.0/eth/contracts'
TBLPROPERTIES (
)
```
### Logs
```sql
CREATE EXTERNAL TABLE `eth.logs`(
`log_index` bigint,
`transaction_hash` string,
`transaction_index` bigint,
`address` string,
`data` string,
`topics` array<string>,
`block_timestamp` timestamp,
`block_number` bigint,
`block_hash` string)
PARTITIONED BY (
`date` string)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
's3://aws-public-blockchain/v1.0/eth/logs'
TBLPROPERTIES (
)
```
### Token\_transfers
```sql
CREATE EXTERNAL TABLE `eth.token_transfers`(
`token_address` string,
`from_address` string,
`to_address` string,
`value` double,
`transaction_hash` string,
`log_index` bigint,
`block_timestamp` timestamp,
`block_number` bigint,
`block_hash` string)
PARTITIONED BY (
`date` string)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
's3://aws-public-blockchain/v1.0/eth/token_transfers'
TBLPROPERTIES (
)
```
### Traces
```sql
CREATE EXTERNAL TABLE `eth.traces`(
`transaction_hash` string,
`transaction_index` bigint,
`from_address` string,
`to_address` string,
`value` double,
`input` string,
`output` string,
`trace_type` string,
`call_type` string,
`reward_type` string,
`gas` double,
`gas_used` double,
`subtraces` bigint,
`trace_address` string,
`error` string,
`status` bigint,
`block_timestamp` timestamp,
`block_number` bigint,
`block_hash` string,
`trace_id` string)
PARTITIONED BY (
`date` string)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
's3://aws-public-blockchain/v1.0/eth/traces'
TBLPROPERTIES (
)
```
# Bitcoin Schema
### Blocks
```sql
CREATE EXTERNAL TABLE `btc.blocks`(
`hash` string,
`size` bigint,
`stripped_size` bigint,
`weight` bigint,
`number` bigint,
`version` bigint,
`merkle_root` string,
`timestamp` timestamp,
`nonce` bigint,
`bits` string,
`coinbase_param` string,
`transaction_count` bigint,
`mediantime` timestamp,
`difficulty` double,
`chainwork` string,
`previousblockhash` string)
PARTITIONED BY (
`date` string)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
's3://aws-public-blockchain/v1.0/btc/blocks'
TBLPROPERTIES (
)
```
### Transactions
```sql
CREATE EXTERNAL TABLE `transactions`(
`hash` string,
`size` bigint,
`virtual_size` bigint,
`version` bigint,
`lock_time` bigint,
`block_hash` string,
`block_number` bigint,
`block_timestamp` timestamp,
`index` bigint,
`input_count` bigint,
`output_count` bigint,
`input_value` double,
`output_value` double,
`is_coinbase` boolean,
`fee` double,
`inputs` array<struct<index:bigint,spent_transaction_hash:string,spent_output_index:bigint,script_asm:string,script_hex:string,sequence:bigint,required_signatures:bigint,type:string,address:string,value:double>>,
`outputs` array<struct<index:bigint,script_asm:string,script_hex:string,required_signatures:bigint,type:string,address:string,value:double>>)
PARTITIONED BY (
`date` string)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
's3://aws-public-blockchain/v1.0/btc/transactions'
TBLPROPERTIES (
)
```
# Base Schema
### Blocks
```sql
CREATE EXTERNAL TABLE IF NOT EXISTS sonarx_base.blocks (
block_number DECIMAL(38, 0),
timestamp DECIMAL(38, 0),
datetime TIMESTAMP,
block_hash STRING,
block_parent_hash STRING,
nonce DECIMAL(38, 0),
sha3_uncles STRING,
logs_bloom STRING,
transactions_root STRING,
state_root STRING,
receipts_root STRING,
miner STRING,
mix_hash STRING,
extra_data STRING,
difficulty DECIMAL(38, 0),
total_difficulty DECIMAL(38, 0),
size DECIMAL(38, 0),
gas_limit DECIMAL(38, 0),
gas_used DECIMAL(38, 0),
transaction_count DECIMAL(38, 0),
base_fee_per_gas DECIMAL(38, 0),
blob_gas_used DECIMAL(38, 0),
excess_blob_gas DECIMAL(38, 0),
parent_beacon_block_root STRING,
withdrawals_root STRING,
withdrawal_count DECIMAL(38, 0),
date_created TIMESTAMP,
date_updated TIMESTAMP)
PARTITIONED BY (
`date` STRING)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION 's3://aws-public-blockchain/v1.1/sonarx/base/blocks'
TBLPROPERTIES (
);
```
### Transactions
```sql
CREATE EXTERNAL TABLE IF NOT EXISTS sonarx_base.`transactions` (
block_number DECIMAL(38, 0),
datetime TIMESTAMP,
`timestamp` DECIMAL(38, 0),
transaction_hash STRING,
transaction_index DECIMAL(38, 0),
nonce DECIMAL(38, 0),
block_hash STRING,
from_address STRING,
to_address STRING,
value DOUBLE,
transaction_fee DOUBLE,
gas_price DOUBLE,
gas_price_gwei DOUBLE,
effective_gas_price DOUBLE,
effective_gas_price_gwei DOUBLE,
max_fee_per_gas DOUBLE,
max_fee_per_gas_gwei DOUBLE,
max_priority_fee_per_gas DOUBLE,
max_priority_fee_per_gas_gwei DOUBLE,
gas_limit DECIMAL(38, 0),
gas_used DECIMAL(38, 0),
gas_used_pct DECIMAL(38, 6),
cumulative_gas_used DECIMAL(38, 0),
input STRING,
transaction_type DECIMAL(38, 0),
contract_address STRING,
status DECIMAL(38, 0),
source_value DOUBLE,
deposit_receipt_version DECIMAL(38, 0),
mint DECIMAL(38, 0),
source_hash STRING,
y_parity DECIMAL(38, 0),
l1_gas_price DOUBLE,
l1_gas_price_gwei DOUBLE,
l1_gas_used DECIMAL(38, 0),
l1_fee_scalar DOUBLE,
l1_fee DOUBLE,
l2_fee DOUBLE,
deposit_nonce DECIMAL(38, 0),
date_created TIMESTAMP,
date_updated TIMESTAMP)
PARTITIONED BY (
`date` STRING)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION 's3://aws-public-blockchain/v1.1/sonarx/base/transactions'
TBLPROPERTIES (
);
```
# Solana Schema
### Blocks
```sql
CREATE EXTERNAL TABLE IF NOT EXISTS solana.blocks(
slot bigint,
block_hash string,
block_timestamp timestamp,
height bigint,
previous_block_hash string,
transaction_count bigint,
leader_reward DECIMAL(38, 0),
leader string
)
PARTITIONED BY (
`date` STRING)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION 's3://carv-dev-blockchain/solana/v1.0/blocks'
TBLPROPERTIES (
);
```
# On-chain Data SQL Query by LLM
### **POST /ai-agent-backend/sql\_query\_by\_llm**
This endpoint allows you to use the nature language to query the on-chain data. Behind the scean, CARV will use LLM model to interpreate the nature language input and convert into the sql query based on the above schemas.
#### Params
| Name | Location | Type | Required | Description |
| ------------- | -------- | ------ | -------- | ------------------------------- |
| question | query | string | no | ask question, return sql result |
| Authorization | header | string | yes | login token in redis |
| body | body | object | no | none |
| » question | body | string | yes | none |
#### **Example Request**
```http
curl -X POST https://interface.carv.io/ai-agent-backend/sql_query_by_llm \
-H "Content-Type: application/json" \
-H "Authorization: <YOUR_AUTH_TOKEN>" \
-d '{"question":"What's the most active address on Ethereum during the last 24 hours?"}'
```
> Response Examples
```json
{
"code": 0,
"msg": "Success",
"data": {
"column_infos": [
"hash",
"nonce",
"transaction_index",
"from_address",
"to_address",
"value",
"gas",
"gas_price",
"input",
"receipt_cumulative_gas_used",
"receipt_gas_used",
"receipt_contract_address",
"receipt_root",
"receipt_status",
"block_timestamp",
"block_number",
"block_hash",
"max_fee_per_gas",
"max_priority_fee_per_gas",
"transaction_type",
"receipt_effective_gas_price",
"date"
],
"rows": [
{
"items": [
"0x21a577613807eded967575e6350f927071ff440b1013067fe8fe738bf2e9cb7a",
"317711",
"0",
"0xca74f404e0c7bfa35b13b511097df966d5a65597",
"0x111111125421ca6dc452d289314280a0f8842a65",
"0.0",
"296049",
"899984959",
"0x07ed23790000000000000000000000005141b82f5ffda4c6fe1e372978f1c5427640a190000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000851f679a5edfb16e7cf1ad157c6995b7e7f333f20000000000000000000000005141b82f5ffda4c6fe1e372978f1c5427640a190000000000000000000000000ca74f404e0c7bfa35b13b511097df966d5a65597000000000000000000000000000000000000000000000000011c37937e0800000000000000000000000000000000000000000000000000000000b7ae8e38ec310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000005180000000000000000000000000000000000000000000004fa0004cc00003c4101c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200042e1a7d4d0000000000000000000000000000000000000000000000000000000000000000496066a9893cc07d91d95644aedd05d03f95e1dba8afeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee02e424856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003060b0e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000851f679a5edfb16e7cf1ad157c6995b7e7f333f2000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000c80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b5dcfc56c65f0000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000851f679a5edfb16e7cf1ad157c6995b7e7f333f2000000000000000000000000111111125421ca6dc452d289314280a0f8842a6500000000000000000000000000000000000000000000000000000000000000000020d6bdbf78851f679a5edfb16e7cf1ad157c6995b7e7f333f2111111125421ca6dc452d289314280a0f8842a650000000000000000fb39cfb5",
"174546",
"174546",
"",
"",
"1",
"2025-02-11 23:59:59.000",
"21826720",
"0xea513277ed1add2912cc96230a302f65a4fcbd0e8135da55e56cb3acebbf20ae",
"1217100000",
"100000000",
"2",
"899984959",
"2025-02-11"
]
},
{
"items": [
"0xbc5d47d72f253617b4bd1534b93cf39ae1678dd2866989171e2d04157692685d",
"135",
"25",
"0xdbb4754bedb8c28e7e7b25e4b85565b7fbcad1da",
"0x267be1c1d684f78cb4f6a176c4911b741e4ffdc0",
"1.19987609121647693E18",
"21000",
"5799984959",
"0x",
"4615886",
"21000",
"",
"",
"1",
"2025-02-11 23:59:59.000",
"21826720",
"0xea513277ed1add2912cc96230a302f65a4fcbd0e8135da55e56cb3acebbf20ae",
"5900418263",
"5000000000",
"2",
"5799984959",
"2025-02-11"
]
},
{
"items": [
"0x42d86916e29412544b4446ce2254322da8b5027961651fae0faee66e5e5e4eeb",
"1010",
"2",
"0x61c1162e6632b9055d154479fcebd161073f9279",
"0xa4eddfe4ba5143ac17fd6bc1e53de0384df8c660",
"0.0",
"230709",
"888984959",
"0x3df0212400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000016790dd900000000000000000000000000000000000000000000000000000000165becdd6",
"1557147",
"161293",
"",
"",
"1",
"2025-02-11 23:59:59.000",
"21826720",
"0xea513277ed1add2912cc96230a302f65a4fcbd0e8135da55e56cb3acebbf20ae",
"1570000000",
"89000000",
"2",
"888984959",
"2025-02-11"
]
},
{
"items": [
"0x8784a6c97ce5e78a7cda2c9eca060e7eaeb603e934491a28734c184c75dca150",
"5559827",
"26",
"0xf89d7b9c864f589bbf53a82105107622b35eaa40",
"0x09395a2a58db45db0da254c7eaa5ac469d8bdc85",
"0.0",
"90000",
"2799984959",
"0xa9059cbb000000000000000000000000daa04b6651ef21bab01f2ce74f7a5065637f7ba7000000000000000000000000000000000000000000000077107e104249bc6000",
"4667310",
"51424",
"",
"",
"1",
"2025-02-11 23:59:59.000",
"21826720",
"0xea513277ed1add2912cc96230a302f65a4fcbd0e8135da55e56cb3acebbf20ae",
"200000000000",
"2000000000",
"2",
"2799984959",
"2025-02-11"
]
},
{
"items": [
"0xdf2a300d11032a4b028f39c4a26d5d4f0f1a99261fcb6a3365e6a624cf682bb8",
"8",
"11",
"0x50d2cf05d98d8e7140392c53a92413be6b198e4a",
"0xdac17f958d2ee523a2206206994597c13d831ec7",
"0.0",
"50834",
"5818692699",
"0xa9059cbb0000000000000000000000001ca5aa5b1dd8d948bb0971a5fb1762fe172e0040000000000000000000000000000000000000000000000000000000002474f9a8",
"3882838",
"41297",
"",
"",
"1",
"2025-02-11 23:59:59.000",
"21826720",
"0xea513277ed1add2912cc96230a302f65a4fcbd0e8135da55e56cb3acebbf20ae",
"0",
"0",
"0",
"5818692699",
"2025-02-11"
]
},
{
"items": [
"0xf8133fe59e596dc04814882afe36c77232ef8975bd0972225b5e6aa069b92b4a",
"8",
"23",
"0x84188654266f8a1fc6829e2034b08140dca6db40",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"0.0",
"65147",
"2799984959",
"0x095ea7b3000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"4573886",
"55846",
"",
"",
"1",
"2025-02-11 23:59:59.000",
"21826720",
"0xea513277ed1add2912cc96230a302f65a4fcbd0e8135da55e56cb3acebbf20ae",
"2840390378",
"2000000000",
"2",
"2799984959",
"2025-02-11"
]
},
{
"items": [
"0xee4a69a9d618b77e483e6d5225c57d83e520f1db55a2f86708bedd34d55c0736",
"247135",
"6",
"0xb0ba33566bd35bcb80738810b2868dc1ddd1f0e9",
"0xe592427a0aece92de3edee1f18e0157c05861564",
"0.0",
"600000",
"7032887706",
"0xc04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000b0ba33566bd35bcb80738810b2868dc1ddd1f0e90000000000000000000000000000000000000000000000000000000067abe5a300000000000000000000000000000000000000000000000007cb23e938256c0000000000000000000000000000000000000000000000000000000000f0e77f45000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2002710d7efb00d12c2c13131fd319336fdf952525da2af000000000000000000000000000000000000000000",
"2894327",
"137116",
"",
"",
"1",
"2025-02-11 23:59:59.000",
"21826720",
"0xea513277ed1add2912cc96230a302f65a4fcbd0e8135da55e56cb3acebbf20ae",
"26415305982",
"6232902747",
"2",
"7032887706",
"2025-02-11"
]
},
{
"items": [
"0x86ac42fff13882c5407a17ff7f5bf6fa6669e3aef838006b405b71a28dfc5e8f",
"79",
"27",
"0x79b3bf3e5d8b72f83f00fa843aa3e2c742486f12",
"0xb612bfc5ce2fb1337bd29f5af24ca85dbb181ce2",
"0.0",
"47594",
"2799984959",
"0x095ea7b3000000000000000000000000881d40237659c251811cec9c364ef91dc08d300cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"4714520",
"47210",
"",
"",
"1",
"2025-02-11 23:59:59.000",
"21826720",
"0xea513277ed1add2912cc96230a302f65a4fcbd0e8135da55e56cb3acebbf20ae",
"3716331977",
"2000000000",
"2",
"2799984959",
"2025-02-11"
]
},
{
"items": [
"0xc1c000a4ae818449b84b046d23d307067ed8e76ffca3e9bcb49694696e9e2a58",
"0",
"12",
"0xc373dfcea18132f4ccaa36c974a9abcc4028e008",
"0xdac17f958d2ee523a2206206994597c13d831ec7",
"0.0",
"50834",
"5818692699",
"0xa9059cbb0000000000000000000000001ca5aa5b1dd8d948bb0971a5fb1762fe172e00400000000000000000000000000000프로젝트로 돌아가기