# 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://.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/0x5BDc62f1ae7D630c37A8B363a1d49845356Ee72d?limit=10 x-client-id: ``` **Decoded events (if supported):** ```http GET https://138.insight.thirdweb.com/v1/events/0x5BDc62f1ae7D630c37A8B363a1d49845356Ee72d?limit=10&decode=true x-client-id: ``` **Transactions:** ```http GET https://138.insight.thirdweb.com/v1/transactions?limit=5 x-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.