API Reference โ
Welcome to the AAstar SDK API Reference. Our SDK is designed with a "Pre-check first, Action second" philosophy, providing tools for different ecosystem roles.
๐ฆ Packages Overview โ
| Package | Purpose |
|---|---|
@aastar/sdk | Meta Package - The most intuitive entry point for all developers. |
@aastar/core | Shared Logic - Essential roles, contract addresses, and requirement checkers. |
@aastar/account | Smart Accounts - ERC-4337 account utilities and factories. |
@aastar/paymaster | Gas Sponsoring - Client and middleware for Paymaster operations. |
@aastar/tokens | Finance - Tools for GT staking and XPNTs management. |
@aastar/identity | Reputation - Community reputation scoring and SBT management. |
@aastar/analytics | Metrics - Real-time ecosystem monitoring and data retrieval. |
@aastar/dapp | React Hooks - Ready-to-use hooks for frontend integration. |
๐ Installation & Quick Start โ
bash
pnpm add @aastar/sdk viem1. Initialize Client โ
typescript
import { createPublicClient, createWalletClient, http } from 'viem';
import { sepolia } from 'viem/chains';
import { createCommunityClient, createOperatorClient } from '@aastar/sdk';
const publicClient = createPublicClient({ chain: sepolia, transport: http() });
const walletClient = createWalletClient({ chain: sepolia, transport: http() });
const community = createCommunityClient({ publicClient, walletClient });2. "Pre-check" Pattern โ
Avoid reverts and save gas by checking requirements off-chain first.
typescript
const check = await community.checkLaunchRequirements(myAddress, parseEther("33"));
if (check.success) {
await community.launchCommunity({ name: "My DAO" });
}๐๏ธ Core Scenarios โ
๐๏ธ For Community Owners โ
Manage your community registry, configure SBT rules, and handle user onboarding.
โ๏ธ For Operators โ
Onboard as a Paymaster operator, stake GToken, and manage your collateral.
๐ For Finance & Analytics โ
Monitor tokenomics, handle GToken staking, and track ecosystem metrics.
๐ Complete Examples โ
Practical implementations for common scenarios:
๐ง TypeScript Support โ
All packages are written in TypeScript with full type definitions.
typescript
import type {
SupportedNetwork,
ClientConfig,
RoleRequirement
} from '@aastar/core';๐ก๏ธ Error Handling โ
typescript
import { AAStarError } from '@aastar/sdk';
try {
// ... SDK call
} catch (error) {
if (error instanceof AAStarError) {
console.error(error.code, error.message);
}
}