UNPKG

@ghostspeak/sdk

Version:

TypeScript SDK for GhostSpeak AI Agent Commerce Protocol - Production Ready Beta

235 lines (228 loc) 8.27 kB
import './StakingModule-CPhp_ZY0.js'; import * as gill from 'gill'; import { Address } from '@solana/addresses'; import './pda-Ce7VYg4T.js'; import './reputation-types-Yebf0Rm_.js'; /** * Solana Attestation Service (SAS) Helper * * Provides utilities for creating and managing SAS attestations for Ghost ownership claims. * * @module SASAttestationHelper */ /** * SAS Program ID (official Solana Foundation attestation service) */ declare const SAS_PROGRAM_ID: Address<"22zoJMtdu4tQc2PzL74ZUT7FrwgB1Udec8DdW4yw4BdG">; /** * Attestation PDA seed prefix */ declare const ATTESTATION_SEED = "attestation"; /** * Credential PDA seed prefix */ declare const CREDENTIAL_SEED = "credential"; /** * Schema PDA seed prefix */ declare const SCHEMA_SEED = "schema"; /** * GhostSpeak ownership credential configuration */ interface GhostSpeakCredentialConfig { /** Credential issuer (typically the GhostSpeak program or a trusted authority) */ issuer: Address; /** Credential name */ name: string; /** Credential description */ description: string; /** Schema definition URI (JSON schema for attestation data) */ schemaUri: string; } /** * SAS Attestation data for Ghost ownership */ interface GhostOwnershipAttestationData { /** x402 payment address being claimed */ x402PaymentAddress: Address; /** Network identifier (devnet, mainnet-beta, etc.) */ network: string; /** Optional GitHub username for verification */ githubUsername?: string; /** Optional Twitter handle for verification */ twitterHandle?: string; /** Timestamp of attestation creation */ timestamp: bigint; } /** * Result of attestation PDA derivation */ interface AttestationPDAResult { /** Derived attestation PDA */ attestationPda: Address; /** Bump seed for PDA */ bump: number; } /** * Configuration for creating a Ghost ownership attestation */ interface CreateAttestationConfig { /** SAS Credential address (issuer of attestations) */ credentialAddress: Address; /** SAS Schema address (defines attestation structure) */ schemaAddress: Address; /** x402 payment address to attest ownership of */ x402PaymentAddress: Address; /** Network identifier */ network: string; /** Optional social proof */ githubUsername?: string; twitterHandle?: string; /** Attestation expiry (Unix timestamp) - defaults to 1 year */ expiryTimestamp?: bigint; } /** * SASAttestationHelper - Utilities for creating and managing SAS attestations */ declare class SASAttestationHelper { /** * Derive attestation PDA for a given credential, schema, and nonce * * PDA seeds: ["attestation", credential, schema, nonce] * * @param credentialAddress - SAS Credential address (issuer) * @param schemaAddress - SAS Schema address (defines structure) * @param nonce - Unique nonce (typically the x402_payment_address) * @returns Attestation PDA and bump */ static deriveAttestationPda(credentialAddress: Address, schemaAddress: Address, nonce: Address): Promise<AttestationPDAResult>; /** * Derive credential PDA for an issuer * * PDA seeds: ["credential", issuer] * * @param issuer - Issuer's public key * @returns Credential PDA and bump */ static deriveCredentialPda(issuer: Address): Promise<AttestationPDAResult>; /** * Derive schema PDA for a credential * * PDA seeds: ["schema", credential, schema_name] * * @param credentialAddress - Credential address * @param schemaName - Schema identifier * @returns Schema PDA and bump */ static deriveSchemaPda(credentialAddress: Address, schemaName: string): Promise<AttestationPDAResult>; /** * Serialize Ghost ownership attestation data for on-chain storage * * Format: Borsh serialization * - x402_payment_address: 32 bytes * - network: String (length-prefixed) * - github_username: Option<String> * - twitter_handle: Option<String> * - timestamp: i64 (8 bytes) * * @param data - Attestation data to serialize * @returns Serialized buffer */ static serializeAttestationData(data: GhostOwnershipAttestationData): Uint8Array; /** * Get GhostSpeak default credential configuration * * This returns the official GhostSpeak credential issuer settings * for production use. * * @param issuer - Credential issuer address (typically the GhostSpeak program authority) * @returns Default credential configuration */ static getDefaultCredentialConfig(issuer: Address): GhostSpeakCredentialConfig; /** * Check if an attestation is expired * * @param expiryTimestamp - Expiry timestamp (Unix seconds) * @param currentTimestamp - Current timestamp (defaults to now) * @returns True if expired */ static isAttestationExpired(expiryTimestamp: bigint, currentTimestamp?: bigint): boolean; /** * Calculate default expiry timestamp (1 year from now) * * @param fromTimestamp - Starting timestamp (defaults to now) * @returns Expiry timestamp */ static calculateDefaultExpiry(fromTimestamp?: bigint): bigint; /** * Create attestation instruction data * * NOTE: This is a helper for building the SAS create_attestation instruction. * The actual instruction building should be done using the SAS SDK or program IDL. * * @param config - Attestation configuration * @returns Prepared attestation data and PDA */ static prepareAttestation(config: CreateAttestationConfig): Promise<{ attestationData: Uint8Array; attestationPda: Address; bump: number; expiryTimestamp: bigint; }>; } /** * GhostSpeak Protocol Constants * July 2025 Implementation */ /** * Program ID for GhostSpeak Marketplace on Solana * Deployed on devnet - December 30, 2025 * Deployment signature: 5zdU8HdtenhgwDmeEJu2ZPrQwoG9gztHHM5Ft6URxCzTj7m4y9ZkvmVKrpvMK41skcHvh8xa7ckNuUkQwPsierJr */ declare const GHOSTSPEAK_PROGRAM_ID: gill.Address<"4wHjA2a5YC4twZb4NQpwZpixo5FgxxzuJUrCG7UnF9pB">; /** * Network-specific configurations */ declare const NETWORK_CONFIG: { readonly devnet: { readonly programId: "4wHjA2a5YC4twZb4NQpwZpixo5FgxxzuJUrCG7UnF9pB"; readonly rpcUrl: "https://api.devnet.solana.com"; }; readonly testnet: { readonly programId: "4wHjA2a5YC4twZb4NQpwZpixo5FgxxzuJUrCG7UnF9pB"; readonly rpcUrl: "https://api.testnet.solana.com"; }; readonly mainnet: { readonly programId: "4wHjA2a5YC4twZb4NQpwZpixo5FgxxzuJUrCG7UnF9pB"; readonly rpcUrl: "https://api.mainnet-beta.solana.com"; }; }; /** * System Program Addresses for Solana * * These are the standard system program addresses used across Solana. * Using constants instead of hardcoded values improves maintainability * and ensures consistency across the SDK. */ /** * SPL Token Program * The standard SPL Token program */ declare const TOKEN_PROGRAM_ADDRESS: Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; /** * SPL Token 2022 Program (Token Extensions) * The new token program with extended functionality */ declare const TOKEN_2022_PROGRAM_ADDRESS: Address<"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb">; /** * Associated Token Account Program * Manages associated token accounts */ declare const ASSOCIATED_TOKEN_PROGRAM_ADDRESS: Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">; /** * Native SOL Mint Address (wSOL) - Token 2022 Program * The mint address for wrapped SOL on Token 2022 * This is the one used by GhostSpeak escrow operations */ declare const NATIVE_MINT_ADDRESS: Address<"9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP">; export { ATTESTATION_SEED as A, CREDENTIAL_SEED as C, type GhostSpeakCredentialConfig as G, NATIVE_MINT_ADDRESS as N, SASAttestationHelper as S, TOKEN_PROGRAM_ADDRESS as T, SAS_PROGRAM_ID as a, SCHEMA_SEED as b, type GhostOwnershipAttestationData as c, type AttestationPDAResult as d, type CreateAttestationConfig as e, GHOSTSPEAK_PROGRAM_ID as f, TOKEN_2022_PROGRAM_ADDRESS as g, ASSOCIATED_TOKEN_PROGRAM_ADDRESS as h, NETWORK_CONFIG as i };