Skip to main content
Development preview — The SDK is under active development.

Installation

The Astral SDK is a unified package that includes location attestations, geospatial computations, stamps, proofs, and the plugin system.

Package manager

npm install @decentralized-geo/astral-sdk

Peer dependencies

The SDK requires ethers.js v6:
npm install ethers@^6.0.0

Basic initialization

import { AstralSDK } from '@decentralized-geo/astral-sdk';
import { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider('https://sepolia.base.org');
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);

const astral = new AstralSDK({
  chainId: 84532,
  signer: wallet,
  apiUrl: 'https://staging-api.astral.global'
});

// All modules are available
const attestation = await astral.location.offchain.create({ ... });
const distance = await astral.compute.distance(uid1, uid2, options);
const stamps = await astral.stamps.collect();

Plugin registration

Register plugins at startup before using stamps or proofs:
import { AstralSDK } from '@decentralized-geo/astral-sdk';
import { MockPlugin } from '@decentralized-geo/astral-sdk';
import { ProofModePlugin } from '@location-proofs/plugin-proofmode';

const astral = new AstralSDK({
  chainId: 84532,
  signer: wallet,
  apiUrl: 'https://staging-api.astral.global'
});

// Register plugins before using stamps/proofs
astral.plugins.register(new MockPlugin());
astral.plugins.register(new ProofModePlugin());

// Now stamps module can orchestrate across registered plugins
const signals = await astral.stamps.collect();

With browser wallet

import { AstralSDK } from '@decentralized-geo/astral-sdk';
import { ethers } from 'ethers';

const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const network = await provider.getNetwork();

const astral = new AstralSDK({
  chainId: Number(network.chainId),
  signer: signer,
  apiUrl: 'https://staging-api.astral.global'
});

Read-only mode

For querying and verification without signing:
import { AstralSDK } from '@decentralized-geo/astral-sdk';
import { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider('https://sepolia.base.org');

const astral = new AstralSDK({
  chainId: 84532,
  provider: provider,
  apiUrl: 'https://staging-api.astral.global'
});

// Can verify attestations
const result = await astral.location.onchain.verify(attestation);

// Can compute (API calls don't require signer)
const distance = await astral.compute.distance(uid1, uid2, options);

// Cannot submit to EAS without signer
// await astral.compute.submit(attestation); // Would throw

Configuration options

interface AstralConfig {
  /** Target chain ID. Required. */
  chainId: number;

  /** Ethers signer for signing attestations and transactions. */
  signer?: Signer;

  /** Ethers provider for read-only blockchain operations. */
  provider?: Provider;

  /** Astral API base URL. Defaults to 'https://staging-api.astral.global' */
  apiUrl?: string;

  /** Required for TEE verification and hosted stamp verification. */
  apiKey?: string;

  /** Enable debug logging. Defaults to false. */
  debug?: boolean;

  /** Pre-register custom EAS schemas. */
  schemas?: RuntimeSchemaConfig[];

  /** Default schema to use when none is specified. */
  defaultSchema?: RuntimeSchemaConfig;

  /** Throw errors on schema validation failures. Defaults to false. */
  strictSchemaValidation?: boolean;
}

Supported chains

NetworkChain IDStatus
Base Sepolia84532Active
Base Mainnet8453Active
Ethereum Sepolia11155111Active
Ethereum Mainnet1Active
Celo42220Active
Arbitrum42161Active
Optimism10Active

Submodule imports

You can import submodules directly for tree-shaking:
import { LocationModule } from '@decentralized-geo/astral-sdk/location';
import { ComputeModule } from '@decentralized-geo/astral-sdk/compute';
import { PluginRegistry } from '@decentralized-geo/astral-sdk/plugins';
import { StampsModule } from '@decentralized-geo/astral-sdk/stamps';
import { ProofsModule } from '@decentralized-geo/astral-sdk/proofs';

TypeScript support

The SDK ships with full type definitions:
import {
  AstralSDK,
  // Location types
  LocationAttestationInput,
  UnsignedLocationAttestation,
  OffchainLocationAttestation,
  OnchainLocationAttestation,
  VerificationResult,
  // Compute types
  Input,
  ComputeOptions,
  NumericComputeResult,
  BooleanComputeResult,
  DelegatedAttestation,
  // Plugin types
  LocationProofPlugin,
  PluginRegistry,
  // Stamp/proof types
  LocationStamp,
  LocationProof,
  CredibilityVector,
  // Configuration
  AstralConfig,
  RuntimeSchemaConfig,
} from '@decentralized-geo/astral-sdk';

Environment variables

For server-side applications:
# .env
PRIVATE_KEY=0x...
CHAIN_ID=84532
ASTRAL_API_URL=https://staging-api.astral.global
import { AstralSDK } from '@decentralized-geo/astral-sdk';
import { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider(getRpcUrl(process.env.CHAIN_ID));
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);

const astral = new AstralSDK({
  chainId: Number(process.env.CHAIN_ID),
  signer: wallet,
  apiUrl: process.env.ASTRAL_API_URL
});

Next: Location module

Learn about location attestation workflows