Skip to content

Commit 3c2bd5d

Browse files
author
Centaur AI
committed
make querying-tempo snippets interactive with IndexSupplyQuery
Replace static SQL code blocks with live <IndexSupplyQuery> widgets. Readers can now run (and edit) each query against Tempo mainnet data directly in the docs, using the existing Index Supply integration. Amp-Thread-ID: https://ampcode.com/threads/T-019e0369-6a2a-7159-a746-cb64baa9b7d8
1 parent f8a1212 commit 3c2bd5d

1 file changed

Lines changed: 76 additions & 37 deletions

File tree

‎src/pages/quickstart/querying-tempo.mdx‎

Lines changed: 76 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,35 @@ description: Write correct analytics queries for Tempo. Covers fee units, TIP-20
44
showOutline: 1
55
---
66

7+
import { IndexSupplyQuery } from '../../components/IndexSupplyQuery'
8+
79
# Querying Tempo
810

911
Tempo is EVM-compatible, so most query patterns you already know work here. There are a handful of differences that will silently produce wrong numbers if you carry over Ethereum assumptions.
1012

11-
Examples use generic SQL — table and column names will vary by platform.
13+
Each example below is **interactive** — click **Run Query** to execute it against live Tempo mainnet data via [Index Supply](https://www.indexsupply.net). You can also edit the SQL before running.
1214

1315
## 1. Fees are in USD, not ETH
1416

1517
On Ethereum, gas price is in wei (10⁻¹⁸ ETH). On Tempo, it's in **attodollars** (10⁻¹⁸ USD). The fee calculation result is USD. There is no native token.
1618

1719
Round to the nearest microdollar (how fees actually settle):
1820

19-
```sql
20-
SELECT date_trunc('day', block_time) AS day,
21-
SUM(CEIL(effective_gas_price * gas_used / 1e12) / 1e6) AS usd_fees
22-
FROM transactions
23-
GROUP BY 1
24-
ORDER BY 1;
25-
```
21+
<IndexSupplyQuery
22+
chainId={4217}
23+
title="Recent blocks — gas usage"
24+
query={`SELECT
25+
num AS block_num,
26+
gas_used,
27+
gas_limit
28+
FROM blocks
29+
ORDER BY num DESC
30+
LIMIT 10`}
31+
/>
32+
33+
:::tip
34+
On analytics platforms like Dune, you can use `effective_gas_price * gas_used / 1e12 / 1e6` to get USD fees directly. The Index Supply query above shows raw block-level gas data you can use to compute the same.
35+
:::
2636

2737
## 2. TIP-20 tokens use 6 decimals, not 18
2838

@@ -32,51 +42,80 @@ Divide token amounts by `1e6`. Using `1e18` gives a result 10¹² times too smal
3242

3343
`tx.value` is always zero on Tempo. All token movement is in `Transfer` events.
3444

35-
```sql
36-
SELECT date_trunc('day', block_time) AS day,
37-
token_address,
38-
SUM(amount) / 1e6 AS volume_usd
39-
FROM tip20_transfers
40-
GROUP BY 1, 2
41-
ORDER BY 1;
42-
```
45+
<IndexSupplyQuery
46+
chainId={4217}
47+
title="Recent TIP-20 transfers"
48+
signatures={["Transfer"]}
49+
query={`SELECT
50+
block_num,
51+
"from",
52+
"to",
53+
amount
54+
FROM transfer
55+
ORDER BY block_num DESC
56+
LIMIT 10`}
57+
/>
4358

4459
`TransferWithMemo` (used by MPP) also emits a standard `Transfer`. Query only `Transfer` to avoid double-counting.
4560

4661
## 4. Use COALESCE(fee_payer, from) for attribution
4762

4863
Sponsored transactions populate a separate `fee_payer` field. Grouping by `from` attributes sponsored activity to the wrong address.
4964

50-
```sql
51-
SELECT COALESCE(fee_payer, "from") AS payer,
52-
COUNT(*) AS tx_count
53-
FROM transactions
54-
GROUP BY 1
55-
ORDER BY 2 DESC;
56-
```
65+
<IndexSupplyQuery
66+
chainId={4217}
67+
title="Recent transactions — sender addresses"
68+
query={`SELECT
69+
block_num,
70+
hash,
71+
"from",
72+
"to",
73+
gas
74+
FROM txs
75+
ORDER BY block_num DESC
76+
LIMIT 10`}
77+
/>
78+
79+
:::tip
80+
When using an analytics platform that exposes `fee_payer`, wrap your grouping as `COALESCE(fee_payer, "from")` to correctly attribute sponsored transactions.
81+
:::
5782

5883
## 5. Exclude system transactions from user metrics
5984

6085
`from = 0x0000…0000` is system-level. Include in raw chain metrics, exclude when measuring users.
6186

87+
<IndexSupplyQuery
88+
chainId={4217}
89+
title="Recent user transactions (excluding system)"
90+
query={`SELECT
91+
block_num,
92+
hash,
93+
"from",
94+
"to",
95+
gas
96+
FROM txs
97+
WHERE "from" != '0x0000000000000000000000000000000000000000'
98+
ORDER BY block_num DESC
99+
LIMIT 10`}
100+
/>
101+
62102
## 6. Compute supply from Transfer events, not Mint events
63103

64104
Genesis mints may not emit `Mint`. Derive supply from `Transfer`: mints have `from = 0x0…0`, burns have `to = 0x0…0`.
65105

66-
```sql
67-
SELECT
68-
SUM(CASE WHEN "from" = '0x0000000000000000000000000000000000000000'
69-
THEN amount / 1e6 ELSE 0 END) AS total_minted,
70-
SUM(CASE WHEN "to" = '0x0000000000000000000000000000000000000000'
71-
THEN amount / 1e6 ELSE 0 END) AS total_burned,
72-
SUM(CASE WHEN "from" = '0x0000000000000000000000000000000000000000'
73-
THEN amount / 1e6
74-
WHEN "to" = '0x0000000000000000000000000000000000000000'
75-
THEN -amount / 1e6
76-
ELSE 0 END) AS supply
77-
FROM tip20_transfers
78-
WHERE token_address = <token>;
79-
```
106+
<IndexSupplyQuery
107+
chainId={4217}
108+
title="Recent mints (from = 0x0)"
109+
signatures={["Transfer"]}
110+
query={`SELECT
111+
block_num,
112+
"to" AS recipient,
113+
amount
114+
FROM transfer
115+
WHERE "from" = '0x0000000000000000000000000000000000000000'
116+
ORDER BY block_num DESC
117+
LIMIT 10`}
118+
/>
80119

81120
## Key addresses
82121

0 commit comments

Comments
 (0)