Skip to content

Instantly share code, notes, and snippets.

@tromer
Created July 23, 2019 02:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tromer/96f9a1bd8ce3d507358fe38eae77deb5 to your computer and use it in GitHub Desktop.
Save tromer/96f9a1bd8ce3d507358fe38eae77deb5 to your computer and use it in GitHub Desktop.
Count the number of fully-shielded Zcash transactions per month
/* Count the number of fully-shielded Zcash transactions per month */
SELECT FORMAT_DATE("%E4Y-%m", Date(block_timestamp)) as month, count(distinct `hash`) as fully_shielded_tx FROM
(
SELECT /* fully shielded transactions with 0 fee */
`hash`,
block_timestamp,
fee
FROM
`bigquery-public-data.crypto_zcash.transactions`
WHERE
is_coinbase = FALSE
AND input_count = 0
AND output_count = 0
UNION DISTINCT
SELECT /* fully shielded transactions with nonzero fee */
`hash`,
block_timestamp,
fee
FROM
`bigquery-public-data.crypto_zcash.transactions`,
UNNEST(inputs) AS i
WHERE
is_coinbase = FALSE
AND input_count = 1
AND output_count = 0
AND i.type = "shielded"
AND i.value = fee
)
GROUP BY 1 ORDER BY 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment