Hosted Environment
This guide explains how to use Amp’s hosted service maintained by Edge & Node. It provides actionable steps for querying published datasets, migrating from local to hosted development, and publishing your own dataset.
Overview
Section titled “Overview”Edge & Node maintains real-time indexed blockchain datasets containing blocks, transactions, and logs. These datasets are queryable with SQL.
Benefits
Section titled “Benefits”- No infrastructure: Skip node management, indexing, and database setup.
- Instant queries: Access mainnet data with SQL immediately.
- Production ready: Build applications on reliable, continuously updated datasets.
- Composable: Combine multiple published datasets in a single query.
Supported Networks
Section titled “Supported Networks”ethereum-mainnetarbitrum-onebase-mainnetbase-sepolia
More networks are planned.
Entry Points
Section titled “Entry Points”- Query existing datasets
- Transition from local to hosted
- Publish your dataset
Query Existing Datasets
Section titled “Query Existing Datasets”Use published blockchain datasets without running local infrastructure.
Step 1: Test Queries
Section titled “Step 1: Test Queries”Visit the Amp Playground to validate data availability: https://playground.amp.thegraph.com
Step 2: Generate an Auth Token
Section titled “Step 2: Generate an Auth Token”pnpm amp auth token --duration "3 days"Save the token for CLI queries or environment variables.
Step 3: Run Queries
Section titled “Step 3: Run Queries”CLI Query Example
Section titled “CLI Query Example”pnpm amp query \ --flight-url https://gateway.amp.staging.thegraph.com \ --bearer-token YOUR_TOKEN_HERE \ 'SELECT block_num, hash FROM "edgeandnode/ethereum_mainnet@0.0.1".blocks ORDER BY block_num DESC LIMIT 5'Filter Logs by Contract
Section titled “Filter Logs by Contract”pnpm amp query \ --flight-url https://gateway.amp.staging.thegraph.com \ --bearer-token YOUR_TOKEN_HERE \ 'SELECT block_num, tx_hash FROM "edgeandnode/ethereum_mainnet@0.0.1".logs WHERE address = 0xYOUR_CONTRACT_ADDRESS LIMIT 10'Use From an Application
Section titled “Use From an Application”Add credentials:
VITE_AMP_QUERY_URL=https://gateway.amp.staging.thegraph.comVITE_AMP_QUERY_TOKEN=amp_your_token_hereExample client usage:
import { ArrowFlight } from "@edgeandnode/amp";import { Effect, Stream } from "effect";
const query = Effect.gen(function* () { const arrow = yield* ArrowFlight.ArrowFlight;
const sql = ` SELECT block_num, hash, gas_used FROM "edgeandnode/ethereum_mainnet@0.0.1".blocks WHERE gas_used > 0 ORDER BY block_num DESC LIMIT 100 `;
return yield* arrow.query([sql] as any).pipe(Stream.runCollect);});Transition from Local to Hosted
Section titled “Transition from Local to Hosted”Migrate your local dataset to a hosted network.
Prerequisites
Section titled “Prerequisites”- Contract deployed to the target network
- ABI matches the deployed contract
Amp handles indexing when your dataset depends on a published raw dataset.
Step 1: Configure Environment
Section titled “Step 1: Configure Environment”“bash cp .env.example .env
Enable the target network:```bashVITE_AMP_RPC_DATASET=edgeandnode/ethereum_mainnet@0.0.1VITE_AMP_NETWORK=ethereum-mainnetStep 2: Update Dataset Config
Section titled “Step 2: Update Dataset Config”import { defineDataset, eventTables } from "@edgeandnode/amp";// @ts-ignoreimport { abi } from "./app/src/lib/abi.ts";
export default defineDataset(() => ({ name: "counter", network: "ethereum-mainnet", dependencies: { rpc: "edgeandnode/ethereum_mainnet@0.0.1", }, tables: eventTables(abi, "rpc"),}));Step 3: Test Configuration
Section titled “Step 3: Test Configuration”Validate Build
pnpm amp build -o /tmp/test-manifest.jsonGenerate Token
pnpm amp auth token --duration "3 days"Verify Connectivity
pnpm amp query \ --flight-url https://gateway.amp.staging.thegraph.com \ --bearer-token YOUR_TOKEN_HERE \ 'SELECT block_num, hash FROM "edgeandnode/ethereum_mainnet@0.0.1".blocks ORDER BY block_num DESC LIMIT 5'Verify Contract Events
pnpm amp query \ --flight-url https://gateway.amp.staging.thegraph.com \ --bearer-token YOUR_TOKEN_HERE \ 'SELECT block_num, tx_hash FROM "edgeandnode/ethereum_mainnet@0.0.1".logs WHERE address = 0xYOUR_CONTRACT_ADDRESS LIMIT 10'If results appear, your configuration is correct.
Step 4: Run the App
Section titled “Step 4: Run the App”just devPublish Your Dataset (Optional)
Section titled “Publish Your Dataset (Optional)”Publish your dataset to the Amp registry for public querying.
Prerequisites
Section titled “Prerequisites”- Queries return expected data
- Contract deployed
- Dataset defined in amp.config.ts
Step 1: Add Publishing Metadata
Section titled “Step 1: Add Publishing Metadata”Add recommended metadata to amp.config.ts for discoverability:
import { defineDataset, eventTables } from "@edgeandnode/amp";// @ts-ignoreimport { abi } from "./app/src/lib/abi.ts";
export default defineDataset(() => ({ name: "counter", network: "ethereum-mainnet", dependencies: { rpc: "edgeandnode/ethereum_mainnet@0.0.1", }, tables: eventTables(abi, "rpc"),
namespace: "your_namespace", description: "Counter dataset tracking increment/decrement events", keywords: ["Ethereum", "Counter", "Events"],}));Step 2: Authenticate
Section titled “Step 2: Authenticate”pnpm amp auth loginThis opens a browser for wallet or social authentication.
Step 3: Publish
Section titled “Step 3: Publish”pnpm amp publish --tag "0.0.1" --changelog "Initial release"--tag(REQUIRED) - Semantic version:{major}.{minor}.{patch}--changelog(optional) - Describe changes in this version
Dataset URL:
your_namespace/counter@0.0.1
Step 4: Generate Auth Token
Section titled “Step 4: Generate Auth Token”Generate a long-lived token for your application:
pnpm amp auth token --duration "30 days"Copy the token and update your .env:
VITE_AMP_QUERY_TOKEN=amp_your_token_hereStep 5: Update Dataset References
Section titled “Step 5: Update Dataset References”In your application code, update queries to reference the published version:
// Before (local dev)const query = 'SELECT * FROM "_/counter@dev".incremented LIMIT 10';
// After (published)const query = 'SELECT * FROM "your_namespace/counter@0.0.1".incremented LIMIT 10';Or use @latest to always query the most recent published version:
const query = 'SELECT * FROM "your_namespace/counter@latest".incremented LIMIT 10';Step 6: Query Your Published Dataset
Section titled “Step 6: Query Your Published Dataset”Your dataset is now publicly available. Anyone can query it:
pnpm amp query \ --flight-url https://gateway.amp.staging.thegraph.com \ --bearer-token YOUR_TOKEN \ 'SELECT * FROM "your_namespace/counter@0.0.1".incremented LIMIT 10'View in registry: https://playground.amp.thegraph.com/
Updating Your Dataset
Section titled “Updating Your Dataset”To publish a new version:
- Update your
amp.config.ts - Increment the version:
pnpm amp publish --tag "0.0.2" --changelog "Added new derived table" - Users can query
@0.0.2for the new version or@latestto automatically use it
Version Tags
Section titled “Version Tags”@dev- Local development (unpublished)@0.0.1,@1.2.3- Specific published versions@latest- Most recent published version (updates automatically)