From d3d5d65b6c5365c8b4de7d5b28dbbd31240974d7 Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Wed, 15 Jan 2025 22:22:12 -0500 Subject: [PATCH] update sql example --- blocks/antelope/Makefile | 2 +- blocks/solana/Makefile | 4 +-- snowflake/solana/README.md | 62 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/blocks/antelope/Makefile b/blocks/antelope/Makefile index 93f5e9b..d8b06fa 100644 --- a/blocks/antelope/Makefile +++ b/blocks/antelope/Makefile @@ -22,7 +22,7 @@ protogen: .PHONY: parquet parquet: - rm -rf state.yaml && substreams-sink-files run "$(NETWORK).substreams.pinax.network:443" substreams.yaml map_events "./out" 413423197:413423198 --encoder parquet --file-block-count 1 --parquet-default-column-compression snappy + substreams-sink-files run "$(NETWORK).substreams.pinax.network:443" substreams.yaml map_events "./out" 414957000: --encoder parquet --file-block-count 1 --parquet-default-column-compression snappy .PHONY: s3 s3: diff --git a/blocks/solana/Makefile b/blocks/solana/Makefile index 5fab9df..b8bfc3e 100644 --- a/blocks/solana/Makefile +++ b/blocks/solana/Makefile @@ -39,11 +39,11 @@ cache-foundational: .PHONY: gui gui: - substreams gui substreams.yaml -e solana.substreams.pinax.network:443 map_events -s 203100000 --network solana + substreams gui substreams.yaml -e solana.substreams.pinax.network:443 map_events -s 311081162 --network solana .PHONY: parquet parquet: - substreams-sink-files run solana.substreams.pinax.network:443 substreams.yaml map_events './out' 203100000:203100001 --encoder parquet --file-block-count 1 --development-mode + substreams-sink-files run solana.substreams.pinax.network:443 substreams.yaml map_events './out' 311081162: --encoder parquet --file-block-count 50 --development-mode .PHONY: deploy deploy: diff --git a/snowflake/solana/README.md b/snowflake/solana/README.md index c8c54e1..4c00946 100644 --- a/snowflake/solana/README.md +++ b/snowflake/solana/README.md @@ -4,7 +4,6 @@ This dataset offers a detailed view of Solana based blockchain activity, providi Free access to the dataset on the [Snowflake Data Marketplace](https://app.snowflake.com/marketplace). -```markdown ## Tables/Views | Data Type | Description | @@ -18,6 +17,66 @@ Free access to the dataset on the [Snowflake Data Marketplace](https://app.snowf | `vote_instruction_calls` | Instruction calls associated with vote transactions, sharing the same structure as `instruction_calls`. | | `vote_account_activity` | Account activity related to voting, structured similarly to general account activity. | +## Sample SQL Queries + +**Daily Active Users (DAU)** + +```sql +SELECT + block_date, + count(distinct address) AS user +FROM solana.account_activity +GROUP BY block_date +ORDER BY block_date ASC; +``` + +**Top Contracts** + +```sql +SELECT + account AS contract, + count(*) AS actions +FROM wax.actions +WHERE block_date = '2025-01-01' +GROUP BY contract +ORDER BY actions DESC +LIMIT 10 +``` + +**Tokens** + +```sql +SELECT + a.tx_id, + a.address, + a.token_mint_address, + a.pre_token_balance, + a.post_token_balance, + a.token_balance_change, + a.block_time +FROM + solana.account_activity a +WHERE + a.token_mint_address IS NOT NULL +ORDER BY + a.block_time DESC +LIMIT + 100; +``` + + +**View the first and last block indexed** +> This query tells you how fresh the data is. + +```sql +SELECT + MIN(number) AS "First block", + MAX(number) AS "Newest block", + COUNT(1) AS "Total number of blocks" +FROM + solana.blocks; +``` + ## Data Dictionary ### `blocks` @@ -196,4 +255,3 @@ Free access to the dataset on the [Snowflake Data Marketplace](https://app.snowf **Note:** The schema for `vote_account_activity` is identical to the `account_activity` table. -``` \ No newline at end of file