Cronos example queries

This page provides Blockchain Analytics query examples for Cronos.

See the BigQuery documentation for instructions on using BigQuery.

Show all USDT transfers

This query shows transfers of the USDT token on Cronos since genesis.

In the Google Cloud console, go to the BigQuery page.

Go to BigQuery

The following query is loaded into the Editor field:

-- 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);
""";

SELECT
  t.transaction_hash,
  t.from_address AS 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
ON
  l.transaction_hash = t.transaction_hash
WHERE
  t.to_address = LOWER("0x66e428c3f67a68878562e79a0234c1f83c208770") -- USDT
AND
  ARRAY_LENGTH(l.topics) > 0
AND
  -- Transfer(address indexed src, address indexed dst, uint wad)
  l.topics[OFFSET(0)] = LOWER("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
;

The following shows an example result:

Transaction Hash From Address To Address USDT Transfer Amount
0x6688fbfff00aee60811c150e3f5fcd08a6c9c50b9e028ff4bed3138918cd6b16 0x792f3570cf9a552952b7f80703d1b4e773397e33 0xe6e2d743e057024e033fde3e16077de3302e0cd1 1500.0
0x84f0b00a5ddc882134fab138097a582500097eb7051fed499c403368ab622b31 0xf6d7dd84382cd532eb68cc2711509058936e890d 0x03363e4bbc35f01bec95a33b3b391894f4ca7244 1001.08402
0xc353e823bfa7c582956154194bccfabef6a4f7e71efb9211ae64b9ccc1b21cc7 0x9e199307660706e0ed1ed4d56684aad67ca97bde 0x43d615be1714913fc1850e5a77cd01fa9b75e90c 5000.0
0x98321418e4fdc29d84a2d49bfc2d6ce1b4d0b37b93b84051aea75b19fb2a6e44 0x340a27ea8874177c894c365183d2283b5fcaa697 0xa0b5564550345414b619821c8dcbf7e0a20a195a 7.0
0x095a3a3453b27d003ac299fbdbcff53f78c32e748f79064e8a74bc6e20fe8e48 0x3a956433edae040b41f1767b24009d08bf73fd6e 0x8995909dc0960fc9c75b6031d683124a4016825b 30000.0

Wrapped Cronos activity

This query shows the wallets with the most interactions with Wrapped Cronos in the last 30 days.

In the Google Cloud console, go to the BigQuery page.

Go to BigQuery

The following query is loaded into the Editor field:

SELECT
  from_address AS address,
  CONCAT("https://cronoscan.com/address/", from_address) AS croniscan_link,
  COUNT(from_address) AS num_transactions
FROM
  `bigquery-public-data.goog_blockchain_cronos_mainnet_us.transactions` AS t
WHERE
  to_address = LOWER("0x5C7F8A570d578ED84E63fdFA7b1eE72dEae1AE23") -- Wrapped CRO
AND
  block_timestamp > (CURRENT_TIMESTAMP() - INTERVAL 30 DAY)
GROUP BY
  from_address
ORDER BY
  COUNT(from_address) DESC
;

The following shows an example result:

address croniscan_link num_transactions
0x07195f6dbac033152904747ca22d4debad682ad7 https://cronoscan.com/address/0x07195f6dbac033152904747ca22d4debad682ad7 167
0x70f1378570328c42782e9023c048d1357071082b https://cronoscan.com/address/0x70f1378570328c42782e9023c048d1357071082b 148
0xce6aeeb31f00a5783c115a669e516f34d56512e4 https://cronoscan.com/address/0xce6aeeb31f00a5783c115a669e516f34d56512e4 120
0xc7b0ff7bd56618645737ad1f5623568c1fc65449 https://cronoscan.com/address/0xc7b0ff7bd56618645737ad1f5623568c1fc65449 95
0x8194ed39b510a07425b49752ce489cbaa972fbf0 https://cronoscan.com/address/0x8194ed39b510a07425b49752ce489cbaa972fbf0 77