///
import { PublicKey, AccountInfo, Commitment, TransactionInstruction, Signer, Keypair, ConfirmOptions, TransactionSignature, AccountMeta, Connection } from '@solana/web3.js';
import { MerkleContext, CompressedAccountWithMerkleContext, Rpc, ValidityProofWithContext, AddressTreeInfo, TreeInfo, ParsedTokenAccount, TreeType, PackedMerkleContextLegacy, CompressedCpiContext, ValidityProof, InputTokenDataWithContext as InputTokenDataWithContext$1, CompressedProof } from '@lightprotocol/stateless.js';
export { ParsedTokenAccount } from '@lightprotocol/stateless.js';
import { Account, Mint } from '@solana/spl-token';
export { AccountState } from '@solana/spl-token';
declare namespace BN {
type Endianness = "le" | "be";
type IPrimeName = "k256" | "p224" | "p192" | "p25519";
interface MPrime {
name: string;
p: BN;
n: number;
k: BN;
}
interface ReductionContext {
m: number;
prime: MPrime;
[key: string]: any;
}
}
declare class BN {
static BN: typeof BN;
static wordSize: 26;
constructor(
number: bigint | number | string | number[] | Uint8Array | Buffer | BN,
base?: number | "hex",
endian?: BN.Endianness,
);
constructor(
number: bigint | number | string | number[] | Uint8Array | Buffer | BN,
endian?: BN.Endianness,
);
/**
* @description create a reduction context
*/
static red(reductionContext: BN | BN.IPrimeName): BN.ReductionContext;
/**
* @description create a reduction context with the Montgomery trick.
*/
static mont(num: BN): BN.ReductionContext;
/**
* @description returns true if the supplied object is a BN.js instance
*/
static isBN(b: any): b is BN;
/**
* @description returns the maximum of 2 BN instances.
*/
static max(left: BN, right: BN): BN;
/**
* @description returns the minimum of 2 BN instances.
*/
static min(left: BN, right: BN): BN;
/**
* @description Copy to dest number
*/
copy(dest: BN): void;
/**
* @description clone number
*/
clone(): BN;
/**
* @description convert to base-string and pad with zeroes
*/
toString(base?: number | "hex", length?: number): string;
/**
* @description convert to Javascript Number (limited to 53 bits)
*/
toNumber(): number;
/**
* @description convert to JSON compatible hex string (alias of toString(16))
*/
toJSON(): string;
/**
* @description convert to byte Array, and optionally zero pad to length, throwing if already exceeding
*/
toArray(endian?: BN.Endianness, length?: number): number[];
/**
* @description convert to an instance of `type`, which must behave like an Array
*/
toArrayLike(
ArrayType: typeof Buffer,
endian?: BN.Endianness,
length?: number,
): Buffer;
toArrayLike(
ArrayType: any[],
endian?: BN.Endianness,
length?: number,
): any[];
/**
* @description convert to Node.js Buffer (if available). For compatibility with browserify and similar tools, use this instead: a.toArrayLike(Buffer, endian, length)
*/
toBuffer(endian?: BN.Endianness, length?: number): Buffer;
/**
* @description get number of bits occupied
*/
bitLength(): number;
/**
* @description return number of less-significant consequent zero bits (example: 1010000 has 4 zero bits)
*/
zeroBits(): number;
/**
* @description return number of bytes occupied
*/
byteLength(): number;
/**
* @description true if the number is negative
*/
isNeg(): boolean;
/**
* @description check if value is even
*/
isEven(): boolean;
/**
* @description check if value is odd
*/
isOdd(): boolean;
/**
* @description check if value is zero
*/
isZero(): boolean;
/**
* @description compare numbers and return `-1 (a < b)`, `0 (a == b)`, or `1 (a > b)` depending on the comparison result
*/
cmp(b: BN): -1 | 0 | 1;
/**
* @description compare numbers and return `-1 (a < b)`, `0 (a == b)`, or `1 (a > b)` depending on the comparison result
*/
ucmp(b: BN): -1 | 0 | 1;
/**
* @description compare numbers and return `-1 (a < b)`, `0 (a == b)`, or `1 (a > b)` depending on the comparison result
*/
cmpn(b: number): -1 | 0 | 1;
/**
* @description a less than b
*/
lt(b: BN): boolean;
/**
* @description a less than b
*/
ltn(b: number): boolean;
/**
* @description a less than or equals b
*/
lte(b: BN): boolean;
/**
* @description a less than or equals b
*/
lten(b: number): boolean;
/**
* @description a greater than b
*/
gt(b: BN): boolean;
/**
* @description a greater than b
*/
gtn(b: number): boolean;
/**
* @description a greater than or equals b
*/
gte(b: BN): boolean;
/**
* @description a greater than or equals b
*/
gten(b: number): boolean;
/**
* @description a equals b
*/
eq(b: BN): boolean;
/**
* @description a equals b
*/
eqn(b: number): boolean;
/**
* @description convert to two's complement representation, where width is bit width
*/
toTwos(width: number): BN;
/**
* @description convert from two's complement representation, where width is the bit width
*/
fromTwos(width: number): BN;
/**
* @description negate sign
*/
neg(): BN;
/**
* @description negate sign
*/
ineg(): BN;
/**
* @description absolute value
*/
abs(): BN;
/**
* @description absolute value
*/
iabs(): BN;
/**
* @description addition
*/
add(b: BN): BN;
/**
* @description addition
*/
iadd(b: BN): BN;
/**
* @description addition
*/
addn(b: number): BN;
/**
* @description addition
*/
iaddn(b: number): BN;
/**
* @description subtraction
*/
sub(b: BN): BN;
/**
* @description subtraction
*/
isub(b: BN): BN;
/**
* @description subtraction
*/
subn(b: number): BN;
/**
* @description subtraction
*/
isubn(b: number): BN;
/**
* @description multiply
*/
mul(b: BN): BN;
/**
* @description multiply
*/
imul(b: BN): BN;
/**
* @description multiply
*/
muln(b: number): BN;
/**
* @description multiply
*/
imuln(b: number): BN;
/**
* @description square
*/
sqr(): BN;
/**
* @description square
*/
isqr(): BN;
/**
* @description raise `a` to the power of `b`
*/
pow(b: BN): BN;
/**
* @description divide
*/
div(b: BN): BN;
/**
* @description divide
*/
divn(b: number): BN;
/**
* @description divide
*/
idivn(b: number): BN;
/**
* @description division with remainder
*/
divmod(b: BN, mode?: "div" | "mod", positive?: boolean): { div: BN; mod: BN };
/**
* @description reduct
*/
mod(b: BN): BN;
/**
* @description reduct
*/
umod(b: BN): BN;
/**
* @deprecated
* @description reduct
*/
modn(b: number): number;
/**
* @description reduct
*/
modrn(b: number): number;
/**
* @description rounded division
*/
divRound(b: BN): BN;
/**
* @description or
*/
or(b: BN): BN;
/**
* @description or
*/
ior(b: BN): BN;
/**
* @description or
*/
uor(b: BN): BN;
/**
* @description or
*/
iuor(b: BN): BN;
/**
* @description and
*/
and(b: BN): BN;
/**
* @description and
*/
iand(b: BN): BN;
/**
* @description and
*/
uand(b: BN): BN;
/**
* @description and
*/
iuand(b: BN): BN;
/**
* @description and (NOTE: `andln` is going to be replaced with `andn` in future)
*/
andln(b: number): BN;
/**
* @description xor
*/
xor(b: BN): BN;
/**
* @description xor
*/
ixor(b: BN): BN;
/**
* @description xor
*/
uxor(b: BN): BN;
/**
* @description xor
*/
iuxor(b: BN): BN;
/**
* @description set specified bit to value
*/
setn(b: number, value: boolean | 0 | 1): BN;
/**
* @description shift left
*/
shln(b: number): BN;
/**
* @description shift left
*/
ishln(b: number): BN;
/**
* @description shift left
*/
ushln(b: number): BN;
/**
* @description shift left
*/
iushln(b: number): BN;
/**
* @description shift right
*/
shrn(b: number): BN;
/**
* @description shift right (unimplemented https://github.com/indutny/bn.js/blob/master/lib/bn.js#L2086)
*/
ishrn(b: number): BN;
/**
* @description shift right
*/
ushrn(b: number): BN;
/**
* @description shift right
*/
iushrn(b: number): BN;
/**
* @description test if specified bit is set
*/
testn(b: number): boolean;
/**
* @description clear bits with indexes higher or equal to `b`
*/
maskn(b: number): BN;
/**
* @description clear bits with indexes higher or equal to `b`
*/
imaskn(b: number): BN;
/**
* @description add `1 << b` to the number
*/
bincn(b: number): BN;
/**
* @description not (for the width specified by `w`)
*/
notn(w: number): BN;
/**
* @description not (for the width specified by `w`)
*/
inotn(w: number): BN;
/**
* @description GCD
*/
gcd(b: BN): BN;
/**
* @description Extended GCD results `({ a: ..., b: ..., gcd: ... })`
*/
egcd(b: BN): { a: BN; b: BN; gcd: BN };
/**
* @description inverse `a` modulo `b`
*/
invm(b: BN): BN;
/**
* @description Convert number to red
*/
toRed(reductionContext: BN.ReductionContext): RedBN;
}
/**
* BN operations in a reduction context.
*/
declare class RedBN extends BN {
/**
* @description Convert back a number using a reduction context
*/
fromRed(): BN;
/**
* @description modular addition
*/
redAdd(b: RedBN): RedBN;
/**
* @description in-place modular addition
*/
redIAdd(b: RedBN): RedBN;
/**
* @description modular subtraction
*/
redSub(b: RedBN): RedBN;
/**
* @description in-place modular subtraction
*/
redISub(b: RedBN): RedBN;
/**
* @description modular shift left
*/
redShl(num: number): RedBN;
/**
* @description modular multiplication
*/
redMul(b: RedBN): RedBN;
/**
* @description in-place modular multiplication
*/
redIMul(b: RedBN): RedBN;
/**
* @description modular square
*/
redSqr(): RedBN;
/**
* @description in-place modular square
*/
redISqr(): RedBN;
/**
* @description modular square root
*/
redSqrt(): RedBN;
/**
* @description modular inverse of the number
*/
redInvm(): RedBN;
/**
* @description modular negation
*/
redNeg(): RedBN;
/**
* @description modular exponentiation
*/
redPow(b: BN): RedBN;
}
declare class Buffer$1 extends Uint8Array {
length: number
write(string: string, offset?: number, length?: number, encoding?: string): number;
toString(encoding?: string, start?: number, end?: number): string;
toJSON(): { type: 'Buffer', data: any[] };
equals(otherBuffer: Buffer$1): boolean;
compare(otherBuffer: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
copy(targetBuffer: Buffer$1, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
slice(start?: number, end?: number): Buffer$1;
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readUInt8(offset: number, noAssert?: boolean): number;
readUInt16LE(offset: number, noAssert?: boolean): number;
readUInt16BE(offset: number, noAssert?: boolean): number;
readUInt32LE(offset: number, noAssert?: boolean): number;
readUInt32BE(offset: number, noAssert?: boolean): number;
readBigUInt64LE(offset: number): BigInt;
readBigUInt64BE(offset: number): BigInt;
readInt8(offset: number, noAssert?: boolean): number;
readInt16LE(offset: number, noAssert?: boolean): number;
readInt16BE(offset: number, noAssert?: boolean): number;
readInt32LE(offset: number, noAssert?: boolean): number;
readInt32BE(offset: number, noAssert?: boolean): number;
readBigInt64LE(offset: number): BigInt;
readBigInt64BE(offset: number): BigInt;
readFloatLE(offset: number, noAssert?: boolean): number;
readFloatBE(offset: number, noAssert?: boolean): number;
readDoubleLE(offset: number, noAssert?: boolean): number;
readDoubleBE(offset: number, noAssert?: boolean): number;
reverse(): this;
swap16(): Buffer$1;
swap32(): Buffer$1;
swap64(): Buffer$1;
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeBigUInt64LE(value: number, offset: number): BigInt;
writeBigUInt64BE(value: number, offset: number): BigInt;
writeInt8(value: number, offset: number, noAssert?: boolean): number;
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeBigInt64LE(value: number, offset: number): BigInt;
writeBigInt64BE(value: number, offset: number): BigInt;
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
fill(value: any, offset?: number, end?: number): this;
indexOf(value: string | number | Buffer$1, byteOffset?: number, encoding?: string): number;
lastIndexOf(value: string | number | Buffer$1, byteOffset?: number, encoding?: string): number;
includes(value: string | number | Buffer$1, byteOffset?: number, encoding?: string): boolean;
/**
* Allocates a new buffer containing the given {str}.
*
* @param str String to store in buffer.
* @param encoding encoding to use, optional. Default is 'utf8'
*/
constructor (str: string, encoding?: string);
/**
* Allocates a new buffer of {size} octets.
*
* @param size count of octets to allocate.
*/
constructor (size: number);
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
*/
constructor (array: Uint8Array);
/**
* Produces a Buffer backed by the same allocated memory as
* the given {ArrayBuffer}.
*
*
* @param arrayBuffer The ArrayBuffer with which to share memory.
*/
constructor (arrayBuffer: ArrayBuffer);
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
*/
constructor (array: any[]);
/**
* Copies the passed {buffer} data onto a new {Buffer} instance.
*
* @param buffer The buffer to copy.
*/
constructor (buffer: Buffer$1);
prototype: Buffer$1;
/**
* Allocates a new Buffer using an {array} of octets.
*
* @param array
*/
static from(array: any[]): Buffer$1;
/**
* When passed a reference to the .buffer property of a TypedArray instance,
* the newly created Buffer will share the same allocated memory as the TypedArray.
* The optional {byteOffset} and {length} arguments specify a memory range
* within the {arrayBuffer} that will be shared by the Buffer.
*
* @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
* @param byteOffset
* @param length
*/
static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer$1;
/**
* Copies the passed {buffer} data onto a new Buffer instance.
*
* @param buffer
*/
static from(buffer: Buffer$1 | Uint8Array): Buffer$1;
/**
* Creates a new Buffer containing the given JavaScript string {str}.
* If provided, the {encoding} parameter identifies the character encoding.
* If not provided, {encoding} defaults to 'utf8'.
*
* @param str
*/
static from(str: string, encoding?: string): Buffer$1;
/**
* Returns true if {obj} is a Buffer
*
* @param obj object to test.
*/
static isBuffer(obj: any): obj is Buffer$1;
/**
* Returns true if {encoding} is a valid encoding argument.
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
*
* @param encoding string to test.
*/
static isEncoding(encoding: string): boolean;
/**
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
* This is not the same as String.prototype.length since that returns the number of characters in a string.
*
* @param string string to test.
* @param encoding encoding used to evaluate (defaults to 'utf8')
*/
static byteLength(string: string, encoding?: string): number;
/**
* Returns a buffer which is the result of concatenating all the buffers in the list together.
*
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
* If the list has exactly one item, then the first item of the list is returned.
* If the list has more than one item, then a new Buffer is created.
*
* @param list An array of Buffer objects to concatenate
* @param totalLength Total length of the buffers when concatenated.
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
*/
static concat(list: Uint8Array[], totalLength?: number): Buffer$1;
/**
* The same as buf1.compare(buf2).
*/
static compare(buf1: Uint8Array, buf2: Uint8Array): number;
/**
* Allocates a new buffer of {size} octets.
*
* @param size count of octets to allocate.
* @param fill if specified, buffer will be initialized by calling buf.fill(fill).
* If parameter is omitted, buffer will be filled with zeros.
* @param encoding encoding used for call to buf.fill while initializing
*/
static alloc(size: number, fill?: string | Buffer$1 | number, encoding?: string): Buffer$1;
/**
* Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
* of the newly created Buffer are unknown and may contain sensitive data.
*
* @param size count of octets to allocate
*/
static allocUnsafe(size: number): Buffer$1;
/**
* Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
* of the newly created Buffer are unknown and may contain sensitive data.
*
* @param size count of octets to allocate
*/
static allocUnsafeSlow(size: number): Buffer$1;
}
declare const TokenAccountSourceType: {
readonly Spl: "spl";
readonly Token2022: "token2022";
readonly SplCold: "spl-cold";
readonly Token2022Cold: "token2022-cold";
readonly LightTokenHot: "light-token-hot";
readonly LightTokenCold: "light-token-cold";
};
type TokenAccountSourceTypeValue = (typeof TokenAccountSourceType)[keyof typeof TokenAccountSourceType];
/** @internal */
interface TokenAccountSource {
type: TokenAccountSourceTypeValue;
address: PublicKey;
amount: bigint;
accountInfo: AccountInfo;
loadContext?: MerkleContext;
parsed: Account;
}
interface AccountInterface {
accountInfo: AccountInfo;
parsed: Account;
isCold: boolean;
loadContext?: MerkleContext;
_sources?: TokenAccountSource[];
_needsConsolidation?: boolean;
_hasDelegate?: boolean;
_anyFrozen?: boolean;
/** True when fetched via getAtaInterface */
_isAta?: boolean;
/** Associated token account owner - set by getAtaInterface */
_owner?: PublicKey;
/** Associated token account mint - set by getAtaInterface */
_mint?: PublicKey;
}
/** @internal */
declare function convertTokenDataToAccount(address: PublicKey, tokenData: {
mint: PublicKey;
owner: PublicKey;
amount: BN;
delegate: PublicKey | null;
state: number;
tlv: Buffer$1 | null;
}): Account;
/** Convert compressed account to AccountInfo */
declare function toAccountInfo(compressedAccount: CompressedAccountWithMerkleContext): AccountInfo;
/** @internal */
declare function parseLightTokenHot(address: PublicKey, accountInfo: AccountInfo): {
accountInfo: AccountInfo;
loadContext: undefined;
parsed: Account;
isCold: false;
};
/** @internal */
declare function parseLightTokenCold(address: PublicKey, compressedAccount: CompressedAccountWithMerkleContext): {
accountInfo: AccountInfo;
loadContext: MerkleContext;
parsed: Account;
isCold: true;
};
/**
* Retrieve information about a token account of SPL/T22/light-token.
*
* @param rpc RPC connection to use
* @param address Token account address
* @param commitment Desired level of commitment for querying the state
* @param programId Token program ID. If not provided, tries all programs concurrently.
*
* @return Token account information with compression context if applicable
*/
declare function getAccountInterface(rpc: Rpc, address: PublicKey, commitment?: Commitment, programId?: PublicKey): Promise;
/**
* SPL interface PDA info.
*/
type SplInterfaceInfo = {
/**
* The mint of the SPL interface
*/
mint: PublicKey;
/**
* The SPL interface address
*/
splInterfacePda: PublicKey;
/**
* The token program of the SPL interface
*/
tokenProgram: PublicKey;
/**
* count of txs and volume in the past 60 seconds.
*/
activity?: {
txs: number;
amountAdded: BN;
amountRemoved: BN;
};
/**
* Whether the SPL interface is initialized
*/
isInitialized: boolean;
/**
* The balance of the SPL interface
*/
balance: BN;
/**
* The index of the SPL interface
*/
poolIndex: number;
/**
* The bump used to derive the SPL interface PDA
*/
bump: number;
};
/**
* @deprecated Use {@link SplInterfaceInfo} instead.
* This type maintains backward compatibility by including both tokenPoolPda and splInterfacePda.
* Both properties point to the same PublicKey value.
*/
type TokenPoolInfo = {
/**
* The mint of the SPL interface
*/
mint: PublicKey;
/**
* @deprecated Use splInterfacePda instead.
*/
tokenPoolPda: PublicKey;
/**
* The SPL interface address (new name).
* For backward compatibility, tokenPoolPda is also available.
*/
splInterfacePda: PublicKey;
/**
* The token program of the SPL interface
*/
tokenProgram: PublicKey;
/**
* count of txs and volume in the past 60 seconds.
*/
activity?: {
txs: number;
amountAdded: BN;
amountRemoved: BN;
};
/**
* Whether the SPL interface is initialized
*/
isInitialized: boolean;
/**
* The balance of the SPL interface
*/
balance: BN;
/**
* The index of the SPL interface
*/
poolIndex: number;
/**
* The bump used to derive the SPL interface PDA
*/
bump: number;
};
/**
* Convert SplInterfaceInfo to TokenPoolInfo for backward compatibility.
* @internal
*/
declare function toTokenPoolInfo(info: SplInterfaceInfo): TokenPoolInfo;
/**
* Derive SplInterfaceInfo for an SPL interface that will be initialized in the
* same transaction. Use this when you need to create an SPL interface and
* compress in a single transaction.
*
* @param mint The mint of the SPL interface
* @param tokenProgramId The token program (TOKEN_PROGRAM_ID or TOKEN_2022_PROGRAM_ID)
* @param poolIndex The pool index. Default 0.
*
* @returns SplInterfaceInfo for the to-be-initialized interface
*/
declare function deriveSplInterfaceInfo(mint: PublicKey, tokenProgramId: PublicKey, poolIndex?: number): SplInterfaceInfo;
/**
* Check if the SPL interface info is initialized and has a balance.
* @param mint The mint of the SPL interface
* @param splInterfaceInfo The SPL interface info (or TokenPoolInfo for backward compatibility)
* @returns True if the SPL interface info is initialized and has a balance
*/
declare function checkSplInterfaceInfo(splInterfaceInfo: SplInterfaceInfo | TokenPoolInfo, mint: PublicKey): boolean;
/**
* Get the SPL interface infos for a given mint.
* @param rpc The RPC client
* @param mint The mint of the SPL interface
* @param commitment The commitment to use
*
* @returns The SPL interface infos
*/
declare function getSplInterfaceInfos(rpc: Rpc, mint: PublicKey, commitment?: Commitment): Promise;
type SplInterfaceActivity = {
signature: string;
amount: BN;
action: Action;
};
/**
* @internal
*/
declare enum Action {
Compress = 1,
Decompress = 2,
Transfer = 3
}
/**
* For `compress` and `mintTo` instructions only.
* Select a random SPL interface info from the SPL interface infos.
*
* For `decompress`, use {@link selectSplInterfaceInfosForDecompression} instead.
*
* @param infos The SPL interface infos
*
* @returns A random SPL interface info
*/
declare function selectSplInterfaceInfo(infos: SplInterfaceInfo[]): SplInterfaceInfo;
/**
* Select one or multiple SPL interface infos from the SPL interface infos.
*
* Use this function for `decompress`.
*
* For `compress`, `mintTo` use {@link selectSplInterfaceInfo} instead.
*
* @param infos The SPL interface infos
* @param decompressAmount The amount of tokens to withdraw
*
* @returns Array with one or more SPL interface infos.
*/
declare function selectSplInterfaceInfosForDecompression(infos: SplInterfaceInfo[], decompressAmount: number | BN): SplInterfaceInfo[];
/**
* @deprecated Use {@link SplInterfaceActivity} instead.
*/
type TokenPoolActivity = SplInterfaceActivity;
/**
* @deprecated Use {@link deriveSplInterfaceInfo} instead.
*/
declare function deriveTokenPoolInfo(mint: PublicKey, tokenProgramId: PublicKey, poolIndex?: number): TokenPoolInfo;
/**
* @deprecated Use {@link checkSplInterfaceInfo} instead.
*/
declare function checkTokenPoolInfo(tokenPoolInfo: TokenPoolInfo, mint: PublicKey): boolean;
/**
* @deprecated Use {@link getSplInterfaceInfos} instead.
*/
declare function getTokenPoolInfos(rpc: Rpc, mint: PublicKey, commitment?: Commitment): Promise;
/**
* @deprecated Use {@link selectSplInterfaceInfo} instead.
*/
declare function selectTokenPoolInfo(infos: TokenPoolInfo[]): TokenPoolInfo;
/**
* @deprecated Use {@link selectSplInterfaceInfosForDecompression} instead.
*/
declare function selectTokenPoolInfosForDecompression(infos: TokenPoolInfo[], decompressAmount: number | BN): TokenPoolInfo[];
interface LayoutObject {
[key: string]: any;
}
/**
* Base class for layout objects.
*
* **NOTE** This is an abstract base class; you can create instances
* if it amuses you, but they won't support the {@link
* Layout#encode|encode} or {@link Layout#decode|decode} functions.
*
* @param {Number} span - Initializer for {@link Layout#span|span}. The
* parameter must be an integer; a negative value signifies that the
* span is {@link Layout#getSpan|value-specific}.
*
* @param {string} [property] - Initializer for {@link
* Layout#property|property}.
*
* @abstract
*/
declare abstract class Layout {
span: number;
property?: string;
boundConstructor_?: any;
constructor(span: number, property?: string);
/** Function to create an Object into which decoded properties will
* be written.
*
* Used only for layouts that {@link Layout#decode|decode} to Object
* instances, which means:
* * {@link Structure}
* * {@link Union}
* * {@link VariantLayout}
* * {@link BitStructure}
*
* If left undefined the JavaScript representation of these layouts
* will be Object instances.
*
* See {@link bindConstructorLayout}.
*/
makeDestinationObject(): LayoutObject;
/**
* Decode from a Uint8Array into a JavaScript value.
*
* @param {Uint8Array} b - the buffer from which encoded data is read.
*
* @param {Number} [offset] - the offset at which the encoded data
* starts. If absent a zero offset is inferred.
*
* @returns {(Number|Array|Object)} - the value of the decoded data.
*
* @abstract
*/
abstract decode(b: Uint8Array, offset?: number): T;
/**
* Encode a JavaScript value into a Uint8Array.
*
* @param {(Number|Array|Object)} src - the value to be encoded into
* the buffer. The type accepted depends on the (sub-)type of {@link
* Layout}.
*
* @param {Uint8Array} b - the buffer into which encoded data will be
* written.
*
* @param {Number} [offset] - the offset at which the encoded data
* starts. If absent a zero offset is inferred.
*
* @returns {Number} - the number of bytes encoded, including the
* space skipped for internal padding, but excluding data such as
* {@link Sequence#count|lengths} when stored {@link
* ExternalLayout|externally}. This is the adjustment to `offset`
* producing the offset where data for the next layout would be
* written.
*
* @abstract
*/
abstract encode(src: T, b: Uint8Array, offset?: number): number;
/**
* Calculate the span of a specific instance of a layout.
*
* @param {Uint8Array} b - the buffer that contains an encoded instance.
*
* @param {Number} [offset] - the offset at which the encoded instance
* starts. If absent a zero offset is inferred.
*
* @return {Number} - the number of bytes covered by the layout
* instance. If this method is not overridden in a subclass the
* definition-time constant {@link Layout#span|span} will be
* returned.
*
* @throws {RangeError} - if the length of the value cannot be
* determined.
*/
getSpan(b?: Uint8Array, offset?: number): number;
/**
* Replicate the layout using a new property.
*
* This function must be used to get a structurally-equivalent layout
* with a different name since all {@link Layout} instances are
* immutable.
*
* **NOTE** This is a shallow copy. All fields except {@link
* Layout#property|property} are strictly equal to the origin layout.
*
* @param {String} property - the value for {@link
* Layout#property|property} in the replica.
*
* @returns {Layout} - the copy with {@link Layout#property|property}
* set to `property`.
*/
replicate(property: string): this;
/**
* Create an object from layout properties and an array of values.
*
* **NOTE** This function returns `undefined` if invoked on a layout
* that does not return its value as an Object. Objects are
* returned for things that are a {@link Structure}, which includes
* {@link VariantLayout|variant layouts} if they are structures, and
* excludes {@link Union}s. If you want this feature for a union
* you must use {@link Union.getVariant|getVariant} to select the
* desired layout.
*
* @param {Array} values - an array of values that correspond to the
* default order for properties. As with {@link Layout#decode|decode}
* layout elements that have no property name are skipped when
* iterating over the array values. Only the top-level properties are
* assigned; arguments are not assigned to properties of contained
* layouts. Any unused values are ignored.
*
* @return {(Object|undefined)}
*/
fromArray(values: any[]): LayoutObject | undefined;
}
interface AdditionalMetadata {
key: Buffer$1;
value: Buffer$1;
}
/**
* Token metadata for creating a light-token mint.
*/
interface TokenMetadataInstructionData {
name: string;
symbol: string;
uri: string;
updateAuthority?: PublicKey | null;
additionalMetadata: AdditionalMetadata[] | null;
}
declare function createTokenMetadata(name: string, symbol: string, uri: string, updateAuthority?: PublicKey | null, additionalMetadata?: AdditionalMetadata[] | null): TokenMetadataInstructionData;
/**
* Create instruction for initializing a light-token mint.
*
* @param mintSigner Mint signer keypair public key.
* @param decimals Number of decimals for the mint.
* @param mintAuthority Mint authority public key.
* @param freezeAuthority Optional freeze authority public key.
* @param payer Fee payer public key.
* @param validityProof Validity proof for the mint account.
* @param addressTreeInfo Address tree info for the mint.
* @param outputStateTreeInfo Output state tree info.
* @param metadata Optional token metadata.
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
*/
declare function createMintInstruction(mintSigner: PublicKey, decimals: number, mintAuthority: PublicKey, freezeAuthority: PublicKey | null, payer: PublicKey, validityProof: ValidityProofWithContext, addressTreeInfo: AddressTreeInfo, outputStateTreeInfo: TreeInfo, metadata?: TokenMetadataInstructionData, maxTopUp?: number): TransactionInstruction;
/**
* SPL-compatible base mint structure
*/
interface BaseMint {
/** Optional authority used to mint new tokens */
mintAuthority: PublicKey | null;
/** Total supply of tokens */
supply: bigint;
/** Number of base 10 digits to the right of the decimal place */
decimals: number;
/** Is initialized - for SPL compatibility */
isInitialized: boolean;
/** Optional authority to freeze token accounts */
freezeAuthority: PublicKey | null;
}
/**
* Light mint context (protocol version, SPL mint reference)
*/
interface MintContext {
/** Protocol version for upgradability */
version: number;
/** Whether the compressed light mint has been decompressed to a light mint account */
cmintDecompressed: boolean;
/** PDA of the associated SPL mint */
splMint: PublicKey;
/** Signer pubkey used to derive the mint PDA */
mintSigner: Uint8Array;
/** Bump seed for the mint PDA */
bump: number;
}
/**
* Raw extension data as stored on-chain
*/
interface MintExtension {
extensionType: number;
data: Uint8Array;
}
/**
* Parsed token metadata matching on-chain TokenMetadata extension.
* Fields: updateAuthority, mint, name, symbol, uri, additionalMetadata
*/
interface TokenMetadata {
/** Authority that can update metadata (None if zero pubkey) */
updateAuthority?: PublicKey | null;
/** Associated mint pubkey */
mint: PublicKey;
/** Token name */
name: string;
/** Token symbol */
symbol: string;
/** URI pointing to off-chain metadata JSON */
uri: string;
/** Additional key-value metadata pairs */
additionalMetadata?: {
key: string;
value: string;
}[];
}
/**
* Complete light mint structure (raw format)
*/
interface CompressedMint {
base: BaseMint;
mintContext: MintContext;
/** Reserved bytes for T22 layout compatibility */
reserved: Uint8Array;
/** Account type discriminator (1 = Mint) */
accountType: number;
/** Compression info embedded in mint */
compression: CompressionInfo;
extensions: MintExtension[] | null;
}
/**
* Rent configuration for compressible accounts
*/
interface RentConfig {
/** Base rent constant per epoch */
baseRent: number;
/** Compression cost in lamports */
compressionCost: number;
/** Lamports per byte per epoch */
lamportsPerBytePerEpoch: number;
/** Maximum epochs that can be pre-funded */
maxFundedEpochs: number;
/** Maximum lamports for top-up operation */
maxTopUp: number;
}
/**
* Compression info embedded in light mint
*/
interface CompressionInfo {
/** Config account version (0 = uninitialized) */
configAccountVersion: number;
/** Whether to compress to pubkey instead of owner */
compressToPubkey: number;
/** Account version for hashing scheme */
accountVersion: number;
/** Lamports to top up per write */
lamportsPerWrite: number;
/** Authority that can compress the account */
compressionAuthority: PublicKey;
/** Recipient for rent on closure */
rentSponsor: PublicKey;
/** Last slot rent was claimed */
lastClaimedSlot: bigint;
/** Rent exemption lamports paid at account creation */
rentExemptionPaid: number;
/** Reserved for future use */
reserved: number;
/** Rent configuration */
rentConfig: RentConfig;
}
/**
* Deserialize a light mint from buffer
* Uses SPL's MintLayout for BaseMint and buffer-layout struct for context
*
* @param data - The raw account data buffer
* @returns The deserialized light mint
*/
declare function deserializeMint(data: Buffer$1 | Uint8Array): CompressedMint;
/**
* Serialize a light mint to buffer
* Uses SPL's MintLayout for BaseMint, helper functions for context/metadata
*
* @param mint - The light mint to serialize
* @returns The serialized buffer
*/
declare function serializeMint(mint: CompressedMint): Buffer$1;
/**
* Extension type constants
*/
declare enum ExtensionType {
TokenMetadata = 19
}
/**
* Decode TokenMetadata from raw extension data using Borsh layout
* Extension format: updateAuthority (32) + mint (32) + name (Vec) + symbol (Vec) + uri (Vec) + additional (Vec)
*/
declare function decodeTokenMetadata(data: Uint8Array): TokenMetadata | null;
/**
* Encode TokenMetadata to raw bytes using Borsh layout
* @param metadata - TokenMetadata to encode
* @returns Encoded buffer
*/
declare function encodeTokenMetadata(metadata: TokenMetadata): Buffer$1;
/**
* Extract and parse TokenMetadata from extensions array
* @param extensions - Array of raw extensions
* @returns Parsed TokenMetadata or null if not found
*/
declare function extractTokenMetadata(extensions: MintExtension[] | null): TokenMetadata | null;
/**
* Metadata portion of MintInstructionData
* Used for instruction encoding when metadata extension is present
*/
interface MintMetadataField {
updateAuthority: PublicKey | null;
name: string;
symbol: string;
uri: string;
}
/**
* Flattened mint data structure for instruction encoding
* This is the format expected by mint action instructions
*/
interface MintInstructionData {
supply: bigint;
decimals: number;
mintAuthority: PublicKey | null;
freezeAuthority: PublicKey | null;
splMint: PublicKey;
cmintDecompressed: boolean;
version: number;
/** Signer pubkey used to derive the mint PDA */
mintSigner: Uint8Array;
/** Bump seed for the mint PDA */
bump: number;
metadata?: MintMetadataField;
}
interface MintInterface {
mint: Mint;
programId: PublicKey;
merkleContext?: MerkleContext;
mintContext?: MintContext;
tokenMetadata?: TokenMetadata;
extensions?: MintExtension[];
/** Compression info for light-token mints */
compression?: CompressionInfo;
}
/**
* Get unified mint info for SPL/T22/light-token mints.
*
* @param rpc RPC connection
* @param address The mint address
* @param commitment Optional commitment level
* @param programId Token program ID. If not provided, tries all programs to
* auto-detect.
* @returns Object with mint, optional merkleContext, mintContext, and
* tokenMetadata
*/
declare function getMintInterface(rpc: Rpc, address: PublicKey, commitment?: Commitment, programId?: PublicKey): Promise;
/**
* Unpack mint info from raw account data for SPL/T22/light-token.
*
* @param address The mint pubkey
* @param data The raw account data or AccountInfo
* @param programId Token program ID. Default light-token.
* @returns Object with mint, optional mintContext and tokenMetadata.
*/
declare function unpackMintInterface(address: PublicKey, data: Buffer$1 | Uint8Array | AccountInfo, programId?: PublicKey): Omit;
/**
* Unpack light-token mint context and metadata from raw account data
*
* @param data The raw account data
* @returns Object with mintContext, tokenMetadata, and extensions
*/
declare function unpackMintData(data: Buffer$1 | Uint8Array): {
mintContext: MintContext;
tokenMetadata?: TokenMetadata;
extensions?: MintExtension[];
};
/**
* Create instruction for updating a light mint's mint authority.
* Works for both compressed and decompressed light mints.
*
* @param mintInterface MintInterface from getMintInterface() - must have merkleContext
* @param currentMintAuthority Current mint authority public key (must sign)
* @param newMintAuthority New mint authority (or null to revoke)
* @param payer Fee payer public key
* @param validityProof Validity proof for the compressed light mint (null for decompressed light mints)
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
*/
declare function createUpdateMintAuthorityInstruction(mintInterface: MintInterface, currentMintAuthority: PublicKey, newMintAuthority: PublicKey | null, payer: PublicKey, validityProof: ValidityProofWithContext | null, maxTopUp?: number): TransactionInstruction;
/**
* Create instruction for updating a light mint's freeze authority.
* Works for both compressed and decompressed light mints.
*
* Output queue is automatically derived from mintInterface.merkleContext.treeInfo
* (preferring nextTreeInfo.queue if available for rollover support).
*
* @param mintInterface MintInterface from getMintInterface() - must have merkleContext
* @param currentFreezeAuthority Current freeze authority public key (must sign)
* @param newFreezeAuthority New freeze authority (or null to revoke)
* @param payer Fee payer public key
* @param validityProof Validity proof for the compressed light mint (null for decompressed light mints)
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
*/
declare function createUpdateFreezeAuthorityInstruction(mintInterface: MintInterface, currentFreezeAuthority: PublicKey, newFreezeAuthority: PublicKey | null, payer: PublicKey, validityProof: ValidityProofWithContext | null, maxTopUp?: number): TransactionInstruction;
/**
* Create instruction for updating a light mint's metadata field.
*
* Output queue is automatically derived from mintInterface.merkleContext.treeInfo
* (preferring nextTreeInfo.queue if available for rollover support).
*
* @param mintInterface MintInterface from getMintInterface() - must have merkleContext and tokenMetadata
* @param authority Metadata update authority public key (must sign)
* @param payer Fee payer public key
* @param validityProof Validity proof for the light mint (null for decompressed light mints)
* @param fieldType Field to update: 'name', 'symbol', 'uri', or 'custom'
* @param value New value for the field
* @param customKey Custom key name (required if fieldType is 'custom')
* @param extensionIndex Extension index (default: 0)
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
*/
declare function createUpdateMetadataFieldInstruction(mintInterface: MintInterface, authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext | null, fieldType: 'name' | 'symbol' | 'uri' | 'custom', value: string, customKey?: string, extensionIndex?: number, maxTopUp?: number): TransactionInstruction;
/**
* Create instruction for updating a light mint's metadata authority.
*
* Output queue is automatically derived from mintInterface.merkleContext.treeInfo
* (preferring nextTreeInfo.queue if available for rollover support).
*
* @param mintInterface MintInterface from getMintInterface() - must have merkleContext and tokenMetadata
* @param currentAuthority Current metadata update authority public key (must sign)
* @param newAuthority New metadata update authority public key
* @param payer Fee payer public key
* @param validityProof Validity proof for the light mint (null for decompressed light mints)
* @param extensionIndex Extension index (default: 0)
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
*/
declare function createUpdateMetadataAuthorityInstruction(mintInterface: MintInterface, currentAuthority: PublicKey, newAuthority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext | null, extensionIndex?: number, maxTopUp?: number): TransactionInstruction;
/**
* Create instruction for removing a metadata key from a light mint.
*
* Output queue is automatically derived from mintInterface.merkleContext.treeInfo
* (preferring nextTreeInfo.queue if available for rollover support).
*
* @param mintInterface MintInterface from getMintInterface() - must have merkleContext and tokenMetadata
* @param authority Metadata update authority public key (must sign)
* @param payer Fee payer public key
* @param validityProof Validity proof for the light mint (null for decompressed light mints)
* @param key Metadata key to remove
* @param idempotent If true, don't error if key doesn't exist (default: false)
* @param extensionIndex Extension index (default: 0)
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
*/
declare function createRemoveMetadataKeyInstruction(mintInterface: MintInterface, authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext | null, key: string, idempotent?: boolean, extensionIndex?: number, maxTopUp?: number): TransactionInstruction;
interface CompressToPubkey {
bump: number;
programId: number[];
seeds: number[][];
}
interface CompressibleConfig {
tokenAccountVersion: number;
rentPayment: number;
compressionOnly: number;
writeTopUp: number;
compressToAccountPubkey?: CompressToPubkey | null;
}
interface CreateAssociatedLightTokenAccountParams {
compressibleConfig?: CompressibleConfig | null;
}
/**
* Default compressible config for light-token ATAs - matches Rust SDK defaults.
*
* - tokenAccountVersion: 3 (ShaFlat) - latest hashing scheme
* - rentPayment: 16 - prepay 16 epochs (~24 hours rent)
* - compressionOnly: 1 - required for ATAs
* - writeTopUp: 766 - per-write top-up (~2 epochs rent) when rent < 2 epochs
* - compressToAccountPubkey: null - required for ATAs
*
* Cost breakdown at associated token account creation:
* - Rent sponsor PDA (LIGHT_TOKEN_RENT_SPONSOR) pays: rent exemption (~890,880 lamports)
* - Fee payer pays: compression_cost (11K) + 16 epochs rent (~6,400) = ~17,400 lamports + tx fees
*
* Per-write top-up (transfers):
* - When account rent is below 2 epochs, fee payer pays 766 lamports top-up
* - This keeps the account perpetually funded when actively used
*
* Rent calculation (272-byte compressible lightToken account):
* - rent_per_epoch = base_rent (128) + bytes * rent_per_byte (272 * 1) = 400 lamports
* - 16 epochs = 16 * 400 = 6,400 lamports (24 hours)
* - 2 epochs = 2 * 400 = 800 lamports (~3 hours, writeTopUp = 766 is conservative)
*
* Account size breakdown (272 bytes):
* - 165 bytes: SPL token base layout
* - 1 byte: account_type discriminator
* - 1 byte: Option discriminator for extensions
* - 4 bytes: Vec length prefix
* - 1 byte: extension type discriminant
* - 4 bytes: CompressibleExtension header (decimals_option, decimals, compression_only, is_ata)
* - 96 bytes: CompressionInfo struct
*/
declare const DEFAULT_COMPRESSIBLE_CONFIG: CompressibleConfig;
/**
* Create instruction for creating an associated light-token account.
* Uses the default rent sponsor PDA by default.
*
* @param feePayer Fee payer public key.
* @param owner Owner of the associated token account.
* @param mint Mint address.
* @param compressibleConfig Compressible configuration (defaults to rent sponsor config).
* @param configAccount Config account (defaults to LIGHT_TOKEN_CONFIG).
* @param rentPayerPda Rent payer PDA (defaults to LIGHT_TOKEN_RENT_SPONSOR).
*/
declare function createAssociatedLightTokenAccountInstruction(feePayer: PublicKey, owner: PublicKey, mint: PublicKey, compressibleConfig?: CompressibleConfig | null, configAccount?: PublicKey, rentPayerPda?: PublicKey): TransactionInstruction;
/**
* Create idempotent instruction for creating an associated light-token account.
* Uses the default rent sponsor PDA by default.
*
* @param feePayer Fee payer public key.
* @param owner Owner of the associated token account.
* @param mint Mint address.
* @param compressibleConfig Compressible configuration (defaults to rent sponsor config).
* @param configAccount Config account (defaults to LIGHT_TOKEN_CONFIG).
* @param rentPayerPda Rent payer PDA (defaults to LIGHT_TOKEN_RENT_SPONSOR).
*/
declare function createAssociatedLightTokenAccountIdempotentInstruction(feePayer: PublicKey, owner: PublicKey, mint: PublicKey, compressibleConfig?: CompressibleConfig | null, configAccount?: PublicKey, rentPayerPda?: PublicKey): TransactionInstruction;
/**
* light-token-specific config for createAssociatedTokenAccountInterfaceInstruction
*/
interface LightTokenConfig {
compressibleConfig?: CompressibleConfig | null;
configAccount?: PublicKey;
rentPayerPda?: PublicKey;
}
/**
* Create instruction for creating an associated token account (SPL, Token-2022,
* or light-token). Follows SPL Token API signature with optional light-token config at the
* end.
*
* @param payer Fee payer public key.
* @param associatedToken Associated token account address.
* @param owner Owner of the associated token account.
* @param mint Mint address.
* @param programId Token program ID (default: TOKEN_PROGRAM_ID).
* @param associatedTokenProgramId Associated token program ID.
* @param lightTokenConfig Optional light-token-specific configuration.
*/
declare function createAssociatedTokenAccountInterfaceInstruction(payer: PublicKey, associatedToken: PublicKey, owner: PublicKey, mint: PublicKey, programId?: PublicKey, associatedTokenProgramId?: PublicKey, lightTokenConfig?: LightTokenConfig): TransactionInstruction;
/**
* Create idempotent instruction for creating an associated token account (SPL,
* Token-2022, or light-token). Follows SPL Token API signature with optional light-token
* config at the end.
*
* @param payer Fee payer public key.
* @param associatedToken Associated token account address.
* @param owner Owner of the associated token account.
* @param mint Mint address.
* @param programId Token program ID (default: TOKEN_PROGRAM_ID).
* @param associatedTokenProgramId Associated token program ID.
* @param lightTokenConfig Optional light-token-specific configuration.
*/
declare function createAssociatedTokenAccountInterfaceIdempotentInstruction(payer: PublicKey, associatedToken: PublicKey, owner: PublicKey, mint: PublicKey, programId?: PublicKey, associatedTokenProgramId?: PublicKey, lightTokenConfig?: LightTokenConfig): TransactionInstruction;
/**
* Short alias for createAssociatedTokenAccountInterfaceIdempotentInstruction.
*/
declare const createAtaInterfaceIdempotentInstruction: typeof createAssociatedTokenAccountInterfaceIdempotentInstruction;
declare function sliceLast(items: T[]): {
rest: T[];
last: T;
};
/**
* Create a light-token transfer instruction.
*
* For light-token accounts with compressible extension, the program needs
* system_program and fee_payer to handle rent top-ups.
*
* @param source Source light-token account
* @param destination Destination light-token account
* @param owner Owner of the source account (signer, also pays for compressible extension top-ups)
* @param amount Amount to transfer
* @param feePayer Optional fee payer for top-ups (defaults to owner)
* @returns Transaction instruction for light-token transfer
*/
declare function createLightTokenTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, feePayer?: PublicKey): TransactionInstruction;
/**
* Create a light-token transfer_checked instruction. Same semantics as SPL
* TransferChecked.
*/
declare function createLightTokenTransferCheckedInstruction(source: PublicKey, destination: PublicKey, mint: PublicKey, owner: PublicKey, amount: number | bigint, decimals: number, payer: PublicKey): TransactionInstruction;
interface InterfaceOptions {
splInterfaceInfos?: SplInterfaceInfo[];
wrap?: boolean;
/**
* Delegate authority pubkey. For owner-signed flows, omit this field.
*/
delegatePubkey?: PublicKey;
}
/**
* Parameters for creating a MintTo instruction.
*/
interface CreateMintToInstructionParams {
/** Light mint account (decompressed from compressed light mint) */
mint: PublicKey;
/** Destination light-token account to mint to */
destination: PublicKey;
/** Amount of tokens to mint */
amount: number | bigint;
/** Mint authority (must be signer) */
authority: PublicKey;
/** Maximum lamports for rent and top-up combined. Transaction fails if exceeded. (u16::MAX = no limit, 0 = no top-ups allowed) */
maxTopUp?: number;
/** Optional fee payer for rent top-ups. If not provided, authority pays. */
feePayer?: PublicKey;
}
/**
* Create instruction for minting tokens to a light-token account.
*
* This is a simple 3-4 account instruction for minting to light-token associated token accounts (hot).
* Uses discriminator 7 (LightTokenMintTo).
*
* @param params - Mint instruction parameters
* @returns TransactionInstruction for minting tokens
*/
declare function createMintToInstruction(params: CreateMintToInstructionParams): TransactionInstruction;
/** Default compressible config PDA (V1) */
declare const LIGHT_TOKEN_CONFIG: PublicKey;
/** Default rent sponsor PDA (V1) */
declare const LIGHT_TOKEN_RENT_SPONSOR: PublicKey;
/**
* Token data version enum - mirrors Rust TokenDataVersion
* Used for compressed token account hashing strategy
*/
declare enum TokenDataVersion {
/** V1: Poseidon hash with little-endian amount, discriminator [2,0,0,0,0,0,0,0] */
V1 = 1,
/** V2: Poseidon hash with big-endian amount, discriminator [0,0,0,0,0,0,0,3] */
V2 = 2,
/** ShaFlat: SHA256 hash of borsh-serialized data, discriminator [0,0,0,0,0,0,0,4] */
ShaFlat = 3
}
declare const POOL_SEED: Buffer$1;
declare const CPI_AUTHORITY_SEED: Buffer$1;
declare const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;
declare const CREATE_TOKEN_POOL_DISCRIMINATOR: Buffer$1;
declare const MINT_TO_DISCRIMINATOR: Buffer$1;
declare const BATCH_COMPRESS_DISCRIMINATOR: Buffer$1;
declare const TRANSFER_DISCRIMINATOR: Buffer$1;
declare const COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR: Buffer$1;
declare const APPROVE_DISCRIMINATOR: Buffer$1;
declare const REVOKE_DISCRIMINATOR: Buffer$1;
declare const ADD_TOKEN_POOL_DISCRIMINATOR: Buffer$1;
/**
* Maximum lamports for rent top-up in a single instruction.
* u16::MAX = no limit; 0 = no top-ups allowed.
* Matches Rust SDK (e.g. token-sdk create_mints uses u16::MAX for "no limit").
*/
declare const MAX_TOP_UP = 65535;
/**
* Rent configuration constants for compressible light token accounts.
* These match the Rust SDK defaults in program-libs/compressible/src/rent/config.rs
*/
/** Base rent per epoch (lamports) */
declare const BASE_RENT_PER_EPOCH = 128;
/** Rent per byte per epoch (lamports) */
declare const RENT_PER_BYTE_PER_EPOCH = 1;
/** Slots per rent epoch (1.5 hours) */
declare const SLOTS_PER_RENT_EPOCH = 13500;
/** Compression cost (lamports) - paid at account creation */
declare const COMPRESSION_COST = 10000;
/** Compression incentive (lamports) - paid at account creation */
declare const COMPRESSION_INCENTIVE = 1000;
/** Total compression cost (COMPRESSION_COST + COMPRESSION_INCENTIVE) */
declare const TOTAL_COMPRESSION_COST: number;
/**
* Compressible light token account size in bytes.
* = 165 (base SPL token) + 1 (account_type) + 1 (Option) + 4 (Vec len) + 1 (ext disc) + 4 (ext header) + 96 (CompressionInfo) = 272
* Source: program-libs/token-interface/src/state/token/top_up.rs MIN_SIZE_WITH_COMPRESSIBLE
*/
declare const COMPRESSIBLE_LIGHT_TOKEN_ACCOUNT_SIZE = 272;
/**
* Calculate rent per epoch for a given account size.
* Formula: base_rent + (bytes * lamports_per_byte_per_epoch)
*/
declare function rentPerEpoch(bytes: number): number;
/**
* Default rent per epoch for a compressible light token account (272 bytes).
* = 128 + 272 = 400 lamports
*/
declare const COMPRESSIBLE_LIGHT_TOKEN_RENT_PER_EPOCH: number;
/** Default prepaid epochs (24 hours = 16 epochs * 1.5h) */
declare const DEFAULT_PREPAY_EPOCHS = 16;
/** Default write top-up (lamports) - ~2 epochs rent */
declare const DEFAULT_WRITE_TOP_UP = 766;
/**
* Calculate fee payer cost at ATA creation.
* = compression_cost (11K) + (prepay_epochs * rent_per_epoch)
*/
declare function calculateFeePayerCostAtCreation(prepayEpochs?: number, accountBytes?: number): number;
/**
* Create instruction for minting tokens from a light mint to compressed accounts.
* To mint to light-token associated token accounts across SPL/T22/light mints, use
* {@link createMintToInterfaceInstruction} instead.
*
* @param authority Mint authority public key.
* @param payer Fee payer public key.
* @param validityProof Validity proof for the light mint.
* @param merkleContext Merkle context of the light mint.
* @param mintData Mint instruction data.
* @param recipients Array of recipients with amounts.
* @param outputStateTreeInfo Optional output state tree info. Uses merkle
* context queue if not provided.
* @param tokenAccountVersion Token account version (default:
* TokenDataVersion.ShaFlat).
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
*/
declare function createMintToCompressedInstruction(authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, merkleContext: MerkleContext, mintData: MintInstructionData, recipients: Array<{
recipient: PublicKey;
amount: number | bigint;
}>, outputStateTreeInfo?: TreeInfo, tokenAccountVersion?: TokenDataVersion, maxTopUp?: number): TransactionInstruction;
/**
* Create mint-to instruction for SPL, Token-2022, or light-token mints.
* This instruction ONLY mints to light-token associated token accounts (hot).
*
* For light-token mints, the light mint account must exist (mint must be decompressed first).
*
* @param mintInterface Mint interface (SPL, Token-2022, or light-token).
* @param destination Destination onchain token account address.
* @param authority Mint authority public key.
* @param payer Fee payer public key.
* @param amount Amount to mint.
* @param validityProof Not used (legacy parameter, kept for compatibility).
* @param multiSigners Multi-signature signer public keys (SPL/T22 only).
*/
declare function createMintToInterfaceInstruction(mintInterface: MintInterface, destination: PublicKey, authority: PublicKey, payer: PublicKey, amount: number | bigint, validityProof?: ValidityProofWithContext, multiSigners?: PublicKey[]): TransactionInstruction;
/**
* Create a wrap instruction that moves tokens from an SPL/T22 account to a
* light-token account.
*
* @param source Source SPL/T22 token account
* @param destination Destination light-token account
* @param owner Owner of the source account (signer)
* @param mint Mint address
* @param amount Amount to wrap,
* @param splInterfaceInfo SPL interface info for the compression
* @param decimals Mint decimals (required for transfer_checked)
* @param payer Fee payer (defaults to owner)
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
* @returns Instruction to wrap tokens
*/
declare function createWrapInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, mint: PublicKey, amount: bigint, splInterfaceInfo: SplInterfaceInfo, decimals: number, payer?: PublicKey, maxTopUp?: number): TransactionInstruction;
/**
* Create an unwrap instruction that moves tokens from a light-token account to an
* SPL/T22 account.
*
* @param source Source light-token account
* @param destination Destination SPL/T22 token account
* @param owner Owner of the source account (signer)
* @param mint Mint address
* @param amount Amount to unwrap,
* @param splInterfaceInfo SPL interface info for the decompression
* @param decimals Mint decimals (required for transfer_checked)
* @param payer Fee payer (defaults to owner if not provided)
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
* @returns TransactionInstruction to unwrap tokens
*/
declare function createUnwrapInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, mint: PublicKey, amount: bigint, splInterfaceInfo: SplInterfaceInfo, decimals: number, payer?: PublicKey, maxTopUp?: number): TransactionInstruction;
/**
* Create an instruction to freeze a decompressed light-token account.
*
* Freezing sets the account state to AccountState::Frozen, preventing
* transfers and other token operations. Only the mint's freeze_authority
* can freeze accounts.
*
* Account order per program:
* 0. token_account (mutable) - the light-token account to freeze
* 1. mint (readonly) - the mint associated with the token account
* 2. freeze_authority - must match mint.freeze_authority (signer)
*
* @param tokenAccount The light-token account to freeze (must be Initialized)
* @param mint The mint of the light-token account
* @param freezeAuthority The freeze authority of the mint (signer)
* @returns TransactionInstruction
*/
declare function createLightTokenFreezeAccountInstruction(tokenAccount: PublicKey, mint: PublicKey, freezeAuthority: PublicKey): TransactionInstruction;
/**
* Create an instruction to thaw (unfreeze) a frozen light-token account.
*
* Thawing restores the account state from AccountState::Frozen to
* AccountState::Initialized, re-enabling token operations. Only the
* mint's freeze_authority can thaw accounts.
*
* Account order per program:
* 0. token_account (mutable) - the frozen light-token account to thaw
* 1. mint (readonly) - the mint associated with the token account
* 2. freeze_authority - must match mint.freeze_authority (signer)
*
* @param tokenAccount The frozen light-token account to thaw
* @param mint The mint of the light-token account
* @param freezeAuthority The freeze authority of the mint (signer)
* @returns TransactionInstruction
*/
declare function createLightTokenThawAccountInstruction(tokenAccount: PublicKey, mint: PublicKey, freezeAuthority: PublicKey): TransactionInstruction;
/**
* Create an instruction to approve a delegate for a light-token account.
*
* Account order per program:
* 0. token_account (mutable) - the light-token account
* 1. delegate (readonly) - the delegate to approve
* 2. owner (signer) - owner of the token account
* 3. system_program (readonly) - for rent top-ups via CPI
* 4. fee_payer (mutable, signer) - pays for rent top-ups
*
* @param tokenAccount The light-token account to set delegation on
* @param delegate The delegate to approve
* @param owner Owner of the token account (signer)
* @param amount Amount of tokens to delegate
* @param feePayer Optional fee payer for rent top-ups (defaults to owner)
* @returns TransactionInstruction
*/
declare function createLightTokenApproveInstruction(tokenAccount: PublicKey, delegate: PublicKey, owner: PublicKey, amount: number | bigint, feePayer?: PublicKey): TransactionInstruction;
/**
* Create an instruction to revoke delegation for a light-token account.
*
* Account order per program:
* 0. token_account (mutable) - the light-token account
* 1. owner (signer) - owner of the token account
* 2. system_program (readonly) - for rent top-ups via CPI
* 3. fee_payer (mutable, signer) - pays for rent top-ups
*
* @param tokenAccount The light-token account to revoke delegation on
* @param owner Owner of the token account (signer)
* @param feePayer Optional fee payer for rent top-ups (defaults to owner)
* @returns TransactionInstruction
*/
declare function createLightTokenRevokeInstruction(tokenAccount: PublicKey, owner: PublicKey, feePayer?: PublicKey): TransactionInstruction;
/**
* Create and initialize a new mint for SPL/T22/light-token.
*
* @param rpc RPC connection to use
* @param payer Fee payer
* @param mintAuthority Account that will control minting (signer for light-token mints)
* @param freezeAuthority Account that will control freeze and thaw (optional)
* @param decimals Location of the decimal place
* @param keypair Mint keypair (defaults to a random keypair)
* @param confirmOptions Confirm options
* @param programId Token program ID (defaults to LIGHT_TOKEN_PROGRAM_ID)
* @param tokenMetadata Optional token metadata (light-token mints only)
* @param outputStateTreeInfo Optional output state tree info (light-token mints only)
* @param addressTreeInfo Optional address tree info (light-token mints only)
*
* @returns Object with mint address and transaction signature
*/
declare function createMintInterface(rpc: Rpc, payer: Signer, mintAuthority: PublicKey | Signer, freezeAuthority: PublicKey | Signer | null, decimals: number, keypair?: Keypair, confirmOptions?: ConfirmOptions, programId?: PublicKey, tokenMetadata?: TokenMetadataInstructionData, outputStateTreeInfo?: TreeInfo, addressTreeInfo?: AddressTreeInfo): Promise<{
mint: PublicKey;
transactionSignature: TransactionSignature;
}>;
/**
* Update the mint authority of a light-token mint.
* Works for both compressed and decompressed light mints.
*
* @param rpc RPC connection
* @param payer Fee payer (signer)
* @param mint Mint address
* @param currentMintAuthority Current mint authority (signer)
* @param newMintAuthority New mint authority (or null to revoke)
* @param confirmOptions Optional confirm options
*/
declare function updateMintAuthority(rpc: Rpc, payer: Signer, mint: PublicKey, currentMintAuthority: Signer, newMintAuthority: PublicKey | null, confirmOptions?: ConfirmOptions): Promise;
/**
* Update the freeze authority of a light-token mint.
* Works for both compressed and decompressed light mints.
*
* @param rpc RPC connection
* @param payer Fee payer (signer)
* @param mint Mint address
* @param currentFreezeAuthority Current freeze authority (signer)
* @param newFreezeAuthority New freeze authority (or null to revoke)
* @param confirmOptions Optional confirm options
*/
declare function updateFreezeAuthority(rpc: Rpc, payer: Signer, mint: PublicKey, currentFreezeAuthority: Signer, newFreezeAuthority: PublicKey | null, confirmOptions?: ConfirmOptions): Promise;
/**
* Update a metadata field on a light-token mint.
* Works for both compressed and decompressed light mints.
*
* @param rpc RPC connection
* @param payer Fee payer (signer)
* @param mint Mint address
* @param authority Metadata update authority (signer)
* @param fieldType Field to update: 'name', 'symbol', 'uri', or 'custom'
* @param value New value for the field
* @param customKey Custom key name (required if fieldType is 'custom')
* @param extensionIndex Extension index (default: 0)
* @param confirmOptions Optional confirm options
*/
declare function updateMetadataField(rpc: Rpc, payer: Signer, mint: PublicKey, authority: Signer, fieldType: 'name' | 'symbol' | 'uri' | 'custom', value: string, customKey?: string, extensionIndex?: number, confirmOptions?: ConfirmOptions): Promise;
/**
* Update the metadata authority of a light-token mint.
* Works for both compressed and decompressed light mints.
*
* @param rpc RPC connection
* @param payer Fee payer (signer)
* @param mint Mint address
* @param currentAuthority Current metadata update authority (signer)
* @param newAuthority New metadata update authority
* @param extensionIndex Extension index (default: 0)
* @param confirmOptions Optional confirm options
*/
declare function updateMetadataAuthority(rpc: Rpc, payer: Signer, mint: PublicKey, currentAuthority: Signer, newAuthority: PublicKey, extensionIndex?: number, confirmOptions?: ConfirmOptions): Promise;
/**
* Remove a metadata key from a light-token mint.
* Works for both compressed and decompressed light mints.
*
* @param rpc RPC connection
* @param payer Fee payer (signer)
* @param mint Mint address
* @param authority Metadata update authority (signer)
* @param key Metadata key to remove
* @param idempotent If true, don't error if key doesn't exist (default: false)
* @param extensionIndex Extension index (default: 0)
* @param confirmOptions Optional confirm options
*/
declare function removeMetadataKey(rpc: Rpc, payer: Signer, mint: PublicKey, authority: Signer, key: string, idempotent?: boolean, extensionIndex?: number, confirmOptions?: ConfirmOptions): Promise;
/**
* Create an associated token account for SPL/T22/light-token. Defaults to
* light-token program.
*
* @param rpc RPC connection
* @param payer Fee payer and transaction signer
* @param mint Mint address
* @param owner Owner of the associated token account
* @param allowOwnerOffCurve Allow owner to be a PDA (default: false)
* @param confirmOptions Options for confirming the transaction
* @param programId Token program ID (default:
* LIGHT_TOKEN_PROGRAM_ID)
* @param associatedTokenProgramId associated token account program ID
* (auto-derived if not provided)
* @param lightTokenConfig Optional rent config
* @returns Address of the new associated token account
*/
declare function createAtaInterface(rpc: Rpc, payer: Signer, mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, confirmOptions?: ConfirmOptions, programId?: PublicKey, associatedTokenProgramId?: PublicKey, lightTokenConfig?: LightTokenConfig): Promise;
/**
* Create an associated token account idempotently for SPL/T22/light-token.
* Defaults to light-token program.
*
* If the account already exists, the instruction succeeds without error.
*
* @param rpc RPC connection
* @param payer Fee payer and transaction signer
* @param mint Mint address
* @param owner Owner of the associated token account
* @param allowOwnerOffCurve Allow owner to be a PDA (default: false)
* @param confirmOptions Options for confirming the transaction
* @param programId Token program ID (default:
* LIGHT_TOKEN_PROGRAM_ID)
* @param associatedTokenProgramId associated token account program ID
* (auto-derived if not provided)
* @param lightTokenConfig Optional light-token-specific configuration
*
* @returns Address of the associated token account
*/
declare function createAtaInterfaceIdempotent(rpc: Rpc, payer: Signer, mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, confirmOptions?: ConfirmOptions, programId?: PublicKey, associatedTokenProgramId?: PublicKey, lightTokenConfig?: LightTokenConfig): Promise;
/**
* Mint tokens to a light-token account.
*
* This is a simple mint instruction for minting to light-token associated token accounts (hot).
* The light mint account must exist (mint must be decompressed first).
*
* @param rpc - RPC connection
* @param payer - Fee payer (signer)
* @param mint - Mint address (light mint account)
* @param destination - Destination light-token account
* @param authority - Mint authority (signer)
* @param amount - Amount to mint
* @param maxTopUp - Optional maximum lamports for rent top-up
* @param confirmOptions - Optional confirm options
* @returns Transaction signature
*/
declare function mintTo$1(rpc: Rpc, payer: Signer, mint: PublicKey, destination: PublicKey, authority: Signer, amount: number | bigint, maxTopUp?: number, confirmOptions?: ConfirmOptions): Promise;
/**
* Mint light-tokens directly to compressed accounts.
*
* @param rpc RPC connection
* @param payer Fee payer
* @param mint Mint address
* @param authority Mint authority (must sign)
* @param recipients Array of recipients with amounts
* @param outputStateTreeInfo Optional output state tree info (auto-fetched if not provided)
* @param tokenAccountVersion Token account version (default: 3)
* @param maxTopUp Optional: cap on rent top-up (units of 1k lamports; default no cap)
* @param confirmOptions Optional confirm options
*/
declare function mintToCompressed(rpc: Rpc, payer: Signer, mint: PublicKey, authority: Signer, recipients: Array<{
recipient: PublicKey;
amount: number | bigint;
}>, outputStateTreeInfo?: TreeInfo, tokenAccountVersion?: number, maxTopUp?: number, confirmOptions?: ConfirmOptions): Promise;
/**
* Mint tokens to a decompressed/onchain token account.
* Works with SPL, Token-2022, and light-token mints.
*
* This function ONLY mints to light-token associated token accounts (hot), never to compressed light-token accounts (cold).
* For light-token mints, the light mint account must exist (mint must be decompressed first).
*
* The signature matches the standard SPL mintTo for simplicity and consistency.
*
* @param rpc - RPC connection to use
* @param payer - Transaction fee payer
* @param mint - Mint address (SPL, Token-2022, or light-token mint)
* @param destination - Destination token account address (must be an existing onchain token account)
* @param authority - Mint authority (can be Signer or PublicKey if multiSigners provided)
* @param amount - Amount to mint
* @param multiSigners - Optional: Multi-signature signers (default: [])
* @param confirmOptions - Optional: Transaction confirmation options
* @param programId - Optional: Token program ID. If undefined, auto-detects.
*
* @returns Transaction signature
*/
declare function mintToInterface(rpc: Rpc, payer: Signer, mint: PublicKey, destination: PublicKey, authority: Signer | PublicKey, amount: number | bigint, multiSigners?: Signer[], confirmOptions?: ConfirmOptions, programId?: PublicKey): Promise;
/**
* Wrap tokens from an SPL/T22 account to a light-token account.
*
* This is an agnostic action that takes explicit account addresses (spl-token style).
* Use getAssociatedTokenAddressSync() to derive associated token account addresses if needed.
*
* @param rpc RPC connection
* @param payer Fee payer
* @param source Source SPL/T22 token account (any token account, not just associated token account)
* @param destination Destination light-token account
* @param owner Owner/authority of the source account (must sign)
* @param mint Mint address
* @param amount Amount to wrap
* @param splInterfaceInfo Optional: SPL interface info (will be fetched if not provided)
* @param maxTopUp Optional: cap on rent top-up (units of 1k lamports; default no cap)
* @param confirmOptions Optional: Confirm options
*
* @example
* const splAta = getAssociatedTokenAddressSync(mint, owner.publicKey, false, TOKEN_PROGRAM_ID);
* const lightTokenAta = getAssociatedTokenAddressInterface(mint, owner.publicKey); // defaults to light-token
*
* await wrap(
* rpc,
* payer,
* splAta,
* lightTokenAta,
* owner,
* mint,
* 1000n,
* );
*
* @returns Transaction signature
*/
declare function wrap(rpc: Rpc, payer: Signer, source: PublicKey, destination: PublicKey, owner: Signer, mint: PublicKey, amount: bigint, splInterfaceInfo?: SplInterfaceInfo, maxTopUp?: number, confirmOptions?: ConfirmOptions): Promise;
/**
* Input for creating off-chain metadata JSON.
* Compatible with Token-2022 and Metaplex standards.
*/
interface OffChainTokenMetadata {
/** Token name */
name: string;
/** Token symbol */
symbol: string;
/** Optional description */
description?: string;
/** Optional image URI */
image?: string;
/** Optional additional metadata key-value pairs */
additionalMetadata?: Array<{
key: string;
value: string;
}>;
}
/**
* Off-chain JSON format for token metadata.
* Standard format compatible with Token-2022 and Metaplex tooling.
*/
interface OffChainTokenMetadataJson {
name: string;
symbol: string;
description?: string;
image?: string;
additionalMetadata?: Array<{
key: string;
value: string;
}>;
}
/**
* Format metadata for off-chain storage.
*
* Returns a plain object ready to be uploaded using any storage provider
* (umi uploader, custom IPFS/Arweave/S3 solution, etc.).
*
* @example
* // With umi uploader
* import { toOffChainMetadataJson } from '@lightprotocol/compressed-token';
* import { irysUploader } from '@metaplex-foundation/umi-uploader-irys';
*
* const umi = createUmi(connection).use(irysUploader());
* const metadataJson = toOffChainMetadataJson({
* name: 'My Token',
* symbol: 'MTK',
* description: 'A light-token',
* image: 'https://example.com/image.png',
* });
* const uri = await umi.uploader.uploadJson(metadataJson);
*
* // Then use uri with createMint
* await createMint(rpc, payer, { ...params, uri });
*/
declare function toOffChainMetadataJson(meta: OffChainTokenMetadata): OffChainTokenMetadataJson;
/**
* Returns the light mint address as bytes.
* @internal
*/
declare function deriveCMintAddress(mintSeed: PublicKey, addressTreeInfo: TreeInfo): number[];
declare const COMPRESSED_MINT_SEED: Buffer$1;
/**
* Finds the SPL mint PDA for a light-token mint.
* @param mintSeed The mint seed public key.
* @returns [PDA, bump]
* @internal
*/
declare function findMintAddress(mintSigner: PublicKey): [PublicKey, number];
/**
* Same as "getAssociatedTokenAddress" but returns the bump as well.
* Uses light-token program ID.
* @internal
*/
declare function getAssociatedLightTokenAddressAndBump(owner: PublicKey, mint: PublicKey): [PublicKey, number];
/**
* Same as "getAssociatedTokenAddress", returning just the associated token address.
* Uses light-token program ID.
* @internal
*/
declare function getAssociatedLightTokenAddress(owner: PublicKey, mint: PublicKey): PublicKey;
/**
* Approve a delegate to spend tokens
*
* @param rpc Rpc to use
* @param payer Fee payer
* @param mint SPL Mint address
* @param amount Number of tokens to delegate
* @param owner Owner of the SPL token account.
* @param delegate Address of the delegate
* @param confirmOptions Options for confirming the transaction
*
* @return Signature of the confirmed transaction
*/
declare function approve(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, delegate: PublicKey, confirmOptions?: ConfirmOptions): Promise;
/**
* Mint compressed tokens to a solana address from an external mint authority
*
* @param rpc Rpc to use
* @param payer Fee payer
* @param mint SPL Mint address
* @param toPubkey Address of the account to mint to
* @param authority Minting authority
* @param amount Amount to mint
* @param outputStateTreeInfo Optional: State tree account that the compressed
* tokens should be inserted into. Defaults to a
* shared state tree account.
* @param splInterfaceInfo Optional: SPL interface info.
* @param confirmOptions Options for confirming the transaction
*
* @return Signature of the confirmed transaction
*/
declare function approveAndMintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: PublicKey, authority: Signer, amount: number | BN, outputStateTreeInfo?: TreeInfo, splInterfaceInfo?: SplInterfaceInfo, confirmOptions?: ConfirmOptions): Promise;
/**
* Compress SPL tokens
*
* @param rpc Rpc connection to use
* @param payer Fee payer
* @param mint SPL Mint address
* @param amount Number of tokens to compress.
* @param owner Owner of the SPL token account.
* @param sourceTokenAccount Source SPL token account. (ATA)
* @param toAddress Recipient owner address.
* @param outputStateTreeInfo Optional: State tree account that the compressed
* tokens should be inserted into. Defaults to a
* shared state tree account.
* @param splInterfaceInfo Optional: SPL interface info.
* @param confirmOptions Options for confirming the transaction
*
* @return Signature of the confirmed transaction
*/
declare function compress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN | number[] | BN[], owner: Signer, sourceTokenAccount: PublicKey, toAddress: PublicKey | Array, outputStateTreeInfo?: TreeInfo, splInterfaceInfo?: SplInterfaceInfo, confirmOptions?: ConfirmOptions): Promise;
/**
* Compress SPL tokens into compressed token format
*
* @param rpc Rpc connection to use
* @param payer Fee payer
* @param mint SPL Mint address
* @param owner Owner of the token account
* @param tokenAccount Token account to compress
* @param remainingAmount Optional: amount to leave in token account.
* Default: 0
* @param outputStateTreeInfo Optional: State tree account that the compressed
* account into
* @param splInterfaceInfo Optional: SPL interface info.
* @param confirmOptions Options for confirming the transaction
*
* @return Signature of the confirmed transaction
*/
declare function compressSplTokenAccount(rpc: Rpc, payer: Signer, mint: PublicKey, owner: Signer, tokenAccount: PublicKey, remainingAmount?: BN, outputStateTreeInfo?: TreeInfo, splInterfaceInfo?: SplInterfaceInfo, confirmOptions?: ConfirmOptions): Promise;
/**
* Create and initialize a new SPL token mint
*
* @deprecated Use {@link createMintInterface} instead, which supports both SPL and compressed mints.
*
* @param rpc RPC connection to use
* @param payer Fee payer
* @param mintAuthority Account that will control minting
* @param decimals Location of the decimal place
* @param keypair Optional: Mint keypair. Defaults to a random
* keypair.
* @param confirmOptions Options for confirming the transaction
* @param tokenProgramId Optional: Program ID for the token. Defaults to
* TOKEN_PROGRAM_ID.
* @param freezeAuthority Optional: Account that will control freeze and thaw.
*
* @return Object with mint address and transaction signature
*/
declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: PublicKey | Signer, decimals: number, keypair?: Keypair, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey | boolean, freezeAuthority?: PublicKey | Signer | null): Promise<{
mint: PublicKey;
transactionSignature: TransactionSignature;
}>;
/**
* Register an existing mint with the CompressedToken program
*
* @param rpc RPC connection to use
* @param payer Fee payer
* @param mint SPL Mint address
* @param confirmOptions Options for confirming the transaction
* @param tokenProgramId Optional: Address of the token program. Default:
* TOKEN_PROGRAM_ID
*
* @return transaction signature
*/
declare function createSplInterface(rpc: Rpc, payer: Signer, mint: PublicKey, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise;
/**
* @deprecated Use {@link createSplInterface} instead.
*/
declare const createTokenPool: typeof createSplInterface;
/**
* Create additional SPL interfaces for an existing mint
*
* @param rpc RPC connection to use
* @param payer Fee payer
* @param mint SPL Mint address
* @param numMaxAdditionalPools Number of additional SPL interfaces to create. Max
* 3.
* @param confirmOptions Optional: Options for confirming the transaction
* @param tokenProgramId Optional: Address of the token program. Default:
* TOKEN_PROGRAM_ID
*
* @return transaction signature
*/
declare function addSplInterfaces(rpc: Rpc, payer: Signer, mint: PublicKey, numMaxAdditionalPools: number, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise;
/**
* @deprecated Use {@link addSplInterfaces} instead.
*/
declare const addTokenPools: typeof addSplInterfaces;
/**
* Create a lookup table for the token program's default accounts
*
* @param rpc Rpc connection to use
* @param payer Fee payer
* @param authority Authority of the lookup table
* @param mints Optional array of mint public keys to include in
* the lookup table
* @param additionalAccounts Optional array of additional account public keys
* to include in the lookup table
*
* @return Object with transaction signatures and the address of the created
* lookup table
*/
declare function createTokenProgramLookupTable(rpc: Rpc, payer: Signer, authority: Signer, mints?: PublicKey[], additionalAccounts?: PublicKey[]): Promise<{
txIds: TransactionSignature[];
address: PublicKey;
}>;
/**
* Decompress compressed tokens
*
* @param rpc Rpc connection to use
* @param payer Fee payer
* @param mint SPL Mint address
* @param amount Number of tokens to transfer
* @param owner Owner of the compressed tokens
* @param toAddress Destination **uncompressed** token account
* address. (ATA)
* @param splInterfaceInfos Optional: SPL interface infos.
* @param confirmOptions Options for confirming the transaction
*
* @return confirmed transaction signature
*/
declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, splInterfaceInfos?: SplInterfaceInfo[], confirmOptions?: ConfirmOptions): Promise;
/**
* Merge multiple compressed token accounts for a given mint into fewer
* accounts. Each call merges up to 4 accounts at a time.
*
* Supports automatic V1 -> V2 migration: when running in V2 mode,
* merging V1 token accounts will produce a V2 output.
*
* IMPORTANT: Only accounts from the same tree type can be merged in one
* transaction. If you have mixed V1+V2 accounts, merge them separately.
*
* @param rpc RPC connection to use
* @param payer Fee payer
* @param mint SPL Mint address
* @param owner Owner of the token accounts to be merged
* @param confirmOptions Options for confirming the transaction
*
* @return confirmed transaction signature
*/
declare function mergeTokenAccounts(rpc: Rpc, payer: Signer, mint: PublicKey, owner: Signer, confirmOptions?: ConfirmOptions): Promise;
/**
* Mint compressed tokens to a solana address
*
* @param rpc Rpc connection to use
* @param payer Fee payer
* @param mint SPL Mint address
* @param toPubkey Address of the account to mint to. Can be an
* array of addresses if the amount is an array of
* amounts.
* @param authority Mint authority
* @param amount Amount to mint. Pass an array of amounts if the
* toPubkey is an array of addresses.
* @param outputStateTreeInfo Optional: State tree account that the compressed
* tokens should be part of. Defaults to the
* default state tree account.
* @param splInterfaceInfo Optional: SPL interface information
* @param confirmOptions Options for confirming the transaction
*
* @return Signature of the confirmed transaction
*/
declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: PublicKey | PublicKey[], authority: Signer, amount: number | BN | number[] | BN[], outputStateTreeInfo?: TreeInfo, splInterfaceInfo?: SplInterfaceInfo, confirmOptions?: ConfirmOptions): Promise;
/**
* Revoke one or more delegated token accounts
*
* @param rpc Rpc connection to use
* @param payer Fee payer
* @param accounts Delegated compressed token accounts to revoke
* (must all be from the same tree type)
* @param owner Owner of the compressed tokens
* @param confirmOptions Options for confirming the transaction
*
* @return Signature of the confirmed transaction
*/
declare function revoke(rpc: Rpc, payer: Signer, accounts: ParsedTokenAccount[], owner: Signer, confirmOptions?: ConfirmOptions): Promise;
/**
* Transfer compressed tokens from one owner to another.
*
* Supports automatic V1 -> V2 migration: when running in V2 mode,
* V1 token inputs will produce V2 token outputs.
*
* @param rpc Rpc connection to use
* @param payer Fee payer
* @param mint SPL Mint address
* @param amount Number of tokens to transfer
* @param owner Owner of the compressed tokens
* @param toAddress Destination address of the recipient
* @param confirmOptions Options for confirming the transaction
*
* @return confirmed transaction signature
*/
declare function transfer(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, confirmOptions?: ConfirmOptions): Promise;
/**
* Transfer delegated compressed tokens to another owner
*
* @param rpc Rpc connection to use
* @param payer Fee payer
* @param mint SPL Mint address
* @param amount Number of tokens to transfer
* @param owner Owner of the compressed tokens
* @param toAddress Destination address of the recipient
* @param confirmOptions Options for confirming the transaction
*
* @return confirmed transaction signature
*/
declare function transferDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, confirmOptions?: ConfirmOptions): Promise;
/**
* Decompress delegated compressed tokens. Remaining compressed tokens are
* returned to the owner without delegation.
*
* @param rpc Rpc connection to use
* @param payer Fee payer
* @param mint SPL Mint address
* @param amount Number of tokens to decompress
* @param owner Owner of the compressed tokens
* @param toAddress Destination **uncompressed** token account
* address. (ATA)
* @param splInterfaceInfos Optional: SPL interface infos.
* @param confirmOptions Options for confirming the transaction
*
* @return Signature of the confirmed transaction
*/
declare function decompressDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, splInterfaceInfos?: SplInterfaceInfo[], confirmOptions?: ConfirmOptions): Promise;
declare const ERROR_NO_ACCOUNTS_FOUND = "Could not find accounts to select for transfer.";
declare const ERROR_MIXED_TREE_TYPES = "Cannot select accounts from different tree types (V1/V2) in the same batch. Filter accounts by tree type first.";
/**
* Options for input account selection
*/
interface SelectInputAccountsOptions {
/**
* Filter accounts by tree type. If provided, only accounts in trees of
* this type will be selected. This prevents mixed V1/V2 batches which
* fail at proof generation.
*/
treeType?: TreeType;
}
/**
* Groups accounts by tree type for separate processing
*/
declare function groupAccountsByTreeType(accounts: ParsedTokenAccount[]): Map;
/**
* Result of selectAccountsByPreferredTreeType
*/
interface SelectedAccountsResult {
/** The selected accounts (all from the same tree type) */
accounts: ParsedTokenAccount[];
/** The tree type of the selected accounts */
treeType: TreeType;
/** Total balance of selected accounts */
totalBalance: BN;
}
/**
* Selects accounts by preferred tree type with automatic fallback.
*
* In V2 mode, prefers StateV2 accounts. Falls back to StateV1 if V2
* has insufficient balance.
*
* This ensures all returned accounts are from the same tree type,
* preventing mixed V1/V2 batch proof failures.
*
* @param accounts All available accounts (can be mixed V1/V2)
* @param requiredAmount Minimum amount needed (optional - if not provided, returns all from preferred type)
* @returns Selected accounts from a single tree type
*/
declare function selectAccountsByPreferredTreeType(accounts: ParsedTokenAccount[], requiredAmount?: BN): SelectedAccountsResult;
/**
* Selects token accounts for approval, first trying to find an exact match, then falling back to minimum selection.
*
* @param {ParsedTokenAccount[]} accounts - Token accounts to choose from.
* @param {BN} approveAmount - Amount to approve.
* @param {number} [maxInputs=4] - Max accounts to select when falling back to minimum selection.
* @param {SelectInputAccountsOptions} [options] - Optional selection options.
* @returns {[
* selectedAccounts: ParsedTokenAccount[],
* total: BN,
* totalLamports: BN | null,
* maxPossibleAmount: BN
* ]} - Returns:
* - selectedAccounts: Accounts chosen for approval.
* - total: Total amount from selected accounts.
* - totalLamports: Total lamports from selected accounts.
* - maxPossibleAmount: Max approvable amount given maxInputs.
*/
declare function selectTokenAccountsForApprove(accounts: ParsedTokenAccount[], approveAmount: BN, maxInputs?: number, options?: SelectInputAccountsOptions): [
selectedAccounts: ParsedTokenAccount[],
total: BN,
totalLamports: BN | null,
maxPossibleAmount: BN
];
/**
* Selects the minimum number of compressed token accounts required for a
* decompress instruction, up to a specified maximum.
*
* @param {ParsedTokenAccount[]} accounts Token accounts to choose from.
* @param {BN} amount Amount to decompress.
* @param {number} [maxInputs=4] Max accounts to select. Default
* is 4.
* @param {SelectInputAccountsOptions} [options] - Optional selection options.
*
* @returns Returns selected accounts and their totals.
*/
declare function selectMinCompressedTokenAccountsForDecompression(accounts: ParsedTokenAccount[], amount: BN, maxInputs?: number, options?: SelectInputAccountsOptions): {
selectedAccounts: ParsedTokenAccount[];
total: BN;
totalLamports: BN | null;
maxPossibleAmount: BN;
};
/**
* Selects the minimum number of compressed token accounts required for a
* transfer or decompression instruction, up to a specified maximum.
*
* @param {ParsedTokenAccount[]} accounts Token accounts to choose from.
* @param {BN} transferAmount Amount to transfer or decompress.
* @param {number} [maxInputs=4] Max accounts to select. Default
* is 4.
* @param {SelectInputAccountsOptions} [options] - Optional selection options.
* Use treeType to filter by V1/V2.
*
* @returns Returns selected accounts and their totals. [
* selectedAccounts: ParsedTokenAccount[],
* total: BN,
* totalLamports: BN | null,
* maxPossibleAmount: BN
* ]
*/
declare function selectMinCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number, options?: SelectInputAccountsOptions): [
selectedAccounts: ParsedTokenAccount[],
total: BN,
totalLamports: BN | null,
maxPossibleAmount: BN
];
/**
* Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,
* returns partial amounts if insufficient accounts are found instead of
* throwing an error.
*/
declare function selectMinCompressedTokenAccountsForTransferOrPartial(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
selectedAccounts: ParsedTokenAccount[],
total: BN,
totalLamports: BN | null,
maxPossibleAmount: BN
];
/**
* Selects compressed token accounts for a transfer, ensuring one extra account
* if possible, up to maxInputs.
*
* 1. Sorts accounts by amount (desc)
* 2. Selects accounts until transfer amount is met or maxInputs is reached,
* attempting to add one extra account if possible.
*
* @param {ParsedTokenAccount[]} accounts - The list of token accounts to select from.
* @param {BN} transferAmount - The token amount to be transferred.
* @param {number} [maxInputs=4] - The maximum number of accounts to select. Default: 4.
* @param {SelectInputAccountsOptions} [options] - Optional selection options.
* Use treeType to filter by V1/V2.
* @returns {[
* selectedAccounts: ParsedTokenAccount[],
* total: BN,
* totalLamports: BN | null,
* maxPossibleAmount: BN
* ]} - An array containing:
* - selectedAccounts: The accounts selected for the transfer.
* - total: The total amount accumulated from the selected accounts.
* - totalLamports: The total lamports accumulated from the selected accounts.
* - maxPossibleAmount: The maximum possible amount that can be transferred considering maxInputs.
*
* @example
* const accounts = [
* { parsed: { amount: new BN(100) }, compressedAccount: { lamports: new BN(10) } },
* { parsed: { amount: new BN(50) }, compressedAccount: { lamports: new BN(5) } },
* { parsed: { amount: new BN(25) }, compressedAccount: { lamports: new BN(2) } },
* ];
* const transferAmount = new BN(75);
* const maxInputs = 2;
*
* const [selectedAccounts, total, totalLamports, maxPossibleAmount] =
* selectSmartCompressedTokenAccountsForTransfer(accounts, transferAmount, maxInputs);
*
* console.log(selectedAccounts.length); // 2
* console.log(total.toString()); // '150'
* console.log(totalLamports!.toString()); // '15'
* console.log(maxPossibleAmount.toString()); // '150'
*/
declare function selectSmartCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number, options?: SelectInputAccountsOptions): [
selectedAccounts: ParsedTokenAccount[],
total: BN,
totalLamports: BN | null,
maxPossibleAmount: BN
];
/**
* Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,
* returns partial amounts if insufficient accounts are found instead of
* throwing an error.
*/
declare function selectSmartCompressedTokenAccountsForTransferOrPartial(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
selectedAccounts: ParsedTokenAccount[],
total: BN,
totalLamports: BN | null,
maxPossibleAmount: BN
];
type TokenTransferOutputData = {
/**
* The owner of the output token account
*/
owner: PublicKey;
/**
* The amount of tokens of the output token account
*/
amount: BN;
/**
* lamports associated with the output token account
*/
lamports: BN | null;
/**
* TokenExtension tlv
*/
tlv: Buffer$1 | null;
};
type PackedTokenTransferOutputData = {
/**
* The owner of the output token account
*/
owner: PublicKey;
/**
* The amount of tokens of the output token account
*/
amount: BN;
/**
* lamports associated with the output token account
*/
lamports: BN | null;
/**
* Merkle tree pubkey index in remaining accounts
*/
merkleTreeIndex: number;
/**
* TokenExtension tlv
*/
tlv: Buffer$1 | null;
};
type InputTokenDataWithContext = {
amount: BN;
delegateIndex: number | null;
merkleContext: PackedMerkleContextLegacy;
rootIndex: number;
lamports: BN | null;
tlv: Buffer$1 | null;
};
type DelegatedTransfer = {
owner: PublicKey;
delegateChangeAccountIndex: number | null;
};
type BatchCompressInstructionData = {
pubkeys: PublicKey[];
amounts: BN[] | null;
lamports: BN | null;
amount: BN | null;
index: number;
bump: number;
};
type MintToInstructionData = {
recipients: PublicKey[];
amounts: BN[];
lamports: BN | null;
};
type CompressSplTokenAccountInstructionData = {
owner: PublicKey;
remainingAmount: BN | null;
cpiContext: CompressedCpiContext | null;
};
declare function isSingleSplInterfaceInfo(splInterfaceInfos: SplInterfaceInfo | SplInterfaceInfo[]): splInterfaceInfos is SplInterfaceInfo;
/**
* @deprecated Use {@link isSingleSplInterfaceInfo} instead.
*/
declare const isSingleTokenPoolInfo: typeof isSingleSplInterfaceInfo;
type CompressedTokenInstructionDataTransfer = {
/**
* Validity proof
*/
proof: ValidityProof | null;
/**
* The mint of the transfer
*/
mint: PublicKey;
/**
* Whether the signer is a delegate
*/
delegatedTransfer: DelegatedTransfer | null;
/**
* Input token data with packed merkle context
*/
inputTokenDataWithContext: InputTokenDataWithContext[];
/**
* Data of the output token accounts
*/
outputCompressedAccounts: PackedTokenTransferOutputData[];
/**
* Whether it's a compress or decompress action if compressOrDecompressAmount is non-null
*/
isCompress: boolean;
/**
* If null, it's a transfer.
* If some, the amount that is being deposited into (compress) or withdrawn from (decompress) the token escrow
*/
compressOrDecompressAmount: BN | null;
/**
* CPI context if
*/
cpiContext: CompressedCpiContext | null;
/**
* The index of the Merkle tree for a lamport change account.
*/
lamportsChangeAccountMerkleTreeIndex: number | null;
};
type TokenData = {
/**
* The mint associated with this account
*/
mint: PublicKey;
/**
* The owner of this account
*/
owner: PublicKey;
/**
* The amount of tokens this account holds
*/
amount: BN;
/**
* If `delegate` is `Some` then `delegated_amount` represents the amount
* authorized by the delegate
*/
delegate: PublicKey | null;
/**
* The account's state
*/
state: number;
/**
* TokenExtension tlv
*/
tlv: Buffer$1 | null;
};
type CompressedTokenInstructionDataApprove = {
proof: ValidityProof | null;
mint: PublicKey;
inputTokenDataWithContext: InputTokenDataWithContext[];
cpiContext: CompressedCpiContext | null;
delegate: PublicKey;
delegatedAmount: BN;
delegateMerkleTreeIndex: number;
changeAccountMerkleTreeIndex: number;
delegateLamports: BN | null;
};
type CompressedTokenInstructionDataRevoke = {
proof: ValidityProof | null;
mint: PublicKey;
inputTokenDataWithContext: InputTokenDataWithContext[];
cpiContext: CompressedCpiContext | null;
outputAccountMerkleTreeIndex: number;
};
type PackCompressedTokenAccountsParams = {
/** Input state to be consumed */
inputCompressedTokenAccounts: ParsedTokenAccount[];
/**
* Output state tree. Required for mint/compress (no inputs).
* For transfer/merge with V1 inputs: pass a V2 tree for migration.
* If not provided with inputs, uses input tree.
*/
outputStateTreeInfo?: TreeInfo;
/** Optional remaining accounts to append to */
remainingAccounts?: PublicKey[];
/**
* Root indices that are used on-chain to fetch the correct root
* from the state Merkle tree account for validity proof verification.
*/
rootIndices: number[];
tokenTransferOutputs: TokenTransferOutputData[];
};
/**
* Packs Compressed Token Accounts.
*/
declare function packCompressedTokenAccounts(params: PackCompressedTokenAccountsParams): {
inputTokenDataWithContext: InputTokenDataWithContext$1[];
remainingAccountMetas: AccountMeta[];
packedOutputTokenData: PackedTokenTransferOutputData[];
};
/**
* Check if all input accounts belong to the same mint.
*
* @param compressedTokenAccounts The compressed token accounts
* @param mint The mint of the token pool
* @returns True if all input accounts belong to the same mint
*/
declare function checkMint(compressedTokenAccounts: ParsedTokenAccount[], mint: PublicKey): boolean;
type LightCompressedToken = {
version: '1.2.0';
name: 'light_compressed_token';
instructions: [
{
name: 'createTokenPool';
docs: [
'This instruction creates a token pool for a given mint. Every spl mint',
'can have one token pool. When a token is compressed the tokens are',
'transferrred to the token pool, and their compressed equivalent is',
'minted into a Merkle tree.'
];
accounts: [
{
name: 'feePayer';
isMut: true;
isSigner: true;
docs: ['UNCHECKED: only pays fees.'];
},
{
name: 'tokenPoolPda';
isMut: true;
isSigner: false;
},
{
name: 'systemProgram';
isMut: false;
isSigner: false;
},
{
name: 'mint';
isMut: true;
isSigner: false;
},
{
name: 'tokenProgram';
isMut: false;
isSigner: false;
},
{
name: 'cpiAuthorityPda';
isMut: false;
isSigner: false;
}
];
args: [];
},
{
name: 'addTokenPool';
docs: [
'This instruction creates an additional token pool for a given mint.',
'The maximum number of token pools per mint is 5.'
];
accounts: [
{
name: 'feePayer';
isMut: true;
isSigner: true;
docs: ['UNCHECKED: only pays fees.'];
},
{
name: 'tokenPoolPda';
isMut: true;
isSigner: false;
},
{
name: 'existingTokenPoolPda';
isMut: false;
isSigner: false;
},
{
name: 'systemProgram';
isMut: false;
isSigner: false;
},
{
name: 'mint';
isMut: true;
isSigner: false;
},
{
name: 'tokenProgram';
isMut: false;
isSigner: false;
},
{
name: 'cpiAuthorityPda';
isMut: false;
isSigner: false;
}
];
args: [
{
name: 'tokenPoolIndex';
type: 'u8';
}
];
},
{
name: 'mintTo';
docs: [
'Mints tokens from an spl token mint to a list of compressed accounts.',
'Minted tokens are transferred to a pool account owned by the compressed',
'token program. The instruction creates one compressed output account for',
'every amount and pubkey input pair. A constant amount of lamports can be',
'transferred to each output account to enable. A use case to add lamports',
'to a compressed token account is to prevent spam. This is the only way',
'to add lamports to a compressed token account.'
];
accounts: [
{
name: 'feePayer';
isMut: true;
isSigner: true;
docs: ['UNCHECKED: only pays fees.'];
},
{
name: 'authority';
isMut: false;
isSigner: true;
},
{
name: 'cpiAuthorityPda';
isMut: false;
isSigner: false;
},
{
name: 'mint';
isMut: true;
isSigner: false;
},
{
name: 'tokenPoolPda';
isMut: true;
isSigner: false;
},
{
name: 'tokenProgram';
isMut: false;
isSigner: false;
},
{
name: 'lightSystemProgram';
isMut: false;
isSigner: false;
},
{
name: 'registeredProgramPda';
isMut: false;
isSigner: false;
},
{
name: 'noopProgram';
isMut: false;
isSigner: false;
docs: ['programs'];
},
{
name: 'accountCompressionAuthority';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionProgram';
isMut: false;
isSigner: false;
},
{
name: 'merkleTree';
isMut: true;
isSigner: false;
},
{
name: 'selfProgram';
isMut: false;
isSigner: false;
},
{
name: 'systemProgram';
isMut: false;
isSigner: false;
},
{
name: 'solPoolPda';
isMut: true;
isSigner: false;
isOptional: true;
}
];
args: [
{
name: 'publicKeys';
type: {
vec: 'publicKey';
};
},
{
name: 'amounts';
type: {
vec: 'u64';
};
},
{
name: 'lamports';
type: {
option: 'u64';
};
}
];
},
{
name: 'compressSplTokenAccount';
docs: [
'Compresses the balance of an spl token account sub an optional remaining',
'amount. This instruction does not close the spl token account. To close',
'the account bundle a close spl account instruction in your transaction.'
];
accounts: [
{
name: 'feePayer';
isMut: true;
isSigner: true;
docs: ['UNCHECKED: only pays fees.'];
},
{
name: 'authority';
isMut: false;
isSigner: true;
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.'
];
},
{
name: 'cpiAuthorityPda';
isMut: false;
isSigner: false;
},
{
name: 'lightSystemProgram';
isMut: false;
isSigner: false;
},
{
name: 'registeredProgramPda';
isMut: false;
isSigner: false;
},
{
name: 'noopProgram';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionAuthority';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionProgram';
isMut: false;
isSigner: false;
},
{
name: 'selfProgram';
isMut: false;
isSigner: false;
docs: ['this program is the signer of the cpi.'];
},
{
name: 'tokenPoolPda';
isMut: true;
isSigner: false;
isOptional: true;
},
{
name: 'compressOrDecompressTokenAccount';
isMut: true;
isSigner: false;
isOptional: true;
},
{
name: 'tokenProgram';
isMut: false;
isSigner: false;
isOptional: true;
},
{
name: 'systemProgram';
isMut: false;
isSigner: false;
}
];
args: [
{
name: 'owner';
type: 'publicKey';
},
{
name: 'remainingAmount';
type: {
option: 'u64';
};
},
{
name: 'cpiContext';
type: {
option: {
defined: 'CompressedCpiContext';
};
};
}
];
},
{
name: 'transfer';
docs: [
'Transfers compressed tokens from one account to another. All accounts',
'must be of the same mint. Additional spl tokens can be compressed or',
'decompressed. In one transaction only compression or decompression is',
'possible. Lamports can be transferred alongside tokens. If output token',
'accounts specify less lamports than inputs the remaining lamports are',
'transferred to an output compressed account. Signer must be owner or',
'delegate. If a delegated token account is transferred the delegate is',
'not preserved.'
];
accounts: [
{
name: 'feePayer';
isMut: true;
isSigner: true;
docs: ['UNCHECKED: only pays fees.'];
},
{
name: 'authority';
isMut: false;
isSigner: true;
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.'
];
},
{
name: 'cpiAuthorityPda';
isMut: false;
isSigner: false;
},
{
name: 'lightSystemProgram';
isMut: false;
isSigner: false;
},
{
name: 'registeredProgramPda';
isMut: false;
isSigner: false;
},
{
name: 'noopProgram';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionAuthority';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionProgram';
isMut: false;
isSigner: false;
},
{
name: 'selfProgram';
isMut: false;
isSigner: false;
docs: ['this program is the signer of the cpi.'];
},
{
name: 'tokenPoolPda';
isMut: true;
isSigner: false;
isOptional: true;
},
{
name: 'compressOrDecompressTokenAccount';
isMut: true;
isSigner: false;
isOptional: true;
},
{
name: 'tokenProgram';
isMut: false;
isSigner: false;
isOptional: true;
},
{
name: 'systemProgram';
isMut: false;
isSigner: false;
}
];
args: [
{
name: 'inputs';
type: 'bytes';
}
];
},
{
name: 'approve';
docs: [
'Delegates an amount to a delegate. A compressed token account is either',
'completely delegated or not. Prior delegates are not preserved. Cannot',
'be called by a delegate.',
'The instruction creates two output accounts:',
'1. one account with delegated amount',
'2. one account with remaining(change) amount'
];
accounts: [
{
name: 'feePayer';
isMut: true;
isSigner: true;
docs: ['UNCHECKED: only pays fees.'];
},
{
name: 'authority';
isMut: false;
isSigner: true;
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.'
];
},
{
name: 'cpiAuthorityPda';
isMut: false;
isSigner: false;
},
{
name: 'lightSystemProgram';
isMut: false;
isSigner: false;
},
{
name: 'registeredProgramPda';
isMut: false;
isSigner: false;
},
{
name: 'noopProgram';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionAuthority';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionProgram';
isMut: false;
isSigner: false;
},
{
name: 'selfProgram';
isMut: false;
isSigner: false;
docs: ['this program is the signer of the cpi.'];
},
{
name: 'systemProgram';
isMut: false;
isSigner: false;
}
];
args: [
{
name: 'inputs';
type: 'bytes';
}
];
},
{
name: 'revoke';
docs: [
'Revokes a delegation. The instruction merges all inputs into one output',
'account. Cannot be called by a delegate. Delegates are not preserved.'
];
accounts: [
{
name: 'feePayer';
isMut: true;
isSigner: true;
docs: ['UNCHECKED: only pays fees.'];
},
{
name: 'authority';
isMut: false;
isSigner: true;
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.'
];
},
{
name: 'cpiAuthorityPda';
isMut: false;
isSigner: false;
},
{
name: 'lightSystemProgram';
isMut: false;
isSigner: false;
},
{
name: 'registeredProgramPda';
isMut: false;
isSigner: false;
},
{
name: 'noopProgram';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionAuthority';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionProgram';
isMut: false;
isSigner: false;
},
{
name: 'selfProgram';
isMut: false;
isSigner: false;
docs: ['this program is the signer of the cpi.'];
},
{
name: 'systemProgram';
isMut: false;
isSigner: false;
}
];
args: [
{
name: 'inputs';
type: 'bytes';
}
];
},
{
name: 'freeze';
docs: [
'Freezes compressed token accounts. Inputs must not be frozen. Creates as',
'many outputs as inputs. Balances and delegates are preserved.'
];
accounts: [
{
name: 'feePayer';
isMut: true;
isSigner: true;
docs: ['UNCHECKED: only pays fees.'];
},
{
name: 'authority';
isMut: false;
isSigner: true;
},
{
name: 'cpiAuthorityPda';
isMut: false;
isSigner: false;
},
{
name: 'lightSystemProgram';
isMut: false;
isSigner: false;
},
{
name: 'registeredProgramPda';
isMut: false;
isSigner: false;
},
{
name: 'noopProgram';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionAuthority';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionProgram';
isMut: false;
isSigner: false;
},
{
name: 'selfProgram';
isMut: false;
isSigner: false;
docs: ['that this program is the signer of the cpi.'];
},
{
name: 'systemProgram';
isMut: false;
isSigner: false;
},
{
name: 'mint';
isMut: false;
isSigner: false;
}
];
args: [
{
name: 'inputs';
type: 'bytes';
}
];
},
{
name: 'thaw';
docs: [
'Thaws frozen compressed token accounts. Inputs must be frozen. Creates',
'as many outputs as inputs. Balances and delegates are preserved.'
];
accounts: [
{
name: 'feePayer';
isMut: true;
isSigner: true;
docs: ['UNCHECKED: only pays fees.'];
},
{
name: 'authority';
isMut: false;
isSigner: true;
},
{
name: 'cpiAuthorityPda';
isMut: false;
isSigner: false;
},
{
name: 'lightSystemProgram';
isMut: false;
isSigner: false;
},
{
name: 'registeredProgramPda';
isMut: false;
isSigner: false;
},
{
name: 'noopProgram';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionAuthority';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionProgram';
isMut: false;
isSigner: false;
},
{
name: 'selfProgram';
isMut: false;
isSigner: false;
docs: ['that this program is the signer of the cpi.'];
},
{
name: 'systemProgram';
isMut: false;
isSigner: false;
},
{
name: 'mint';
isMut: false;
isSigner: false;
}
];
args: [
{
name: 'inputs';
type: 'bytes';
}
];
},
{
name: 'burn';
docs: [
'Burns compressed tokens and spl tokens from the pool account. Delegates',
'can burn tokens. The output compressed token account remains delegated.',
'Creates one output compressed token account.'
];
accounts: [
{
name: 'feePayer';
isMut: true;
isSigner: true;
docs: ['UNCHECKED: only pays fees.'];
},
{
name: 'authority';
isMut: false;
isSigner: true;
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.'
];
},
{
name: 'cpiAuthorityPda';
isMut: false;
isSigner: false;
},
{
name: 'mint';
isMut: true;
isSigner: false;
},
{
name: 'tokenPoolPda';
isMut: true;
isSigner: false;
},
{
name: 'tokenProgram';
isMut: false;
isSigner: false;
},
{
name: 'lightSystemProgram';
isMut: false;
isSigner: false;
},
{
name: 'registeredProgramPda';
isMut: false;
isSigner: false;
},
{
name: 'noopProgram';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionAuthority';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionProgram';
isMut: false;
isSigner: false;
},
{
name: 'selfProgram';
isMut: false;
isSigner: false;
},
{
name: 'systemProgram';
isMut: false;
isSigner: false;
}
];
args: [
{
name: 'inputs';
type: 'bytes';
}
];
},
{
name: 'stubIdlBuild';
docs: [
'This function is a stub to allow Anchor to include the input types in',
'the IDL. It should not be included in production builds nor be called in',
'practice.'
];
accounts: [
{
name: 'feePayer';
isMut: true;
isSigner: true;
docs: ['UNCHECKED: only pays fees.'];
},
{
name: 'authority';
isMut: false;
isSigner: true;
docs: [
'Authority is verified through proof since both owner and delegate',
'are included in the token data hash, which is a public input to the',
'validity proof.'
];
},
{
name: 'cpiAuthorityPda';
isMut: false;
isSigner: false;
},
{
name: 'lightSystemProgram';
isMut: false;
isSigner: false;
},
{
name: 'registeredProgramPda';
isMut: false;
isSigner: false;
},
{
name: 'noopProgram';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionAuthority';
isMut: false;
isSigner: false;
},
{
name: 'accountCompressionProgram';
isMut: false;
isSigner: false;
},
{
name: 'selfProgram';
isMut: false;
isSigner: false;
docs: ['this program is the signer of the cpi.'];
},
{
name: 'tokenPoolPda';
isMut: true;
isSigner: false;
isOptional: true;
},
{
name: 'compressOrDecompressTokenAccount';
isMut: true;
isSigner: false;
isOptional: true;
},
{
name: 'tokenProgram';
isMut: false;
isSigner: false;
isOptional: true;
},
{
name: 'systemProgram';
isMut: false;
isSigner: false;
}
];
args: [
{
name: 'inputs1';
type: {
defined: 'CompressedTokenInstructionDataTransfer';
};
},
{
name: 'inputs2';
type: {
defined: 'TokenData';
};
}
];
}
];
types: [
{
name: 'AccountState';
type: {
kind: 'enum';
variants: [
{
name: 'Initialized';
},
{
name: 'Frozen';
}
];
};
},
{
name: 'CompressedAccount';
type: {
kind: 'struct';
fields: [
{
name: 'owner';
type: 'publicKey';
},
{
name: 'lamports';
type: 'u64';
},
{
name: 'address';
type: {
option: {
array: ['u8', 32];
};
};
},
{
name: 'data';
type: {
option: {
defined: 'CompressedAccountData';
};
};
}
];
};
},
{
name: 'CompressedAccountData';
type: {
kind: 'struct';
fields: [
{
name: 'discriminator';
type: {
array: ['u8', 8];
};
},
{
name: 'data';
type: 'bytes';
},
{
name: 'dataHash';
type: {
array: ['u8', 32];
};
}
];
};
},
{
name: 'CompressedCpiContext';
type: {
kind: 'struct';
fields: [
{
name: 'setContext';
docs: [
'Is set by the program that is invoking the CPI to signal that is should',
'set the cpi context.'
];
type: 'bool';
},
{
name: 'firstSetContext';
docs: [
'Is set to wipe the cpi context since someone could have set it before',
'with unrelated data.'
];
type: 'bool';
},
{
name: 'cpiContextAccountIndex';
docs: [
'Index of cpi context account in remaining accounts.'
];
type: 'u8';
}
];
};
},
{
name: 'CompressedProof';
type: {
kind: 'struct';
fields: [
{
name: 'a';
type: {
array: ['u8', 32];
};
},
{
name: 'b';
type: {
array: ['u8', 64];
};
},
{
name: 'c';
type: {
array: ['u8', 32];
};
}
];
};
},
{
name: 'CompressedTokenInstructionDataTransfer';
type: {
kind: 'struct';
fields: [
{
name: 'proof';
type: {
option: {
defined: 'CompressedProof';
};
};
},
{
name: 'mint';
type: 'publicKey';
},
{
name: 'delegatedTransfer';
docs: [
'Is required if the signer is delegate,',
'-> delegate is authority account,',
'owner = Some(owner) is the owner of the token account.'
];
type: {
option: {
defined: 'DelegatedTransfer';
};
};
},
{
name: 'inputTokenDataWithContext';
type: {
vec: {
defined: 'InputTokenDataWithContext';
};
};
},
{
name: 'outputCompressedAccounts';
type: {
vec: {
defined: 'PackedTokenTransferOutputData';
};
};
},
{
name: 'isCompress';
type: 'bool';
},
{
name: 'compressOrDecompressAmount';
type: {
option: 'u64';
};
},
{
name: 'cpiContext';
type: {
option: {
defined: 'CompressedCpiContext';
};
};
},
{
name: 'lamportsChangeAccountMerkleTreeIndex';
type: {
option: 'u8';
};
}
];
};
},
{
name: 'CompressedTokenInstructionDataRevoke';
type: {
kind: 'struct';
fields: [
{
name: 'proof';
type: {
option: {
defined: 'CompressedProof';
};
};
},
{
name: 'mint';
type: 'publicKey';
},
{
name: 'inputTokenDataWithContext';
type: {
vec: {
defined: 'InputTokenDataWithContext';
};
};
},
{
name: 'cpiContext';
type: {
option: {
defined: 'CompressedCpiContext';
};
};
},
{
name: 'outputAccountMerkleTreeIndex';
type: 'u8';
}
];
};
},
{
name: 'CompressedTokenInstructionDataApprove';
type: {
kind: 'struct';
fields: [
{
name: 'proof';
type: {
option: {
defined: 'CompressedProof';
};
};
},
{
name: 'mint';
type: 'publicKey';
},
{
name: 'inputTokenDataWithContext';
type: {
vec: {
defined: 'InputTokenDataWithContext';
};
};
},
{
name: 'cpiContext';
type: {
option: {
defined: 'CompressedCpiContext';
};
};
},
{
name: 'delegate';
type: 'publicKey';
},
{
name: 'delegatedAmount';
type: 'u64';
},
{
name: 'delegateMerkleTreeIndex';
type: 'u8';
},
{
name: 'changeAccountMerkleTreeIndex';
type: 'u8';
},
{
name: 'delegateLamports';
type: {
option: 'u64';
};
}
];
};
},
{
name: 'DelegatedTransfer';
docs: [
'Struct to provide the owner when the delegate is signer of the transaction.'
];
type: {
kind: 'struct';
fields: [
{
name: 'owner';
type: 'publicKey';
},
{
name: 'delegateChangeAccountIndex';
docs: [
'Index of change compressed account in output compressed accounts. In',
"case that the delegate didn't spend the complete delegated compressed",
'account balance the change compressed account will be delegated to her',
'as well.'
];
type: {
option: 'u8';
};
}
];
};
},
{
name: 'InputTokenDataWithContext';
type: {
kind: 'struct';
fields: [
{
name: 'amount';
type: 'u64';
},
{
name: 'delegateIndex';
type: {
option: 'u8';
};
},
{
name: 'merkleContext';
type: {
defined: 'PackedMerkleContext';
};
},
{
name: 'rootIndex';
type: 'u16';
},
{
name: 'lamports';
type: {
option: 'u64';
};
},
{
name: 'tlv';
docs: [
'Placeholder for TokenExtension tlv data (unimplemented)'
];
type: {
option: 'bytes';
};
}
];
};
},
{
name: 'InstructionDataInvoke';
type: {
kind: 'struct';
fields: [
{
name: 'proof';
type: {
option: {
defined: 'CompressedProof';
};
};
},
{
name: 'inputCompressedAccountsWithMerkleContext';
type: {
vec: {
defined: 'PackedCompressedAccountWithMerkleContext';
};
};
},
{
name: 'outputCompressedAccounts';
type: {
vec: {
defined: 'OutputCompressedAccountWithPackedContext';
};
};
},
{
name: 'relayFee';
type: {
option: 'u64';
};
},
{
name: 'newAddressParams';
type: {
vec: {
defined: 'NewAddressParamsPacked';
};
};
},
{
name: 'compressOrDecompressLamports';
type: {
option: 'u64';
};
},
{
name: 'isCompress';
type: 'bool';
}
];
};
},
{
name: 'InstructionDataInvokeCpi';
type: {
kind: 'struct';
fields: [
{
name: 'proof';
type: {
option: {
defined: 'CompressedProof';
};
};
},
{
name: 'newAddressParams';
type: {
vec: {
defined: 'NewAddressParamsPacked';
};
};
},
{
name: 'inputCompressedAccountsWithMerkleContext';
type: {
vec: {
defined: 'PackedCompressedAccountWithMerkleContext';
};
};
},
{
name: 'outputCompressedAccounts';
type: {
vec: {
defined: 'OutputCompressedAccountWithPackedContext';
};
};
},
{
name: 'relayFee';
type: {
option: 'u64';
};
},
{
name: 'compressOrDecompressLamports';
type: {
option: 'u64';
};
},
{
name: 'isCompress';
type: 'bool';
},
{
name: 'cpiContext';
type: {
option: {
defined: 'CompressedCpiContext';
};
};
}
];
};
},
{
name: 'MerkleTreeSequenceNumber';
type: {
kind: 'struct';
fields: [
{
name: 'pubkey';
type: 'publicKey';
},
{
name: 'seq';
type: 'u64';
}
];
};
},
{
name: 'NewAddressParamsPacked';
type: {
kind: 'struct';
fields: [
{
name: 'seed';
type: {
array: ['u8', 32];
};
},
{
name: 'addressQueueAccountIndex';
type: 'u8';
},
{
name: 'addressMerkleTreeAccountIndex';
type: 'u8';
},
{
name: 'addressMerkleTreeRootIndex';
type: 'u16';
}
];
};
},
{
name: 'OutputCompressedAccountWithPackedContext';
type: {
kind: 'struct';
fields: [
{
name: 'compressedAccount';
type: {
defined: 'CompressedAccount';
};
},
{
name: 'merkleTreeIndex';
type: 'u8';
}
];
};
},
{
name: 'PackedCompressedAccountWithMerkleContext';
type: {
kind: 'struct';
fields: [
{
name: 'compressedAccount';
type: {
defined: 'CompressedAccount';
};
},
{
name: 'merkleContext';
type: {
defined: 'PackedMerkleContext';
};
},
{
name: 'rootIndex';
docs: [
'Index of root used in inclusion validity proof.'
];
type: 'u16';
},
{
name: 'readOnly';
docs: [
'Placeholder to mark accounts read-only unimplemented set to false.'
];
type: 'bool';
}
];
};
},
{
name: 'PackedMerkleContext';
type: {
kind: 'struct';
fields: [
{
name: 'merkleTreePubkeyIndex';
type: 'u8';
},
{
name: 'queuePubkeyIndex';
type: 'u8';
},
{
name: 'leafIndex';
type: 'u32';
},
{
name: 'proveByIndex';
type: 'bool';
}
];
};
},
{
name: 'PackedTokenTransferOutputData';
type: {
kind: 'struct';
fields: [
{
name: 'owner';
type: 'publicKey';
},
{
name: 'amount';
type: 'u64';
},
{
name: 'lamports';
type: {
option: 'u64';
};
},
{
name: 'merkleTreeIndex';
type: 'u8';
},
{
name: 'tlv';
docs: [
'Placeholder for TokenExtension tlv data (unimplemented)'
];
type: {
option: 'bytes';
};
}
];
};
},
{
name: 'PublicTransactionEvent';
type: {
kind: 'struct';
fields: [
{
name: 'inputCompressedAccountHashes';
type: {
vec: {
array: ['u8', 32];
};
};
},
{
name: 'outputCompressedAccountHashes';
type: {
vec: {
array: ['u8', 32];
};
};
},
{
name: 'outputCompressedAccounts';
type: {
vec: {
defined: 'OutputCompressedAccountWithPackedContext';
};
};
},
{
name: 'outputLeafIndices';
type: {
vec: 'u32';
};
},
{
name: 'sequenceNumbers';
type: {
vec: {
defined: 'MerkleTreeSequenceNumber';
};
};
},
{
name: 'relayFee';
type: {
option: 'u64';
};
},
{
name: 'isCompress';
type: 'bool';
},
{
name: 'compressOrDecompressLamports';
type: {
option: 'u64';
};
},
{
name: 'pubkeyArray';
type: {
vec: 'publicKey';
};
},
{
name: 'message';
type: {
option: 'bytes';
};
}
];
};
},
{
name: 'QueueIndex';
type: {
kind: 'struct';
fields: [
{
name: 'queueId';
docs: ['Id of queue in queue account.'];
type: 'u8';
},
{
name: 'index';
docs: ['Index of compressed account hash in queue.'];
type: 'u16';
}
];
};
},
{
name: 'TokenData';
type: {
kind: 'struct';
fields: [
{
name: 'mint';
docs: ['The mint associated with this account'];
type: 'publicKey';
},
{
name: 'owner';
docs: ['The owner of this account.'];
type: 'publicKey';
},
{
name: 'amount';
docs: ['The amount of tokens this account holds.'];
type: 'u64';
},
{
name: 'delegate';
docs: [
'If `delegate` is `Some` then `delegated_amount` represents',
'the amount authorized by the delegate'
];
type: {
option: 'publicKey';
};
},
{
name: 'state';
docs: ["The account's state"];
type: {
defined: 'AccountState';
};
},
{
name: 'tlv';
docs: [
'Placeholder for TokenExtension tlv data (unimplemented)'
];
type: {
option: 'bytes';
};
}
];
};
}
];
errors: [
{
code: 6000;
name: 'PublicKeyAmountMissmatch';
msg: 'public keys and amounts must be of same length';
},
{
code: 6001;
name: 'ComputeInputSumFailed';
msg: 'ComputeInputSumFailed';
},
{
code: 6002;
name: 'ComputeOutputSumFailed';
msg: 'ComputeOutputSumFailed';
},
{
code: 6003;
name: 'ComputeCompressSumFailed';
msg: 'ComputeCompressSumFailed';
},
{
code: 6004;
name: 'ComputeDecompressSumFailed';
msg: 'ComputeDecompressSumFailed';
},
{
code: 6005;
name: 'SumCheckFailed';
msg: 'SumCheckFailed';
},
{
code: 6006;
name: 'DecompressRecipientUndefinedForDecompress';
msg: 'DecompressRecipientUndefinedForDecompress';
},
{
code: 6007;
name: 'CompressedPdaUndefinedForDecompress';
msg: 'CompressedPdaUndefinedForDecompress';
},
{
code: 6008;
name: 'DeCompressAmountUndefinedForDecompress';
msg: 'DeCompressAmountUndefinedForDecompress';
},
{
code: 6009;
name: 'CompressedPdaUndefinedForCompress';
msg: 'CompressedPdaUndefinedForCompress';
},
{
code: 6010;
name: 'DeCompressAmountUndefinedForCompress';
msg: 'DeCompressAmountUndefinedForCompress';
},
{
code: 6011;
name: 'DelegateSignerCheckFailed';
msg: 'DelegateSignerCheckFailed';
},
{
code: 6012;
name: 'MintTooLarge';
msg: 'Minted amount greater than u64::MAX';
},
{
code: 6013;
name: 'SplTokenSupplyMismatch';
msg: 'SplTokenSupplyMismatch';
},
{
code: 6014;
name: 'HeapMemoryCheckFailed';
msg: 'HeapMemoryCheckFailed';
},
{
code: 6015;
name: 'InstructionNotCallable';
msg: 'The instruction is not callable';
},
{
code: 6016;
name: 'ArithmeticUnderflow';
msg: 'ArithmeticUnderflow';
},
{
code: 6017;
name: 'HashToFieldError';
msg: 'HashToFieldError';
},
{
code: 6018;
name: 'InvalidAuthorityMint';
msg: 'Expected the authority to be also a mint authority';
},
{
code: 6019;
name: 'InvalidFreezeAuthority';
msg: 'Provided authority is not the freeze authority';
},
{
code: 6020;
name: 'InvalidDelegateIndex';
},
{
code: 6021;
name: 'TokenPoolPdaUndefined';
},
{
code: 6022;
name: 'IsTokenPoolPda';
msg: 'Compress or decompress recipient is the same account as the token pool pda.';
},
{
code: 6023;
name: 'InvalidTokenPoolPda';
},
{
code: 6024;
name: 'NoInputTokenAccountsProvided';
},
{
code: 6025;
name: 'NoInputsProvided';
},
{
code: 6026;
name: 'MintHasNoFreezeAuthority';
},
{
code: 6027;
name: 'MintWithInvalidExtension';
},
{
code: 6028;
name: 'InsufficientTokenAccountBalance';
msg: 'The token account balance is less than the remaining amount.';
},
{
code: 6029;
name: 'InvalidTokenPoolBump';
msg: 'Max number of token pools reached.';
},
{
code: 6030;
name: 'FailedToDecompress';
},
{
code: 6031;
name: 'FailedToBurnSplTokensFromTokenPool';
},
{
code: 6032;
name: 'NoMatchingBumpFound';
}
];
};
declare const IDL: LightCompressedToken;
declare const DelegatedTransferLayout: Layout;
declare const CpiContextLayout: Layout;
declare const CompressedTokenInstructionDataTransferLayout: Layout;
declare const mintToLayout: Layout;
declare const batchCompressLayout: Layout;
declare const compressSplTokenAccountInstructionDataLayout: Layout;
declare function encodeMintToInstructionData(data: MintToInstructionData): Buffer$1;
declare function decodeMintToInstructionData(buffer: Buffer$1): MintToInstructionData;
declare function encodeBatchCompressInstructionData(data: BatchCompressInstructionData): Buffer$1;
declare function decodeBatchCompressInstructionData(buffer: Buffer$1): BatchCompressInstructionData;
declare function encodeCompressSplTokenAccountInstructionData(data: CompressSplTokenAccountInstructionData): Buffer$1;
declare function decodeCompressSplTokenAccountInstructionData(buffer: Buffer$1): CompressSplTokenAccountInstructionData;
declare function encodeTransferInstructionData(data: CompressedTokenInstructionDataTransfer): Buffer$1;
declare function decodeTransferInstructionData(buffer: Buffer$1): CompressedTokenInstructionDataTransfer;
interface BaseAccountsLayoutParams {
feePayer: PublicKey;
authority: PublicKey;
cpiAuthorityPda: PublicKey;
lightSystemProgram: PublicKey;
registeredProgramPda: PublicKey;
noopProgram: PublicKey;
accountCompressionAuthority: PublicKey;
accountCompressionProgram: PublicKey;
selfProgram: PublicKey;
systemProgram: PublicKey;
}
type createTokenPoolAccountsLayoutParams = {
feePayer: PublicKey;
tokenPoolPda: PublicKey;
systemProgram: PublicKey;
mint: PublicKey;
tokenProgram: PublicKey;
cpiAuthorityPda: PublicKey;
};
type addTokenPoolAccountsLayoutParams = createTokenPoolAccountsLayoutParams & {
existingTokenPoolPda: PublicKey;
};
type mintToAccountsLayoutParams = BaseAccountsLayoutParams & {
mint: PublicKey;
tokenPoolPda: PublicKey;
tokenProgram: PublicKey;
merkleTree: PublicKey;
solPoolPda: PublicKey | null;
};
type transferAccountsLayoutParams = BaseAccountsLayoutParams & {
tokenPoolPda?: PublicKey;
compressOrDecompressTokenAccount?: PublicKey;
tokenProgram?: PublicKey;
};
type approveAccountsLayoutParams = BaseAccountsLayoutParams;
type revokeAccountsLayoutParams = approveAccountsLayoutParams;
type freezeAccountsLayoutParams = BaseAccountsLayoutParams & {
mint: PublicKey;
};
type thawAccountsLayoutParams = freezeAccountsLayoutParams;
declare const createTokenPoolAccountsLayout: (accounts: createTokenPoolAccountsLayoutParams) => AccountMeta[];
declare const addTokenPoolAccountsLayout: (accounts: addTokenPoolAccountsLayoutParams) => AccountMeta[];
declare const mintToAccountsLayout: (accounts: mintToAccountsLayoutParams) => AccountMeta[];
declare const transferAccountsLayout: (accounts: transferAccountsLayoutParams) => AccountMeta[];
declare const approveAccountsLayout: (accounts: approveAccountsLayoutParams) => AccountMeta[];
declare const revokeAccountsLayout: (accounts: approveAccountsLayoutParams) => AccountMeta[];
declare const freezeAccountsLayout: (accounts: freezeAccountsLayoutParams) => AccountMeta[];
declare const thawAccountsLayout: (accounts: freezeAccountsLayoutParams) => AccountMeta[];
declare const CompressedTokenInstructionDataApproveLayout: Layout;
declare const CompressedTokenInstructionDataRevokeLayout: Layout;
declare function encodeApproveInstructionData(data: CompressedTokenInstructionDataApprove): Buffer$1;
declare function decodeApproveInstructionData(buffer: Buffer$1): CompressedTokenInstructionDataApprove;
declare function encodeRevokeInstructionData(data: CompressedTokenInstructionDataRevoke): Buffer$1;
declare function decodeRevokeInstructionData(buffer: Buffer$1): CompressedTokenInstructionDataRevoke;
type CompressParams = {
/**
* Fee payer
*/
payer: PublicKey;
/**
* Owner of uncompressed token account
*/
owner: PublicKey;
/**
* Source SPL Token account address
*/
source: PublicKey;
/**
* Recipient address(es)
*/
toAddress: PublicKey | PublicKey[];
/**
* Token amount(s) to compress
*/
amount: number | BN | number[] | BN[];
/**
* SPL Token mint address
*/
mint: PublicKey;
/**
* State tree to write to
*/
outputStateTreeInfo: TreeInfo;
/**
* Token pool
*/
tokenPoolInfo: TokenPoolInfo | SplInterfaceInfo;
};
type CompressSplTokenAccountParams = {
/**
* Fee payer
*/
feePayer: PublicKey;
/**
* SPL Token account owner
*/
authority: PublicKey;
/**
* SPL Token account to compress
*/
tokenAccount: PublicKey;
/**
* SPL Token mint address
*/
mint: PublicKey;
/**
* Amount to leave in token account
*/
remainingAmount?: BN;
/**
* State tree to write to
*/
outputStateTreeInfo: TreeInfo;
/**
* Token pool
*/
tokenPoolInfo: TokenPoolInfo | SplInterfaceInfo;
};
type DecompressParams = {
/**
* Fee payer
*/
payer: PublicKey;
/**
* Source compressed token accounts
*/
inputCompressedTokenAccounts: ParsedTokenAccount[];
/**
* Destination uncompressed token account
*/
toAddress: PublicKey;
/**
* Token amount to decompress
*/
amount: number | BN;
/**
* Validity proof for input state
*/
recentValidityProof: ValidityProof | CompressedProof | null;
/**
* Recent state root indices
*/
recentInputStateRootIndices: number[];
/**
* Token pool(s)
*/
tokenPoolInfos: TokenPoolInfo | TokenPoolInfo[] | SplInterfaceInfo | SplInterfaceInfo[];
};
type TransferParams = {
/**
* Fee payer
*/
payer: PublicKey;
/**
* Source compressed token accounts
*/
inputCompressedTokenAccounts: ParsedTokenAccount[];
/**
* Recipient address
*/
toAddress: PublicKey;
/**
* Token amount to transfer
*/
amount: BN | number;
/**
* Validity proof for input state
*/
recentValidityProof: ValidityProof | CompressedProof | null;
/**
* Recent state root indices
*/
recentInputStateRootIndices: number[];
};
type ApproveParams = {
/**
* Fee payer
*/
payer: PublicKey;
/**
* Source compressed token accounts
*/
inputCompressedTokenAccounts: ParsedTokenAccount[];
/**
* Recipient address
*/
toAddress: PublicKey;
/**
* Token amount to approve
*/
amount: BN | number;
/**
* Validity proof for input state
*/
recentValidityProof: ValidityProof | CompressedProof | null;
/**
* Recent state root indices
*/
recentInputStateRootIndices: number[];
};
type RevokeParams = {
/**
* Fee payer
*/
payer: PublicKey;
/**
* Input compressed token accounts
*/
inputCompressedTokenAccounts: ParsedTokenAccount[];
/**
* Validity proof for input state
*/
recentValidityProof: ValidityProof | CompressedProof | null;
/**
* Recent state root indices
*/
recentInputStateRootIndices: number[];
};
/**
* Create Mint account for compressed Tokens
*/
type CreateMintParams = {
/**
* Fee payer
*/
feePayer: PublicKey;
/**
* SPL Mint address
*/
mint: PublicKey;
/**
* Mint authority
*/
authority: PublicKey;
/**
* Optional: freeze authority
*/
freezeAuthority: PublicKey | null;
/**
* Mint decimals
*/
decimals: number;
/**
* lamport amount for mint account rent exemption
*/
rentExemptBalance: number;
/**
* Optional: The token program ID. Default: SPL Token Program ID
*/
tokenProgramId?: PublicKey;
/**
* Optional: Mint size to use, defaults to MINT_SIZE
*/
mintSize?: number;
};
/**
* Parameters for merging compressed token accounts
*/
type MergeTokenAccountsParams = {
/**
* Fee payer
*/
payer: PublicKey;
/**
* Owner of the compressed token accounts to be merged
*/
owner: PublicKey;
/**
* SPL Token mint address
*/
mint: PublicKey;
/**
* Array of compressed token accounts to merge
*/
inputCompressedTokenAccounts: ParsedTokenAccount[];
/**
* Validity proof for state inclusion
*/
recentValidityProof: ValidityProof | CompressedProof | null;
/**
* State root indices of the input state
*/
recentInputStateRootIndices: number[];
};
/**
* Create compressed token accounts
*/
type MintToParams = {
/**
* Fee payer
*/
feePayer: PublicKey;
/**
* Token mint address
*/
mint: PublicKey;
/**
* Mint authority
*/
authority: PublicKey;
/**
* Recipient address(es)
*/
toPubkey: PublicKey[] | PublicKey;
/**
* Token amount(s) to mint
*/
amount: BN | BN[] | number | number[];
/**
* State tree for minted tokens
*/
outputStateTreeInfo: TreeInfo;
/**
* Token pool
*/
tokenPoolInfo: TokenPoolInfo | SplInterfaceInfo;
};
/**
* Register an existing SPL mint account to the compressed token program.
* Creates an omnibus account (SPL interface) for the mint.
*/
type CreateSplInterfaceParams = {
/**
* Fee payer
*/
feePayer: PublicKey;
/**
* SPL Mint address
*/
mint: PublicKey;
/**
* Optional: The token program ID. Default: SPL Token Program ID
*/
tokenProgramId?: PublicKey;
};
/**
* @deprecated Use {@link CreateSplInterfaceParams} instead.
*/
type CreateTokenPoolParams = CreateSplInterfaceParams;
type AddSplInterfaceParams = {
/**
* Fee payer
*/
feePayer: PublicKey;
/**
* Token mint address
*/
mint: PublicKey;
/**
* SPL interface pool index
*/
poolIndex: number;
/**
* Optional: Token program ID. Default: SPL Token Program ID
*/
tokenProgramId?: PublicKey;
};
/**
* @deprecated Use {@link AddSplInterfaceParams} instead.
*/
type AddTokenPoolParams = AddSplInterfaceParams;
/**
* Mint from existing SPL mint to compressed token accounts
*/
type ApproveAndMintToParams = {
/**
* Fee payer
*/
feePayer: PublicKey;
/**
* SPL Mint address
*/
mint: PublicKey;
/**
* Mint authority
*/
authority: PublicKey;
/**
* Mint authority (associated) token account
*/
authorityTokenAccount: PublicKey;
/**
* Recipient address
*/
toPubkey: PublicKey;
/**
* Token amount to mint
*/
amount: BN | number;
/**
* State tree to write to
*/
outputStateTreeInfo: TreeInfo;
/**
* Token pool
*/
tokenPoolInfo: TokenPoolInfo | SplInterfaceInfo;
};
type CreateTokenProgramLookupTableParams = {
/**
* Fee payer
*/
payer: PublicKey;
/**
* Authority of the transaction
*/
authority: PublicKey;
/**
* Optional Mint addresses to store in the lookup table
*/
mints?: PublicKey[];
/**
* Recently finalized Solana slot
*/
recentSlot: number;
/**
* Optional additional addresses to store in the lookup table
*/
remainingAccounts?: PublicKey[];
};
/**
* Sum up the token amounts of the compressed token accounts
*/
declare const sumUpTokenAmount: (accounts: ParsedTokenAccount[]) => BN;
/**
* Validate that all the compressed token accounts are owned by the same owner.
*/
declare const validateSameTokenOwner: (accounts: ParsedTokenAccount[]) => void;
/**
* Parse compressed token accounts to get the mint, current owner and delegate.
*/
declare const parseTokenData: (compressedTokenAccounts: ParsedTokenAccount[]) => {
mint: PublicKey;
currentOwner: PublicKey;
delegate: PublicKey | null;
};
declare const parseMaybeDelegatedTransfer: (inputs: ParsedTokenAccount[], outputs: TokenTransferOutputData[]) => {
delegatedTransfer: DelegatedTransfer | null;
authority: PublicKey;
};
/**
* Create the output state for a transfer transaction.
* @param inputCompressedTokenAccounts Input state
* @param toAddress Recipient address
* @param amount Amount of tokens to transfer
* @returns Output token data for the transfer
* instruction
*/
declare function createTransferOutputState(inputCompressedTokenAccounts: ParsedTokenAccount[], toAddress: PublicKey, amount: number | BN): TokenTransferOutputData[];
/**
* Create the output state for a compress transaction.
* @param inputCompressedTokenAccounts Input state
* @param amount Amount of tokens to compress
* @returns Output token data for the compress
* instruction
*/
declare function createDecompressOutputState(inputCompressedTokenAccounts: ParsedTokenAccount[], amount: number | BN): TokenTransferOutputData[];
declare class CompressedTokenProgram {
/**
* @internal
*/
constructor();
/**
* Public key that identifies the CompressedPda program
*/
static programId: PublicKey;
/**
* Set a custom programId via PublicKey or base58 encoded string.
* This method is not required for regular usage.
*
* Use this only if you know what you are doing.
*/
static setProgramId(programId: PublicKey | string): void;
/**
* Derive the SPL interface PDA.
* To derive the SPL interface PDA with bump, use {@link deriveSplInterfacePdaWithIndex}.
*
* @param mint The mint of the SPL interface
*
* @returns The SPL interface PDA
*/
static deriveSplInterfacePda(mint: PublicKey): PublicKey;
/**
* @deprecated Use {@link deriveSplInterfacePda} instead.
*/
static deriveTokenPoolPda(mint: PublicKey): PublicKey;
/**
* Find the index and bump for a given SPL interface PDA and mint.
*
* @param poolPda The SPL interface PDA to find the index and bump for
* @param mint The mint of the SPL interface
*
* @returns The index and bump number.
*/
static findSplInterfaceIndexAndBump(poolPda: PublicKey, mint: PublicKey): [number, number];
/**
* @deprecated Use {@link findSplInterfaceIndexAndBump} instead.
*/
static findTokenPoolIndexAndBump(poolPda: PublicKey, mint: PublicKey): [number, number];
/**
* Derive the SPL interface PDA with index.
*
* @param mint The mint of the SPL interface
* @param index Index. starts at 0. The Protocol supports 4 indexes aka SPL interfaces
* per mint.
*
* @returns The SPL interface PDA and bump.
*/
static deriveSplInterfacePdaWithIndex(mint: PublicKey, index: number): [PublicKey, number];
/**
* @deprecated Use {@link deriveSplInterfacePdaWithIndex} instead.
*/
static deriveTokenPoolPdaWithIndex(mint: PublicKey, index: number): [PublicKey, number];
/** @internal */
static get deriveCpiAuthorityPda(): PublicKey;
/**
* Construct createMint instruction for SPL tokens.
*
* @param feePayer Fee payer.
* @param mint SPL Mint address.
* @param authority Mint authority.
* @param freezeAuthority Optional: freeze authority.
* @param decimals Decimals.
* @param rentExemptBalance Lamport amount for mint account rent exemption.
* @param tokenProgramId Optional: Token program ID. Default: SPL Token Program ID
* @param mintSize Optional: mint size. Default: MINT_SIZE
*
* @returns [createMintAccountInstruction, initializeMintInstruction,
* createSplInterfaceInstruction]
*
* Note that `createSplInterfaceInstruction` must be executed after
* `initializeMintInstruction`.
*/
static createMint({ feePayer, mint, authority, freezeAuthority, decimals, rentExemptBalance, tokenProgramId, mintSize, }: CreateMintParams): Promise;
/**
* Create SPL interface (omnibus account) for an existing SPL mint.
* For new mints, use `CompressedTokenProgram.createMint`.
*
* @param feePayer Fee payer.
* @param mint SPL Mint address.
* @param tokenProgramId Optional: Token program ID. Default: SPL
* Token Program ID
*
* @returns The createSplInterface instruction
*/
static createSplInterface({ feePayer, mint, tokenProgramId, }: CreateSplInterfaceParams): Promise;
/**
* @deprecated Use {@link createSplInterface} instead.
*/
static createTokenPool(params: CreateSplInterfaceParams): Promise;
/**
* Add a token pool to an existing SPL mint. For new mints, use
* {@link createSplInterface}.
*
* @param feePayer Fee payer.
* @param mint SPL Mint address.
* @param poolIndex Pool index.
* @param tokenProgramId Optional: Token program ID. Default: SPL
* Token Program ID
*
* @returns The addTokenPool instruction
*/
static addTokenPool({ feePayer, mint, poolIndex, tokenProgramId, }: AddSplInterfaceParams): Promise;
/**
* Construct mintTo instruction for compressed tokens
*
* @param feePayer Fee payer.
* @param mint SPL Mint address.
* @param authority Mint authority.
* @param toPubkey Recipient owner address.
* @param amount Amount of tokens to mint.
* @param outputStateTreeInfo State tree to write to.
* @param tokenPoolInfo Token pool info.
*
* @returns The mintTo instruction
*/
static mintTo({ feePayer, mint, authority, toPubkey, amount, outputStateTreeInfo, tokenPoolInfo, }: MintToParams): Promise;
/**
* Mint tokens from registered SPL mint account to a compressed account
*
* @param feePayer Fee payer.
* @param mint SPL Mint address.
* @param authority Mint authority.
* @param authorityTokenAccount The mint authority's associated token
* account (ATA).
* @param toPubkey Recipient owner address.
* @param amount Amount of tokens to mint.
* @param outputStateTreeInfo State tree to write to.
* @param tokenPoolInfo Token pool info.
*
* @returns The mintTo instruction
*/
static approveAndMintTo({ feePayer, mint, authority, authorityTokenAccount, toPubkey, amount, outputStateTreeInfo, tokenPoolInfo, }: ApproveAndMintToParams): Promise;
/**
* Construct transfer instruction for compressed tokens.
*
* V1 inputs automatically migrate to V2 outputs when in V2 mode.
*
* @param payer Fee payer.
* @param inputCompressedTokenAccounts Source compressed token accounts.
* @param toAddress Recipient owner address.
* @param amount Amount of tokens to transfer.
* @param recentValidityProof Recent validity proof.
* @param recentInputStateRootIndices Recent state root indices.
*
* @returns The transfer instruction
*/
static transfer({ payer, inputCompressedTokenAccounts, toAddress, amount, recentValidityProof, recentInputStateRootIndices, }: TransferParams): Promise;
/**
* Create lookup table instructions for the token program's default
* accounts.
*
* @param payer Fee payer.
* @param authority Authority.
* @param mints Mints.
* @param recentSlot Recent slot.
* @param remainingAccounts Remaining accounts.
*
* @returns [createInstruction, extendInstruction, option(extendInstruction2)]
*/
static createTokenProgramLookupTable({ payer, authority, mints, recentSlot, remainingAccounts, }: CreateTokenProgramLookupTableParams): Promise<{
instructions: TransactionInstruction[];
address: PublicKey;
}>;
/**
* Create compress instruction
*
* @param payer Fee payer.
* @param owner Owner of uncompressed token account.
* @param source Source SPL Token account address.
* @param toAddress Recipient owner address(es).
* @param amount Amount of tokens to compress.
* @param mint SPL Token mint address.
* @param outputStateTreeInfo State tree to write to.
* @param tokenPoolInfo Token pool info.
*
* @returns The compress instruction
*/
static compress({ payer, owner, source, toAddress, amount, mint, outputStateTreeInfo, tokenPoolInfo, }: CompressParams): Promise;
/**
* Construct decompress instruction
*
* @param payer Fee payer.
* @param inputCompressedTokenAccounts Source compressed token accounts.
* @param toAddress Destination **uncompressed** token
* account address. (ATA)
* @param amount Amount of tokens to decompress.
* @param recentValidityProof Recent validity proof.
* @param recentInputStateRootIndices Recent state root indices.
* @param tokenPoolInfos Token pool info.
*
* @returns The decompress instruction
*/
static decompress({ payer, inputCompressedTokenAccounts, toAddress, amount, recentValidityProof, recentInputStateRootIndices, tokenPoolInfos, }: DecompressParams): Promise;
/**
* Create `mergeTokenAccounts` instruction.
*
* @param payer Fee payer.
* @param owner Owner of the compressed token
* accounts to be merged.
* @param inputCompressedTokenAccounts Source compressed token accounts.
* @param mint SPL Token mint address.
* @param recentValidityProof Recent validity proof.
* @param recentInputStateRootIndices Recent state root indices.
* @returns instruction
*/
static mergeTokenAccounts({ payer, owner, inputCompressedTokenAccounts, mint, recentValidityProof, recentInputStateRootIndices, }: MergeTokenAccountsParams): Promise;
/**
* Create `compressSplTokenAccount` instruction
*
* @param feePayer Fee payer.
* @param authority SPL Token account owner.
* @param tokenAccount SPL Token account to compress.
* @param mint SPL Token mint address.
* @param remainingAmount Optional: Amount to leave in token account.
* @param outputStateTreeInfo State tree to write to.
* @param tokenPoolInfo Token pool info.
*
* @returns instruction
*/
static compressSplTokenAccount({ feePayer, authority, tokenAccount, mint, remainingAmount, outputStateTreeInfo, tokenPoolInfo, }: CompressSplTokenAccountParams): Promise;
/**
* Get the program ID for a mint
*
* @param mint SPL Token mint address.
* @param connection Connection.
*
* @returns program ID
*/
static getMintProgramId(mint: PublicKey, connection: Connection): Promise;
/**
* Create `approve` instruction to delegate compressed tokens.
*
* @param payer Fee payer.
* @param inputCompressedTokenAccounts Source compressed token accounts.
* @param toAddress Owner to delegate to.
* @param amount Amount of tokens to delegate.
* @param recentValidityProof Recent validity proof.
* @param recentInputStateRootIndices Recent state root indices.
*
* @returns instruction
*/
static approve({ payer, inputCompressedTokenAccounts, toAddress, amount, recentValidityProof, recentInputStateRootIndices, }: ApproveParams): Promise;
/**
* Create `revoke` instruction to revoke delegation of compressed tokens.
*
* @param payer Fee payer.
* @param inputCompressedTokenAccounts Source compressed token accounts.
* @param recentValidityProof Recent validity proof.
* @param recentInputStateRootIndices Recent state root indices.
*
* @returns instruction
*/
static revoke({ payer, inputCompressedTokenAccounts, recentValidityProof, recentInputStateRootIndices, }: RevokeParams): Promise;
}
/**
* Exports for @lightprotocol/compressed-token/unified
*
* Import from `/unified` to get a single unified associated token account for SPL/T22 and light-token
* mints.
*/
/**
* Get associated token account with unified balance
*
* @param rpc RPC connection
* @param ata Associated token address
* @param owner Owner public key
* @param mint Mint public key
* @param commitment Optional commitment level
* @param programId Optional program ID (omit for unified behavior)
* @returns AccountInterface with aggregated balance from all sources
*/
declare function getAtaInterface(rpc: Rpc, ata: PublicKey, owner: PublicKey, mint: PublicKey, commitment?: Commitment, programId?: PublicKey): Promise;
/**
* Derive the canonical token associated token account for SPL/T22/light-token in the unified path.
*
* Enforces LIGHT_TOKEN_PROGRAM_ID.
*
* @param mint Mint public key
* @param owner Owner public key
* @param allowOwnerOffCurve Allow owner to be a PDA. Default false.
* @param programId Token program ID. Default light-token.
* @param associatedTokenProgramId Associated token program ID. Default
* auto-detected.
* @returns Associated token address.
*/
declare function getAssociatedTokenAddressInterface(mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, programId?: PublicKey, associatedTokenProgramId?: PublicKey): PublicKey;
/**
* Create instruction batches for loading ALL token balances into a light-token associated token account.
*
* @param rpc RPC connection
* @param ata Associated token address
* @param owner Owner public key
* @param mint Mint public key
* @param payer Fee payer (defaults to owner)
* @param options Optional interface options
* @returns Instruction batches - each inner array is one transaction
*/
declare function createLoadAtaInstructions(rpc: Rpc, ata: PublicKey, owner: PublicKey, mint: PublicKey, payer?: PublicKey, options?: InterfaceOptions): Promise;
/**
* Load all token balances into the light-token associated token account.
*
* Wraps SPL/Token-2022 balances and decompresses compressed light-tokens
* into the on-chain light-token associated token account. If no balances exist and the associated token account doesn't
* exist, creates an empty ATA (idempotent).
*
* @param rpc RPC connection
* @param ata Associated token address (light-token)
* @param owner Owner of the tokens (signer)
* @param mint Mint public key
* @param payer Fee payer (signer, defaults to owner)
* @param confirmOptions Optional confirm options
* @param interfaceOptions Optional interface options
* @returns Transaction signature, or null if ATA exists and nothing to load
*/
declare function loadAta(rpc: Rpc, ata: PublicKey, owner: Signer, mint: PublicKey, payer?: Signer, confirmOptions?: ConfirmOptions, interfaceOptions?: InterfaceOptions, decimals?: number): Promise;
/**
* Transfer tokens using the unified ata interface.
*
* Destination ATA is derived from `recipient` and created idempotently.
* Automatically wraps SPL/T22 to light-token associated token account.
*
* @param rpc RPC connection
* @param payer Fee payer (signer)
* @param source Source light-token associated token account address
* @param mint Mint address
* @param recipient Destination owner wallet address
* @param owner Source account owner pubkey
* @param authority Signing authority (owner or approved delegate)
* @param amount Amount to transfer
* @param confirmOptions Optional confirm options
* @param options Optional interface options
* @returns Transaction signature
*/
declare function transferInterface(rpc: Rpc, payer: Signer, source: PublicKey, mint: PublicKey, recipient: PublicKey, owner: PublicKey, authority: Signer, amount: number | bigint | BN, confirmOptions?: ConfirmOptions, options?: InterfaceOptions, decimals?: number): Promise;
/**
* Transfer tokens to an explicit destination token account.
*
* Use this for advanced routing to non-ATA destinations.
*/
declare function transferToAccountInterface(rpc: Rpc, payer: Signer, source: PublicKey, mint: PublicKey, destination: PublicKey, owner: PublicKey, authority: Signer, amount: number | bigint | BN, confirmOptions?: ConfirmOptions, options?: InterfaceOptions, decimals?: number): Promise;
/**
* Get or create light-token ATA with unified balance detection and auto-loading.
*
* Enforces LIGHT_TOKEN_PROGRAM_ID. Aggregates balances from:
* - light-token associated token account (hot balance)
* - compressed light-token accounts (cold balance)
* - SPL token accounts (for unified wrapping)
* - Token-2022 accounts (for unified wrapping)
*
* When owner is a Signer:
* - Creates hot ATA if it doesn't exist
* - Loads cold (compressed) tokens into hot ATA
* - Wraps SPL/T22 tokens into light-token associated token account
* - Returns account with all tokens ready to use
*
* When owner is a PublicKey:
* - Creates hot ATA if it doesn't exist
* - Returns aggregated balance but does NOT auto-load (can't sign)
*
* @param rpc RPC connection
* @param payer Fee payer
* @param mint Mint address
* @param owner Owner (Signer for auto-load, PublicKey for read-only)
* @param allowOwnerOffCurve Allow PDA owners (default: false)
* @param commitment Optional commitment level
* @param confirmOptions Optional confirm options
* @returns AccountInterface with unified balance and source breakdown
*/
declare function getOrCreateAtaInterface(rpc: Rpc, payer: Signer, mint: PublicKey, owner: PublicKey | Signer, allowOwnerOffCurve?: boolean, commitment?: Commitment, confirmOptions?: ConfirmOptions): Promise;
/**
* Create transfer instructions for a unified token transfer.
*
* Unified variant: always wraps SPL/T22 to light-token associated token account.
* Recipient must be an on-curve wallet address. For PDA/off-curve owners,
* use createTransferToAccountInterfaceInstructions with an explicit destination ATA.
*
* Returns `TransactionInstruction[][]`. Send [0..n-2] in parallel, then [n-1].
* Use `sliceLast` to separate the parallel prefix from the final transfer.
*
* @see createTransferInterfaceInstructions in v3/actions/transfer-interface.ts
*/
declare function createTransferInterfaceInstructions(rpc: Rpc, payer: PublicKey, mint: PublicKey, amount: number | bigint | BN, owner: PublicKey, recipient: PublicKey, options?: InterfaceOptions): Promise;
/**
* Create transfer instructions that route to an explicit destination token
* account.
*/
declare function createTransferToAccountInterfaceInstructions(rpc: Rpc, payer: PublicKey, mint: PublicKey, amount: number | bigint | BN, owner: PublicKey, destination: PublicKey, options?: InterfaceOptions): Promise;
/**
* Build instruction batches for unwrapping light-tokens to SPL/T22.
*
* Load batches (cold -> hot) come first if needed; unwrap is bundled into the
* final batch.
* SPL/T22 balances are not consolidated; only light ATA (hot + cold) is unwrapped.
*
* Returns `TransactionInstruction[][]`. Load-only batches (if any) come first;
* the last batch contains unwrap.
*
* @param rpc RPC connection
* @param destination Destination SPL/T22 token account (must exist)
* @param owner Owner of the light-token
* @param mint Mint address
* @param amount Amount to unwrap (defaults to full balance)
* @param payer Fee payer (defaults to owner)
* @param splInterfaceInfo Optional: SPL interface info
* @param interfaceOptions Optional: interface options for load
* @returns Instruction batches - each inner array is one transaction
*/
declare function createUnwrapInstructions(rpc: Rpc, destination: PublicKey, owner: PublicKey, mint: PublicKey, amount?: number | bigint | BN, payer?: PublicKey, splInterfaceInfo?: SplInterfaceInfo, interfaceOptions?: InterfaceOptions): Promise;
/**
* Unwrap light-tokens to SPL tokens.
*
* Loads cold into hot if needed, then unwraps from light ATA to destination SPL/T22.
* SPL/T22 balances are not consolidated; only light ATA balance is unwrapped.
*
* @param rpc RPC connection
* @param payer Fee payer
* @param destination Destination SPL/T22 token account
* @param owner Owner of the light-token (signer)
* @param mint Mint address
* @param amount Amount to unwrap (defaults to all)
* @param splInterfaceInfo SPL interface info
* @param confirmOptions Confirm options
* @returns Transaction signature of the unwrap transaction
*/
declare function unwrap(rpc: Rpc, payer: Signer, destination: PublicKey, owner: Signer, mint: PublicKey, amount?: number | bigint | BN, splInterfaceInfo?: SplInterfaceInfo, confirmOptions?: ConfirmOptions, decimals?: number): Promise;
/**
* Approve a delegate for an associated token account.
*
* Auto-detects mint type (light-token, SPL, or Token-2022) and dispatches
* to the appropriate instruction.
*
* @remarks For light-token mints, all cold (compressed) balances are loaded
* into the hot ATA, not just the delegation amount. The `amount` parameter
* only controls the delegate's spending limit.
*
* @param rpc RPC connection
* @param payer Fee payer (signer)
* @param tokenAccount ATA address
* @param mint Mint address
* @param delegate Delegate to approve
* @param amount Amount to delegate
* @param owner Owner of the token account (signer)
* @param confirmOptions Optional confirm options
* @returns Transaction signature
*/
declare function approveInterface(rpc: Rpc, payer: Signer, tokenAccount: PublicKey, mint: PublicKey, delegate: PublicKey, amount: number | bigint | BN, owner: Signer, confirmOptions?: ConfirmOptions, options?: InterfaceOptions, decimals?: number): Promise;
/**
* Build instruction batches for approving a delegate on an ATA.
*
* Auto-detects mint type (light-token, SPL, or Token-2022).
*
* @remarks For light-token mints, all cold (compressed) balances are loaded
* into the hot ATA before the approve instruction. The `amount` parameter
* only controls the delegate's spending limit, not the number of accounts
* loaded.
*/
declare function createApproveInterfaceInstructions(rpc: Rpc, payer: PublicKey, mint: PublicKey, tokenAccount: PublicKey, delegate: PublicKey, amount: number | bigint | BN, owner: PublicKey, decimals?: number, options?: InterfaceOptions): Promise;
/**
* Revoke delegation for an associated token account.
*
* Auto-detects mint type (light-token, SPL, or Token-2022) and dispatches
* to the appropriate instruction.
*
* @remarks For light-token mints, all cold (compressed) balances are loaded
* into the hot ATA before the revoke instruction.
*
* @param rpc RPC connection
* @param payer Fee payer (signer)
* @param tokenAccount ATA address
* @param mint Mint address
* @param owner Owner of the token account (signer)
* @param confirmOptions Optional confirm options
* @returns Transaction signature
*/
declare function revokeInterface(rpc: Rpc, payer: Signer, tokenAccount: PublicKey, mint: PublicKey, owner: Signer, confirmOptions?: ConfirmOptions, options?: InterfaceOptions, decimals?: number): Promise;
/**
* Build instruction batches for revoking delegation on an ATA.
*
* Auto-detects mint type (light-token, SPL, or Token-2022).
*
* @remarks For light-token mints, all cold (compressed) balances are loaded
* into the hot ATA before the revoke instruction.
*/
declare function createRevokeInterfaceInstructions(rpc: Rpc, payer: PublicKey, mint: PublicKey, tokenAccount: PublicKey, owner: PublicKey, decimals?: number, options?: InterfaceOptions): Promise;
export { ADD_TOKEN_POOL_DISCRIMINATOR, APPROVE_DISCRIMINATOR, type AccountInterface, Action, type AddSplInterfaceParams, type AddTokenPoolParams, type ApproveAndMintToParams, type ApproveParams, BASE_RENT_PER_EPOCH, BATCH_COMPRESS_DISCRIMINATOR, type BaseMint, type BatchCompressInstructionData, COMPRESSED_MINT_SEED, COMPRESSIBLE_LIGHT_TOKEN_ACCOUNT_SIZE, COMPRESSIBLE_LIGHT_TOKEN_RENT_PER_EPOCH, COMPRESSION_COST, COMPRESSION_INCENTIVE, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type CompressParams, type CompressSplTokenAccountInstructionData, type CompressSplTokenAccountParams, type CompressedMint, type CompressedTokenInstructionDataApprove, CompressedTokenInstructionDataApproveLayout, type CompressedTokenInstructionDataRevoke, CompressedTokenInstructionDataRevokeLayout, type CompressedTokenInstructionDataTransfer, CompressedTokenInstructionDataTransferLayout, CompressedTokenProgram, type CompressibleConfig, CpiContextLayout, type CreateAssociatedLightTokenAccountParams, type CreateMintParams, type CreateSplInterfaceParams, type CreateTokenPoolParams, type CreateTokenProgramLookupTableParams, DEFAULT_COMPRESSIBLE_CONFIG, DEFAULT_PREPAY_EPOCHS, DEFAULT_WRITE_TOP_UP, type DecompressParams, type DelegatedTransfer, DelegatedTransferLayout, ERROR_MIXED_TREE_TYPES, ERROR_NO_ACCOUNTS_FOUND, ExtensionType, IDL, type InputTokenDataWithContext, type InterfaceOptions, LIGHT_TOKEN_CONFIG, LIGHT_TOKEN_RENT_SPONSOR, type LightCompressedToken, type LightTokenConfig, MAX_TOP_UP, MINT_TO_DISCRIMINATOR, type MergeTokenAccountsParams, type MintContext, type MintExtension, type MintInterface, type MintToInstructionData, type MintToParams, type OffChainTokenMetadata, type OffChainTokenMetadataJson, POOL_SEED, type PackCompressedTokenAccountsParams, type PackedTokenTransferOutputData, RENT_PER_BYTE_PER_EPOCH, REVOKE_DISCRIMINATOR, type RevokeParams, SLOTS_PER_RENT_EPOCH, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, type SelectInputAccountsOptions, type SelectedAccountsResult, type SplInterfaceActivity, type SplInterfaceInfo, TOTAL_COMPRESSION_COST, TRANSFER_DISCRIMINATOR, type TokenAccountSource, type TokenData, TokenDataVersion, type TokenMetadata, type TokenMetadataInstructionData, type TokenPoolActivity, type TokenPoolInfo, type TokenTransferOutputData, type TransferParams, addSplInterfaces, addTokenPoolAccountsLayout, type addTokenPoolAccountsLayoutParams, addTokenPools, approve, approveAccountsLayout, type approveAccountsLayoutParams, approveAndMintTo, approveInterface, batchCompressLayout, calculateFeePayerCostAtCreation, checkMint, checkSplInterfaceInfo, checkTokenPoolInfo, compress, compressSplTokenAccount, compressSplTokenAccountInstructionDataLayout, convertTokenDataToAccount, createApproveInterfaceInstructions, createAssociatedLightTokenAccountIdempotentInstruction, createAssociatedLightTokenAccountInstruction, createAssociatedTokenAccountInterfaceIdempotentInstruction, createAssociatedTokenAccountInterfaceInstruction, createAtaInterface, createAtaInterfaceIdempotent, createAtaInterfaceIdempotentInstruction, createDecompressOutputState, createLightTokenApproveInstruction, createLightTokenFreezeAccountInstruction, createLightTokenRevokeInstruction, createLightTokenThawAccountInstruction, createLightTokenTransferCheckedInstruction, createLightTokenTransferInstruction, createLoadAtaInstructions, createMint, createMintInstruction, createMintInterface, createMintToCompressedInstruction, createMintToInstruction, createMintToInterfaceInstruction, createRemoveMetadataKeyInstruction, createRevokeInterfaceInstructions, createSplInterface, createTokenMetadata, createTokenPool, createTokenPoolAccountsLayout, type createTokenPoolAccountsLayoutParams, createTokenProgramLookupTable, createTransferInterfaceInstructions, createTransferOutputState, createTransferToAccountInterfaceInstructions, createUnwrapInstruction, createUnwrapInstructions, createUpdateFreezeAuthorityInstruction, createUpdateMetadataAuthorityInstruction, createUpdateMetadataFieldInstruction, createUpdateMintAuthorityInstruction, createWrapInstruction, decodeApproveInstructionData, decodeBatchCompressInstructionData, decodeCompressSplTokenAccountInstructionData, decodeMintToInstructionData, decodeRevokeInstructionData, decodeTokenMetadata, decodeTransferInstructionData, decompress, decompressDelegated, deriveCMintAddress, deriveSplInterfaceInfo, deriveTokenPoolInfo, deserializeMint, encodeApproveInstructionData, encodeBatchCompressInstructionData, encodeCompressSplTokenAccountInstructionData, encodeMintToInstructionData, encodeRevokeInstructionData, encodeTokenMetadata, encodeTransferInstructionData, extractTokenMetadata, findMintAddress, freezeAccountsLayout, type freezeAccountsLayoutParams, getAccountInterface, getAssociatedLightTokenAddress, getAssociatedLightTokenAddressAndBump, getAssociatedTokenAddressInterface, getAtaInterface, getMintInterface, getOrCreateAtaInterface, getSplInterfaceInfos, getTokenPoolInfos, groupAccountsByTreeType, isSingleSplInterfaceInfo, isSingleTokenPoolInfo, loadAta, mergeTokenAccounts, mintTo, mintToAccountsLayout, type mintToAccountsLayoutParams, mintToCompressed, mintToInterface, mintToLayout, mintTo$1 as mintToLightToken, packCompressedTokenAccounts, parseLightTokenCold, parseLightTokenHot, parseMaybeDelegatedTransfer, parseTokenData, removeMetadataKey, rentPerEpoch, revoke, revokeAccountsLayout, type revokeAccountsLayoutParams, revokeInterface, selectAccountsByPreferredTreeType, selectMinCompressedTokenAccountsForDecompression, selectMinCompressedTokenAccountsForTransfer, selectMinCompressedTokenAccountsForTransferOrPartial, selectSmartCompressedTokenAccountsForTransfer, selectSmartCompressedTokenAccountsForTransferOrPartial, selectSplInterfaceInfo, selectSplInterfaceInfosForDecompression, selectTokenAccountsForApprove, selectTokenPoolInfo, selectTokenPoolInfosForDecompression, serializeMint, sliceLast, sumUpTokenAmount, thawAccountsLayout, type thawAccountsLayoutParams, toAccountInfo, toOffChainMetadataJson, toTokenPoolInfo, transfer, transferAccountsLayout, type transferAccountsLayoutParams, transferDelegated, transferInterface, transferToAccountInterface, unpackMintData, unpackMintInterface, unwrap, updateFreezeAuthority, updateMetadataAuthority, updateMetadataField, updateMintAuthority, validateSameTokenOwner, wrap };