You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3c2bd5d
Browse filesBrowse the repository at this point in the historyBrowse files
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
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.
10
12
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.
12
14
13
15
## 1. Fees are in USD, not ETH
14
16
15
17
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.
16
18
17
19
Round to the nearest microdollar (how fees actually settle):
18
20
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 BY1
24
-
ORDER BY1;
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
+
:::
26
36
27
37
## 2. TIP-20 tokens use 6 decimals, not 18
28
38
@@ -32,51 +42,80 @@ Divide token amounts by `1e6`. Using `1e18` gives a result 10¹² times too smal
32
42
33
43
`tx.value` is always zero on Tempo. All token movement is in `Transfer` events.
34
44
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 BY1, 2
41
-
ORDER BY1;
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
+
/>
43
58
44
59
`TransferWithMemo` (used by MPP) also emits a standard `Transfer`. Query only `Transfer` to avoid double-counting.
45
60
46
61
## 4. Use COALESCE(fee_payer, from) for attribution
47
62
48
63
Sponsored transactions populate a separate `fee_payer` field. Grouping by `from` attributes sponsored activity to the wrong address.
49
64
50
-
```sql
51
-
SELECT COALESCE(fee_payer, "from") AS payer,
52
-
COUNT(*) AS tx_count
53
-
FROM transactions
54
-
GROUP BY1
55
-
ORDER BY2DESC;
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
+
:::
57
82
58
83
## 5. Exclude system transactions from user metrics
59
84
60
85
`from = 0x0000…0000` is system-level. Include in raw chain metrics, exclude when measuring users.
61
86
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
+
62
102
## 6. Compute supply from Transfer events, not Mint events
63
103
64
104
Genesis mints may not emit `Mint`. Derive supply from `Transfer`: mints have `from = 0x0…0`, burns have `to = 0x0…0`.
65
105
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'
0 commit comments