@decentralized-geo/astral-sdk v0.1.0
Astral SDK
Create, store, and verify location attestations on any blockchain.
Astral SDK is a developer-friendly TypeScript library that makes location-based attestations simple. Built on Ethereum Attestation Service (EAS), it supports both gasless offchain signatures and permanent onchain registration across multiple networks.
š„ Get started in 30 seconds ā Quick Start
š Complete guide ā Getting Started
š API docs ā API Reference
Why Astral SDK?
š Two ways to create location attestations:
- Offchain: Gasless EIP-712 signatures, instant verification
- Onchain: Permanent blockchain registration with smart contract integration
š Universal location support:
- GeoJSON (Points, Polygons, Features)
- Decimal coordinates
[lng, lat]
- Well-Known Text (WKT)
- H3 geospatial indexing
āļø Multi-chain ready:
- Sepolia (testnet) ⢠Base ⢠Arbitrum ⢠Celo
š« Developer experience:
- 100% TypeScript with full type safety
- Clear workflow separation (no confusion)
- Comprehensive docs and working examples
Installation
# Using pnpm (recommended)
pnpm add @astral-protocol/sdk
# Using npm
npm install @astral-protocol/sdk
# Using yarn
yarn add @astral-protocol/sdk
Quick Start
Installation
pnpm add @astral-protocol/sdk # or npm/yarn
30-Second Example: Offchain Attestation (No Gas Required)
import { AstralSDK } from '@astral-protocol/sdk';
// Connect to your wallet
const sdk = new AstralSDK({
provider: window.ethereum,
defaultChain: 'sepolia'
});
// Create a location attestation
const attestation = await sdk.createOffchainLocationAttestation({
location: [-0.163808, 51.5101], // London coordinates
memo: 'Visited Big Ben today!'
});
// ā
Done! You have a cryptographically signed location attestation
console.log('Attestation UID:', attestation.uid);
Onchain Attestation (Permanent Blockchain Record)
// Same API, different method - registers permanently on blockchain
const onchainAttestation = await sdk.createOnchainLocationAttestation({
location: {
type: 'Point',
coordinates: [2.3522, 48.8566] // Paris
},
memo: 'Onchain proof from the Eiffel Tower'
});
console.log('Transaction:', attestation.txHash);
Location Format Flexibility
// Supports multiple location formats automatically
const formats = [
[-0.163808, 51.5101], // Coordinates [lng, lat]
{ type: 'Point', coordinates: [lng, lat] }, // GeoJSON
'POINT(-0.163808 51.5101)', // Well-Known Text
'8c1fb46741ae9ff' // H3 cell ID
];
// All of these work the same way
for (const location of formats) {
const attestation = await sdk.createOffchainLocationAttestation({
location,
memo: 'Different format, same result'
});
}
Verification & Type Safety
// Verify any attestation
const result = await sdk.verifyOffchainLocationAttestation(attestation);
if (result.isValid) {
console.log('ā
Valid signature from:', result.signerAddress);
} else {
console.log('ā Invalid:', result.reason);
}
// Type guards for handling mixed attestation types
import { isOffchainLocationAttestation } from '@astral-protocol/sdk';
if (isOffchainLocationAttestation(someAttestation)) {
// TypeScript knows this is an offchain attestation
console.log('Signed by:', someAttestation.signer);
}
How It Works
Astral SDK provides two distinct workflows for different use cases:
š Offchain Workflow
Build Attestation ā Sign with EIP-712 ā Optionally Publish
Perfect for: High-volume apps, private proofs, gasless operations
- ā Free (no gas costs)
- ā Instant (no blockchain wait times)
- ā Private until you publish
- ā Works without blockchain connection
āļø Onchain Workflow
Build Attestation ā Submit Transaction ā Permanent Blockchain Record
Perfect for: Smart contracts, immutable records, public verification
- ā Permanent blockchain storage
- ā Smart contract integration
- ā Public verification by default
- ā Native EAS ecosystem compatibility
Note: These workflows create different attestation types with unique identifiers. An offchain attestation cannot be "moved" onchain while preserving its identity.
Supported Networks & Formats
š Networks: Sepolia (testnet) ⢠Base ⢠Arbitrum ⢠Celo
š Formats: GeoJSON ⢠Coordinates ⢠WKT ⢠H3 ⢠Custom extensions
š Documentation
Guide | Description |
---|---|
Getting Started | Step-by-step tutorial from zero to first attestation |
API Reference | Complete API documentation with types |
Offchain Guide | Deep dive into gasless attestations |
Onchain Guide | Blockchain integration patterns |
Examples Cookbook | Real-world usage patterns |
Extension System | Custom location formats and media types |
š§ Development
Quick Setup
# Clone and install
git clone <repo-url>
cd astral-sdk
pnpm install
# Copy environment template
cp .env.example .env.local
# Build and test
pnpm build
pnpm test
Environment Variables
# Required for onchain testing
TEST_PRIVATE_KEY=0x... # Test wallet private key
INFURA_API_KEY=... # Get from infura.io
# Optional
ASTRAL_API_URL=... # Custom API endpoint
Commands
pnpm build # Build the SDK
pnpm test # Run all tests
pnpm lint # Check code style
pnpm typecheck # Verify TypeScript
pnpm dev # Watch mode
š See Development Guide for contributing guidelines.
License
Licensed under the Apache 2.0 License. See LICENSE for details.
Copyright Ā© 2025 Sophia Systems Corporation
5 months ago