Skip to main content

Configuration

Connect the SDK to your Web3 wallet and choose your network.

Basic Configuration

The simplest setup uses a self-contained wallet:

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

// Create a self-contained wallet for testing
const privateKey = Wallet.createRandom().privateKey;
const wallet = new Wallet(privateKey);

const sdk = new AstralSDK({
signer: wallet
});

Configuration Options

→ Supported Chains

type SupportedChain = 
| 'sepolia' // Ethereum testnet (recommended for development)
| 'base' // Base mainnet
| 'arbitrum' // Arbitrum One
| 'celo' // Celo mainnet

→ Full Configuration

const sdk = new AstralSDK({
// Required
signer: wallet, // ethers.js signer

// Optional
chainId: 11155111, // Chain ID (Sepolia)
apiUrl: 'https://api.astral.com', // Custom API endpoint
debug: true // Enable debug logging
});

Provider Options

Browser Wallet (For Production)

// MetaMask or other injected wallets
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();

const sdk = new AstralSDK({
signer: signer
});

Custom Provider

import { ethers } from 'ethers';

// Using ethers.js provider for onchain operations
const provider = new ethers.JsonRpcProvider('https://rpc.sepolia.org');
const wallet = new ethers.Wallet(privateKey, provider);

const sdk = new AstralSDK({
signer: wallet,
chainId: 11155111 // Sepolia
});

Verify Configuration

// Check connection
const address = await sdk.getAddress();
console.log('Connected wallet:', address);

// Check chain
const chainId = await sdk.getChainId();
console.log('Connected to chain:', chainId);

Next: First Attestation