Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions src/pages/quickstart/querying-tempo.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
title: Querying Tempo
description: Write correct analytics queries for Tempo. Covers fee units, TIP-20 decimals, Transfer events, fee_payer attribution, system transactions, and supply.
showOutline: 1
---

import { IndexSupplyQuery } from '../../components/IndexSupplyQuery'

# Querying Tempo

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.

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.

## 1. Fees are in USD, not ETH

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.

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

<IndexSupplyQuery
chainId={4217}
title="Recent blocks — gas usage"
query={`SELECT
num AS block_num,
gas_used,
gas_limit
FROM blocks
ORDER BY num DESC
LIMIT 10`}
/>

:::tip
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.
:::

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

Divide token amounts by `1e6`. Using `1e18` gives a result 10¹² times too small.

## 3. Use Transfer events for volume, not tx.value

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

<IndexSupplyQuery
chainId={4217}
title="Recent TIP-20 transfers"
signatures={["Transfer"]}
query={`SELECT
block_num,
"from",
"to",
amount
FROM transfer
ORDER BY block_num DESC
LIMIT 10`}
/>

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

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

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

<IndexSupplyQuery
chainId={4217}
title="Recent transactions — sender addresses"
query={`SELECT
block_num,
hash,
"from",
"to",
gas
FROM txs
ORDER BY block_num DESC
LIMIT 10`}
/>

:::tip
When using an analytics platform that exposes `fee_payer`, wrap your grouping as `COALESCE(fee_payer, "from")` to correctly attribute sponsored transactions.
:::

## 5. Exclude system transactions from user metrics

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

<IndexSupplyQuery
chainId={4217}
title="Recent user transactions (excluding system)"
query={`SELECT
block_num,
hash,
"from",
"to",
gas
FROM txs
WHERE "from" != '0x0000000000000000000000000000000000000000'
ORDER BY block_num DESC
LIMIT 10`}
/>

## 6. Compute supply from Transfer events, not Mint events

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

<IndexSupplyQuery
chainId={4217}
title="Recent mints (from = 0x0)"
signatures={["Transfer"]}
query={`SELECT
block_num,
"to" AS recipient,
amount
FROM transfer
WHERE "from" = '0x0000000000000000000000000000000000000000'
ORDER BY block_num DESC
LIMIT 10`}
/>

## Key addresses

| Contract | Address |
| --- | --- |
| FeeManager | `0xfeec000000000000000000000000000000000000` |
| Stablecoin DEX | `0xdec0000000000000000000000000000000000000` |
| TIP-20 Factory | `0x20fc000000000000000000000000000000000000` |
| pathUSD | `0x20c0000000000000000000000000000000000000` |

## Networks

| | Mainnet | Testnet (Moderato) |
| --- | --- | --- |
| Chain ID | `4217` | `42431` |
| RPC | `https://rpc.tempo.xyz` | `https://rpc.moderato.tempo.xyz` |
| Explorer | `https://explore.tempo.xyz` | `https://explore.testnet.tempo.xyz` |
| Tokenlist | `https://tokenlist.tempo.xyz/list/4217` | `https://tokenlist.tempo.xyz/list/42431` |
7 changes: 7 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ function syncTips(): Plugin {
// Escape angle brackets outside of code blocks/inline code so MDX doesn't
// treat them as JSX (e.g. `Mapping<B256, bool>` in prose).
content = escapeAngleBrackets(content)
// Quote frontmatter `authors:` values that start with a YAML reserved
// character (e.g. `@handle`). Upstream TIPs occasionally include GitHub
// handles like `@0xrusowsky`, which break YAML parsing unless quoted.
content = content.replace(
/^(authors:\s*)([@&*!|>%#`].*)$/m,
(_m, prefix, value) => `${prefix}"${value.replace(/"/g, '\\"')}"`,
)
const outputPath = path.join(outputDir, file.name.replace('.md', '.mdx'))
await fs.writeFile(outputPath, content)
}),
Expand Down
4 changes: 4 additions & 0 deletions vocs.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ export default defineConfig({
text: 'Wallet Developers',
link: '/quickstart/wallet-developers',
},
{
text: 'Querying Tempo',
link: '/quickstart/querying-tempo',
},
{
text: 'Contract Verification',
link: '/quickstart/verify-contracts',
Expand Down
Loading