You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Blockchain Analytics offers indexed blockchain data made available through BigQuery for easy analysis through SQL.
Blockchain Analytics offers you access to reliable data without the overhead of operating nodes or developing and maintaining an indexer. You can now query the full history of blocks, transactions, logs and receipts for Cronos.
By leveraging datasets in BigQuery, you can access blockchain data as easily as your internal data. By joining chain data with application data, you can get a complete picture of your users and your business.
How are these datasets different from the existing public dataset?
Like the existing public blockchain datasets, customers are not charged for storage of the data, only for querying the data based on BigQuery pricing.
To start developing your own BigQuery SQL code, we refer to the following syntax.
For the Cronos data schema we refer to the Google Cloud Cronos schema.
SELECTt.from_addressAS address,
CONCAT("https://cronoscan.com/address/", t.from_address) AS cronoscan_link,
COUNT(t.from_address) AS num_transactions
FROM`bigquery-public-data.goog_blockchain_cronos_mainnet_us.transactions`AS t
INNER JOIN
bigquery-public-data.goog_blockchain_cronos_mainnet_us.blocks AS b
ONb.block_hash=t.block_hashWHEREt.to_address=LOWER("0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23") -- Wrapped CROANDb.block_timestamp> (CURRENT_TIMESTAMP() - INTERVAL 30 DAY)
GROUP BYt.from_addressORDER BYCOUNT(t.from_address) DESC
;
We can now query the results in the results tab below, further explore by exporting the results or visualizing in another tool such as Google sheets or Looker.\
SELECTMIN(block_number) AS`First block`,
MAX(block_number) AS`Newest block`,
COUNT(1) AS`Total number of blocks`FROM`bigquery-public-data.goog_blockchain_cronos_mainnet_us.blocks`AS t
Row
First block
Newest block
Total number of blocks
1
1
12134627
12134627
Daily transactions in the last 10 days
SELECTDATE(block_timestamp) ASdate,
COUNT(*) AS num_transactions
FROM`bigquery-public-data.goog_blockchain_cronos_mainnet_us.transactions`WHERE
block_timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 10 DAY)
GROUP BY1ORDER BY1DESC;
Row
date
num_transactions
1
2024-01-18
10250
2
2024-01-17
47747
3
2024-01-16
49717
4
2024-01-15
47099
5
2024-01-14
47051
6
2024-01-13
43926
7
2024-01-12
50448
8
2024-01-11
60904
9
2024-01-10
61774
10
2024-01-09
54521
11
2024-01-08
44194
View the blocks with largest CRO value transfer
SELECT block_hash, SUM(value.bignumeric_value/1000000000000000000) value_total
FROM`bigquery-public-data.goog_blockchain_cronos_mainnet_us.transactions`JOIN`bigquery-public-data.goog_blockchain_cronos_mainnet_us.receipts` USING (block_hash, transaction_hash)
WHERE status =1GROUP BY block_hash
ORDER BY value_total DESCLIMIT5
SELECT
from_address,
COUNT(*) AS num_transactions
FROM`bigquery-public-data.goog_blockchain_cronos_mainnet_us.transactions`GROUP BY from_address
ORDER BY num_transactions DESCLIMIT10;
Row
from_address
num_transactions
1
0xc9219731adfa70645be14cd5d30507266f2092c5
3435654
2
0xae45a8240147e6179ec7c9f92c5a18f9a97b3fca
610937
3
0xd166bcf1d581bb25ab597672ae8a4a02441d2b39
579612
4
0x95d49a8a2d69b2a2de4a00655d05ee39f9c41108
520301
5
0x71f0cdb17454ad7eeb7e26242292fe0e0189645a
355649
6
0xb3c506d60d45abb917ee10a947749a098b497d3d
321307
7
0x9b6e6035998a84bf2d42781752707087fe8229ed
309942
8
0x227f6757289a86c13eee2e91c2e6eb03f2ed11a6
294599
9
0x6614d26064d762922c7bc7a00337713d5169ae7c
267727
10
0x3936530e2f41df21889067ae35aa81ffbd68aeef
253452
All USDT activity
-- UDF for easier string manipulation.
CREATE TEMP FUNCTION ParseSubStr(hexStr STRING, startIndex INT64, endIndex INT64)
RETURNS STRING
LANGUAGE js
AS r""" if (hexStr.length < 1) { return hexStr; } return hexStr.substring(startIndex, endIndex);""";
-- UDF to convert hex to decimal.
CREATE TEMP FUNCTION HexToDecimal(hexStr STRING)
RETURNS INT64
LANGUAGE js
AS r""" return parseInt(hexStr, 16);""";
SELECTt.transaction_hash,
t.from_addressAS from_address,
CONCAT("0x", ParseSubStr(l.topics[OFFSET(2)], 26, LENGTH(l.topics[OFFSET(2)]))) AS to_address,
(HexToDecimal(l.data) /1000000) AS usdt_transfer_amount
FROM`bigquery-public-data.goog_blockchain_cronos_mainnet_us.transactions`AS t
INNER JOIN`bigquery-public-data.goog_blockchain_cronos_mainnet_us.logs`AS l
ONl.transaction_hash=t.transaction_hashWHEREt.to_address=LOWER("0x66e428c3f67a68878562e79a0234c1f83c208770") -- USDTAND
ARRAY_LENGTH(l.topics) >0AND-- Transfer(address indexed src, address indexed dst, uint wad)l.topics[OFFSET(0)] =LOWER("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
;