Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- MASTER_INDEX: Last Updated 2026-03-06; status 59/59 contracts; add NEXT_STEPS_LIST, CONTRACT_NEXT_STEPS_LIST - docs/README, NEXT_STEPS_INDEX, 06-besu/MASTER_INDEX: Last Updated 2026-03-06 - Contract check script: 59 addresses (PMM, vault/reserve, CompliantFiatTokens); canonical CCIP/router - New docs: EXECUTION_CHECKLIST, NEXT_STEPS_LIST, DOTENV_AUDIT, ADDITIONAL_PATHS, deployer gas runbook, WEMIX_ACQUISITION_TABLED, etc. - Config: deployer-gas-routes, cro-wemix-swap-routes, routing-registry, token-mapping - Scripts: check-contracts-on-chain-138, check-pmm-pool-balances-chain138, deployer-gas-auto-route, acquire-cro-and-wemix-gas - Operator rule: operator-lan-access-check.mdc Made-with: Cursor
76 lines
3.4 KiB
Markdown
76 lines
3.4 KiB
Markdown
# Thirdweb Insight — Blockchain Indexer
|
||
|
||
**Purpose:** Use [Thirdweb Insight](https://insight-api.thirdweb.com) (blockchain indexer) to query events, transactions, and token data via REST. This doc describes how to try it and wire it for Chain 138 and Alltra (651940).
|
||
|
||
**References:** [Insight API Reference](https://insight-api.thirdweb.com/reference), [Getting started](https://insight-api.thirdweb.com/), [Multichain queries](https://blog.thirdweb.com/changelog/multichain-queries-with-insight-api).
|
||
|
||
---
|
||
|
||
## 1. What Insight provides
|
||
|
||
- **Events** — Query contract events (with optional decoding).
|
||
- **Transactions** — Get transaction status and list with filters.
|
||
- **Tokens** — ERC-20 / ERC-721 / ERC-1155 balances and metadata.
|
||
- **Base URL:** `https://<chain-id>.insight.thirdweb.com`
|
||
- **Auth:** Your Thirdweb **Client ID** in header `x-client-id` (or query `clientId`).
|
||
|
||
---
|
||
|
||
## 2. Try it from this repo
|
||
|
||
**Prereq:** `THIRDWEB_SECRET_KEY` or `THIRDWEB_CLIENT_ID` in env — e.g. from `smom-dbis-138/.env`. Server-side auth uses the secret key (`x-secret-key` header) when set.
|
||
|
||
```bash
|
||
# From repo root (loads smom-dbis-138/.env automatically)
|
||
node scripts/try-thirdweb-insight.js
|
||
|
||
# Or set explicitly
|
||
THIRDWEB_CLIENT_ID=542981292d51ec610388ba8985f027d7 node scripts/try-thirdweb-insight.js
|
||
```
|
||
|
||
The script calls the Insight API for **Chain 138** and **651940** (`GET /v1/events?limit=1`). If you get 200 and a small JSON body, the chain is supported; if 404/403 or “unsupported chain”, the chain may not be enabled for Insight yet.
|
||
|
||
---
|
||
|
||
## 3. Enable Insight in the Thirdweb dashboard
|
||
|
||
1. Go to [thirdweb.com](https://thirdweb.com) → your project.
|
||
2. Open **Insight** (or **Infrastructure** → **Insight**) and **enable** the Insight service for your project.
|
||
3. Ensure the **Client ID** you use in the script and dapp is from this project.
|
||
4. If you get **401 "keys are invalid"**, Insight is likely not enabled for the project — enable it in the dashboard and retry.
|
||
5. Check **supported chains**: [thirdweb.com/chainlist?service=insight](https://thirdweb.com/chainlist?service=insight). **Chain 138 and 651940 are not currently supported** by Insight (API returns "Chains not supported"). Use the try script with Ethereum (1) to verify your credentials; for 138 and 651940 use your own indexer and [ACTIVITY_FEED_SPEC.md](ACTIVITY_FEED_SPEC.md).
|
||
|
||
---
|
||
|
||
## 4. Example API calls (after enabling)
|
||
|
||
**Events for a contract (e.g. DODO PMM on 138):**
|
||
|
||
```http
|
||
GET https://138.insight.thirdweb.com/v1/events/0x79cdbaFBaA0FdF9F55D26F360F54cddE5c743F7D?limit=10
|
||
x-client-id: <your-client-id>
|
||
```
|
||
|
||
**Decoded events (if supported):**
|
||
|
||
```http
|
||
GET https://138.insight.thirdweb.com/v1/events/0x79cdbaFBaA0FdF9F55D26F360F54cddE5c743F7D?limit=10&decode=true
|
||
x-client-id: <your-client-id>
|
||
```
|
||
|
||
**Transactions:**
|
||
|
||
```http
|
||
GET https://138.insight.thirdweb.com/v1/transactions?limit=5
|
||
x-client-id: <your-client-id>
|
||
```
|
||
|
||
---
|
||
|
||
## 5. Relation to your activity feed
|
||
|
||
- **Insight:** Thirdweb-hosted indexer; use it when your chain is supported and you want quick REST queries.
|
||
- **Your stack:** [ACTIVITY_FEED_SPEC.md](ACTIVITY_FEED_SPEC.md) and the `activity_events` table are your own normalized feed (transfers, app events, bridge stitching). Use that for chains or event types Insight doesn’t cover (e.g. custom 138/651940 events and routing).
|
||
|
||
You can use both: Insight for standard events/transactions where available, and your indexer for activity feed and bridge-aware stitching.
|