> ## Documentation Index
> Fetch the complete documentation index at: https://astral-6ef288be-claude-ascii-globe-mouse-interaction-bupya.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK Overview

> Unified TypeScript SDK for Astral Location Services v0.2.0

<Warning>
  **Development Preview** — The SDK is under development.
</Warning>

<Note>
  **v0.2.0 Unified SDK** — The SDK now provides a unified API with namespaced modules.
  Location attestations and geospatial computations are now in a single package: `@decentralized-geo/astral-sdk`.
</Note>

# SDK Overview

The Astral SDK is the official TypeScript client for Astral Location Services, providing a unified interface for location attestations and verifiable geospatial computations.

## Design Philosophy

* **Namespaced API**: Clear separation between location and compute operations
* **Workflow-oriented**: Distinct offchain and onchain workflows for location attestations
* **Type-safe**: Full TypeScript support with comprehensive types
* **Batteries included**: Handles signing, encoding, and EAS integration

## Package Structure

```typescript theme={null}
import { AstralSDK } from '@decentralized-geo/astral-sdk';

// Initialize with unified configuration
const astral = new AstralSDK({
  chainId: 84532,
  signer: wallet,
  apiUrl: 'https://api.astral.global'
});

// Location module - offchain workflow
astral.location.offchain.create(input);
astral.location.offchain.sign(unsigned);
astral.location.offchain.verify(attestation);
astral.location.offchain.publish(attestation);

// Location module - onchain workflow
astral.location.onchain.create(input);
astral.location.onchain.register(unsigned);
astral.location.onchain.verify(attestation);
astral.location.onchain.revoke(attestation);

// Location module - common operations
astral.location.build(input);
astral.location.encode(attestation);
astral.location.decode(data);

// Compute module - spatial operations
astral.compute.distance(from, to, options);
astral.compute.area(geometry, options);
astral.compute.length(geometry, options);
astral.compute.contains(container, containee, options);
astral.compute.within(geometry, target, radius, options);
astral.compute.intersects(a, b, options);

// Compute module - submission
astral.compute.submit(delegatedAttestation);
astral.compute.estimate(delegatedAttestation);
astral.compute.health();
```

## Quick Start

```typescript theme={null}
import { AstralSDK } from '@decentralized-geo/astral-sdk';
import { ethers } from 'ethers';

// Initialize with signer
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://api.astral.global'
});

// Create an offchain location attestation
const attestation = await astral.location.offchain.create({
  location: {
    type: 'Point',
    coordinates: [2.2945, 48.8584]
  },
  memo: 'Eiffel Tower'
});

console.log('Attestation UID:', attestation.uid);

// Compute distance between two locations
const distance = await astral.compute.distance(
  attestation.uid,
  landmarkUID,
  { schema: SCHEMA_UID }
);

console.log('Distance:', distance.result, distance.units);

// Submit computation result onchain
await astral.compute.submit(distance.delegatedAttestation);
```

## Key Concepts

<CardGroup cols={2}>
  <Card title="Namespaced Modules" icon="folder-tree">
    Clear separation: `location.offchain.*`, `location.onchain.*`, and `compute.*`
  </Card>

  <Card title="Flexible Inputs" icon="shuffle">
    Accept UIDs, raw GeoJSON, or attestation objects interchangeably.
  </Card>

  <Card title="Delegated Attestations" icon="signature">
    SDK handles the delegated attestation pattern — you pay gas, Astral is attester.
  </Card>

  <Card title="Type Safety" icon="shield-check">
    Full TypeScript types for all inputs, outputs, and options.
  </Card>
</CardGroup>

## Configuration

```typescript theme={null}
interface AstralConfig {
  // Required
  chainId: number;              // Target chain ID (e.g., 84532 for Base Sepolia)

  // Recommended
  signer?: Signer;              // For signing attestations and transactions
  provider?: Provider;          // For read-only blockchain operations
  apiUrl?: string;              // Defaults to 'https://api.astral.global'

  // Advanced
  debug?: boolean;              // Enable debug logging
  schemas?: RuntimeSchemaConfig[];  // Pre-register custom schemas
  defaultSchema?: RuntimeSchemaConfig;  // Override default schema
  strictSchemaValidation?: boolean;     // Throw on schema validation errors
}
```

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

## Module Architecture

```
AstralSDK
├── location: LocationModule
│   ├── offchain: OffchainWorkflow
│   │   ├── create()    - Build + sign in one step
│   │   ├── sign()      - Sign unsigned attestation
│   │   ├── verify()    - Verify signature
│   │   └── publish()   - Store to IPFS/storage
│   ├── onchain: OnchainWorkflow
│   │   ├── create()    - Build + register in one step
│   │   ├── register()  - Register unsigned attestation
│   │   ├── verify()    - Verify onchain attestation
│   │   └── revoke()    - Revoke attestation
│   ├── build()         - Build unsigned attestation
│   ├── encode()        - Encode for EAS
│   └── decode()        - Decode from EAS
└── compute: ComputeModule
    ├── distance()      - Distance between geometries
    ├── area()          - Area of polygon
    ├── length()        - Length of line
    ├── contains()      - Containment check
    ├── within()        - Proximity check
    ├── intersects()    - Intersection check
    ├── submit()        - Submit delegated attestation
    ├── estimate()      - Estimate gas
    └── health()        - Service health check
```

## Pages

<CardGroup cols={2}>
  <Card title="Installation" icon="download" href="/sdk/installation">
    Install and configure the SDK
  </Card>

  <Card title="Location Module" icon="location-dot" href="/sdk/location">
    Offchain and onchain attestation workflows
  </Card>

  <Card title="Compute Module" icon="calculator" href="/sdk/compute">
    Geospatial computation methods
  </Card>

  <Card title="Migration Guide" icon="arrow-right" href="/sdk/migration">
    Migrate from v0.1.x to v0.2.0
  </Card>
</CardGroup>
