Links

SQL Examples

SQL examples for the Sort API / Query page
Visit https://sort.xyz/query to use any of these examples and view API code

Get all transactions for a given contract

select
*
from
ethereum.transaction t
where
t.to = '0x7f268357a8c2552623316e2562d90e642bb538e5'
order by
t.timestamp desc
limit
10

Get all transaction logs for a given contract

select
*
from
ethereum.transaction_log l
where
l.transaction_to = '0x7f268357a8c2552623316e2562d90e642bb538e5'
order by
l.timestamp desc
limit
10

Get all NFT transactions

select
*
from
ethereum.nft_transaction n
order by
n.timestamp desc
limit
10

Top 10 most active NFTs by volume in past 1 hour

select
n.nft_name,
sum(amount_eth) as volume
from
ethereum.nft_transaction n
where
n.timestamp > DATE(CURRENT_DATETIME()) - INTERVAL 1 HOUR
group by
n.nft_name
order by
volume desc
limit
10

NFT volume per hour over past 12 hours

select
EXTRACT(
HOUR
FROM
n.timestamp
) as hour,
sum(amount_eth) as volume
from
ethereum.nft_transaction n
where
n.timestamp > DATE(CURRENT_DATETIME()) - INTERVAL 12 HOUR
group by
EXTRACT(
HOUR
FROM
n.timestamp
)
order by
hour desc
limit
10