> ## Documentation Index
> Fetch the complete documentation index at: https://docs.astral.global/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Install and configure the Astral SDK

> [!WARNING]
>
> **Research 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

```bash npm theme={null}
npm install @decentralized-geo/astral-sdk
```

```bash yarn theme={null}
yarn add @decentralized-geo/astral-sdk
```

```bash pnpm theme={null}
pnpm add @decentralized-geo/astral-sdk
```

## Peer dependencies

The SDK requires ethers.js v6:

```bash theme={null}
npm install ethers@^6.0.0
```

## Basic initialization

```typescript theme={null}
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:

```typescript theme={null}
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

```typescript theme={null}
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:

```typescript theme={null}
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

```typescript theme={null}
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

| Network | Chain ID | Status |
| - | - | - |
| Base Sepolia | 84532 | Active |
| Base Mainnet | 8453 | Active |
| Ethereum Sepolia | 11155111 | Active |
| Ethereum Mainnet | 1 | Active |
| Celo | 42220 | Active |
| Arbitrum | 42161 | Active |
| Optimism | 10 | Active |

## Submodule imports

You can import submodules directly for tree-shaking:

```typescript theme={null}
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:

```typescript theme={null}
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:

```bash theme={null}
# .env
PRIVATE_KEY=0x...
CHAIN_ID=84532
ASTRAL_API_URL=https://staging-api.astral.global
```

```typescript theme={null}
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
});
```

> [card] [Next: Location module](https://docs.astral.global/sdk/location.md)
>
> Learn about location attestation workflows


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.