@x84-ai/sdk package provides TypeScript bindings for every instruction, account type, and utility in the x84 Solana program. It handles PDA derivation, instruction building, account fetching, event parsing, and error handling.
Installation
Entry points
The SDK has two entry points to keep the core bundle small.| Import | Purpose |
|---|---|
@x84-ai/sdk | Core SDK — instructions, types, PDA helpers, account fetchers, events, errors |
@x84-ai/sdk/settlement | Settlement — Light Protocol integration, compressed receipts, ALT management |
Quick start
Constants and network config
NetworkConfig
Each deployed network exposes a typed config object viagetNetworkConfig("devnet") or getNetworkConfig("mainnet").
| Field | Description |
|---|---|
programId | x84 program address |
collection | Metaplex Core collection NFT mint |
feeTreasury | Treasury wallet for protocol fees |
tokenMint | Payment token (USDC on devnet) |
treasuryTokenAccount | Treasury’s ATA for the token mint |
facilitator | Facilitator signer for delegated settlement |
lightAlt | Settlement ALT (16 static accounts) |
PDA derivation
All PDA functions return[PublicKey, number]. The default programId is X84_PROGRAM_ID.
| Function | Seeds |
|---|---|
findConfigPda | "config" |
findAgentPda | "agent" + nftMint |
findServicePda | "service" + nftMint + serviceTypeSeed |
findFeedbackPda | "feedback" + nftMint + reviewer + nonce (8 bytes) |
findValidationRequestPda | "val_request" + nftMint + validator + hash first 8 bytes |
findValidationResponsePda | "val_response" + nftMint + validator + hash first 8 bytes |
findDelegationPda | "delegation" + delegator + delegate + id (8 bytes) |
findPaymentReqPda | "payment_req" + nftMint + serviceTypeSeed |
findReceiptPda | "receipt" + paymentId |
findCpiAuthorityPda | "cpi_authority" |
Account fetchers
Single account
Batch fetchers
These usegetProgramAccounts with filters for efficient bulk queries.
Utilities
Error handling
The SDK provides structured error parsing for all 49 program error codes (6000-6048).Key error codes
| Code | Name | Description |
|---|---|---|
| 6005 | InvalidFeedbackScore | Must be 0-100 |
| 6010 | AgentInactive | Agent is deactivated |
| 6012 | Unauthorized | Not owner, no valid delegation |
| 6016 | DelegationExpired | Delegation past expiry |
| 6018 | InsufficientPermission | Delegation lacks required permission |
| 6028 | InsufficientPayment | Payment amount too low |
| 6029 | PaymentReplay | Payment ID already used |
| 6034 | ModulePaused | Protocol module is paused |
| 6036 | InsufficientRegistrationFee | Not enough SOL for registration |
| 6038 | FacilitatorRequired | Attestation mode needs facilitator |