- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains - Omit embedded publish git dirs and empty placeholders from index Made-with: Cursor
78 lines
3.8 KiB
Markdown
78 lines
3.8 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).
|
|
|
|
**Operational status (2026-04-07):** Thirdweb **Insight for Chain 138 is running** (operator-confirmed). Re-check any time with `node scripts/try-thirdweb-insight.js` (expects HTTP 200 for 138). **651940** remains **verify per project**: same script; if the API still returns unsupported, keep using your activity feed for that chain.
|
|
|
|
---
|
|
|
|
## 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:** Insight is **on** for this deployment; confirm with the try script above. **651940:** confirm with the same script or chainlist; if unsupported, use your own indexer and [ACTIVITY_FEED_SPEC.md](ACTIVITY_FEED_SPEC.md). You can still use **Ethereum (1)** in the try script to sanity-check API keys alone.
|
|
|
|
---
|
|
|
|
## 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/0x86ADA6Ef91A3B450F89f2b751e93B1b7A3218895?limit=10
|
|
x-client-id: <your-client-id>
|
|
```
|
|
|
|
**Decoded events (if supported):**
|
|
|
|
```http
|
|
GET https://138.insight.thirdweb.com/v1/events/0x86ADA6Ef91A3B450F89f2b751e93B1b7A3218895?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 **bridge-aware stitching**, custom app events, or any chain Insight does not index (e.g. 651940 if still unsupported).
|
|
|
|
You can use both: Insight for standard events/transactions where available, and your indexer for activity feed and bridge-aware stitching.
|