UNPKG

solana-token-extension-boost

Version:

SDK for Solana Token Extensions with wallet adapter support

164 lines (163 loc) 6.16 kB
import { Connection, Keypair, PublicKey, Transaction, TransactionInstruction } from "@solana/web3.js"; import { AccountState } from "@solana/spl-token"; export declare class TokenBuilder { private connection; private extensions; private decimals; private mintAuthority; private freezeAuthority; private metadata?; private tokenMetadata?; private transferFee?; private permanentDelegate?; private transferHook?; private confidentialTransfer?; private interestBearing?; private defaultAccountState?; private mintCloseAuthority?; /** * Initialize builder with connection * * @param connection - Connection to Solana cluster */ constructor(connection: Connection); /** * Set basic token information * * @param decimals - Token decimals * @param mintAuthority - Mint authority of the token * @param freezeAuthority - Freeze authority of the token (optional) * @returns this - for method chaining */ setTokenInfo(decimals: number, mintAuthority: PublicKey, freezeAuthority?: PublicKey | null): TokenBuilder; /** * Add metadata extension * * @param name - Token name * @param symbol - Token symbol * @param uri - URI to metadata * @param additionalMetadata - Additional metadata (optional) * @returns this - for method chaining */ addMetadata(name: string, symbol: string, uri: string, additionalMetadata?: Record<string, string>): TokenBuilder; /** * Add token metadata extension (embedded metadata) * * When using this extension, metadata will be stored directly in the mint account * and does not require a separate metadata account * * @param name - Token name * @param symbol - Token symbol * @param uri - URI to metadata * @param additionalMetadata - Additional metadata (optional) * @returns this - for method chaining */ addTokenMetadata(name: string, symbol: string, uri: string, additionalMetadata?: Record<string, string>): TokenBuilder; /** * Add transfer fee extension * * @param feeBasisPoints - Fee in basis points (1% = 100 basis points) * @param maxFee - Maximum fee * @param transferFeeConfigAuthority - Account with authority to update fee config * @param withdrawWithheldAuthority - Account with authority to withdraw collected fees * @returns this - for method chaining */ addTransferFee(feeBasisPoints: number, maxFee: bigint, transferFeeConfigAuthority: PublicKey, withdrawWithheldAuthority: PublicKey): TokenBuilder; /** * Add permanent delegate extension * * @param delegate - Permanent delegate address * @returns this - for method chaining */ addPermanentDelegate(delegate: PublicKey): TokenBuilder; /** * Add interest bearing extension * * @param rate - Interest rate (basis points) * @param rateAuthority - Account with authority to update interest rate * @returns this - for method chaining */ addInterestBearing(rate: number, rateAuthority: PublicKey): TokenBuilder; /** * Add transfer hook extension * * @param programId - Address of transfer hook program * @param extraMetas - Additional metadata (optional) * @returns this - for method chaining */ addTransferHook(programId: PublicKey, extraMetas?: PublicKey[]): TokenBuilder; /** * Add non-transferable extension * * @returns this - for method chaining */ addNonTransferable(): TokenBuilder; /** * Add confidential transfer extension * * @param autoEnable - Whether to auto-enable confidential transfers * @returns this - for method chaining */ addConfidentialTransfer(autoEnable?: boolean): TokenBuilder; /** * Add default account state extension * * @param state - Default account state * @param freezeAuthority - Freeze authority (optional) * @returns this - for method chaining */ addDefaultAccountState(state: AccountState, freezeAuthority?: PublicKey): TokenBuilder; /** * Add mint close authority extension * * @param closeAuthority - Close authority * @returns this - for method chaining */ addMintCloseAuthority(closeAuthority: PublicKey): TokenBuilder; /** * Create instructions for token with configured extensions * * This method returns instructions instead of executing transaction, * making it easy to integrate with wallet adapter. * * @param payer - Public key of the transaction fee payer * @returns Promise with instructions, required signers, and mint address */ createTokenInstructions(payer: PublicKey): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[]; mint: PublicKey; }>; /** * Create instructions for token with multiple extensions - simplified version * * @param payer - Public key of the transaction fee payer * @returns Promise with instructions, required signers, and mint address */ createTokenWithExtensionsInstructions(payer: PublicKey): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[]; mint: PublicKey; }>; /** * Create instructions for token with metadata and other extensions * * @param payer - Public key of the transaction fee payer * @returns Promise with instructions, required signers, and mint address */ createTokenWithMetadataAndExtensionsInstructions(payer: PublicKey): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[]; mint: PublicKey; }>; /** * Build transaction from token instructions * * Utility method to help users create transaction from instructions * * @param instructions - Instructions to include in transaction * @param feePayer - Public key of fee payer * @returns Configured transaction */ buildTransaction(instructions: TransactionInstruction[], feePayer: PublicKey): Transaction; }