CryptoIcicleLil-Nouns-2.Secondary Sales Activity
    Updated 2022-06-17
    -- Payout 100 USDC
    -- Grand Prize 300 USDC
    -- Level Intermediate

    -- Q2. How many Lil Nouns have been sold on a secondary exchange within 24 hours of being minted?
    -- Are there any common traits among these Lil Nouns? Which Lil Noun’s have the biggest difference (positive or negative)
    -- between their mint price and secondary sale price? Visualize and analyze your findings.

    -- Hint: This query looks at Nouns traits. You will need to modify it for Lil Nouns!

    -- select
    -- block_number as mint_block, block_timestamp as mint_time, tx_hash as mint_hash, contract_address,
    -- tokenflow_eth.hextoint(topics[1])::integer as tokenID, tokenflow_eth.hextoint(substr(data,3,64)) as background,
    -- tokenflow_eth.hextoint(substr(data,67,64)) as body, tokenflow_eth.hextoint(substr(data,131,64)) as accessory,
    -- tokenflow_eth.hextoint(substr(data,195,64)) as head, tokenflow_eth.hextoint(substr(data,259,64)) as glasses
    -- from ethereum.core.fact_event_logs
    -- where block_number > 12000000
    -- and contract_address = '0x9c8ff314c9bc7f6e59a9d9225fb22946427edc03'
    -- and topics[0]::string = '0x1106ee9d020bfbb5ee34cf5535a5fbf024a011bd130078088cbf124ab3092478'
    -- order by tokenId desc;

    with mint_dates as (
    select
    tokenid,
    mint_price_usd as mint_price,
    block_timestamp as mint_date
    from ethereum.core.ez_nft_mints
    where nft_address = '0x4b10701bfd7bfedc47d50562b76b436fbb5bdb3b'
    ),
    sale_dates as (
    select
    tokenid,
    price_usd as sale_price,
    block_timestamp as sale_date,
    rank() over (partition by tokenid order by block_timestamp asc ) as rank -- take only the very first sale
    from ethereum.core.ez_nft_sales
    Run a query to Download Data