WITH
first_transactions_from_to AS (
SELECT
from_address AS address,
MIN(block_timestamp) AS ts
FROM
avalanche.core.fact_transactions
GROUP BY
1
),
first_transactions AS (
SELECT
address,
MIN(ts) ts
FROM
first_transactions_from_to
GROUP BY
1
),
total_users AS (
SELECT
date_trunc('month', ts) AS month,
COUNT(DISTINCT address) AS monthly_new_users,
SUM(monthly_new_users) OVER (
ORDER BY
month
) AS cumulative_number_users
FROM
first_transactions
GROUP BY
1
),
days AS (
SELECT
date_trunc('day', block_timestamp) as day,
from_address as user_address