theericstoneHottest New Contracts -- Last 30 Days
    Updated 2023-03-09
    -- every active contract address in the last 30 days by number of transactions
    with actives as (
    select * from (
    select
    contract_address,
    symbol,
    min(block_id) as minblock,
    min(block_timestamp) as mintime,
    count(tx_id) as n_txns,
    count( distinct from_address ) as n_addys
    from ethereum.udm_events
    where block_timestamp > getdate() - interval '32 days'
    group by 1,2
    ) basics
    where basics.n_txns > 100
    and basics.n_addys > 100
    ),

    -- the first block of that period
    minblock as (select min(minblock) as min_block from actives),

    -- exclude contracts that were active BEFORE this period
    exclusions as (
    select contract_address,
    min(block_id) as min_block_id,
    min(block_timestamp) as min_time
    from ethereum.udm_events
    where contract_address in (select contract_address from actives)
    and block_id < (select min_block from minblock)
    and block_timestamp > getdate() - interval '180 days'
    group by 1
    )
    -- summarize the new AND active contracts
    select
    actives.contract_address,