/** * Solana transaction v1 (SIMD-0385) — compile, serialize and sign, with no * dependency on @solana/kit. web3.js 1.x can decode v1 but cannot build or * serialize it, so every client that needs to SEND v1 uses this module. * * Wire format: * 0x81 | header(3) | configMask(u32 LE) | lifetime(32) | numIx(u8) | numAddr(u8) * | addresses[32 × numAddr] | configValues[4 × popcount(mask)] * | ixHeaders[(programIdx u8, numAccounts u8, dataLen u16 LE) × numIx] * | ixPayloads[(accountIndexes, data) × numIx] | signatures[64 × numSigners] * The signed message is every byte before the signatures. * * Uses only Uint8Array/DataView (no Node Buffer) so it runs unpolyfilled in * browsers, React Native and MV3 service workers. */ import { Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js"; export declare const V1_VERSION_BYTE = 129; export declare const V1_MAX_TRANSACTION_BYTES = 4096; export declare const V1_MAX_ACCOUNTS = 64; export declare const V1_MAX_INSTRUCTIONS = 64; export declare const V1_MAX_SIGNATURES = 12; export declare const V1_SIGNATURE_BYTES = 64; /** Offset of the first address: version + header + mask + lifetime + numIx + numAddr. */ export declare const V1_ADDRESSES_OFFSET: number; export declare const MAX_COMPUTE_UNIT_LIMIT = 1400000; export declare const MAX_LOADED_ACCOUNTS_DATA_BYTES: number; export declare const MIN_HEAP_BYTES: number; export declare const MAX_HEAP_BYTES: number; /** Resource requests carried in the v1 header. Unset CU / loaded-data limits are ZERO in v1. */ export interface V1Config { computeUnitLimit: number; loadedAccountsDataSizeLimit: number; /** Total priority fee in lamports (not micro-lamports per CU). */ priorityFeeLamports?: bigint; heapSize?: number; } export interface CompiledV1Message { messageBytes: Uint8Array; /** Account keys in message order; the first `numRequiredSignatures` are signers. */ accountKeys: PublicKey[]; numRequiredSignatures: number; /** Serialized transaction size once signatures are attached. */ transactionSize: number; } export declare class V1CompileError extends Error { constructor(message: string); } /** * Compile a v1 message. ComputeBudget instructions are dropped: v1 ignores them * (they only burn CU and an instruction slot) and carries the budget in `config`. * * Account order: fee payer first, then writable signers, readonly signers, * writable non-signers, readonly non-signers — insertion order within each * group. Duplicates are merged (v1 rejects duplicate addresses), keeping the * strongest signer/writable flags. */ export declare function compileV1Message(params: { payer: PublicKey; recentBlockhash: string; instructions: TransactionInstruction[]; config: V1Config; }): CompiledV1Message; /** Serialized bytes with zeroed signature slots — for simulation or later signing. */ export declare function unsignedV1Transaction(compiled: CompiledV1Message): Uint8Array; /** * Sign a compiled message. Every required signer must be provided; the * signature for accountKeys[i] goes in slot i. */ export declare function signV1Transaction(compiled: CompiledV1Message, signers: Keypair[]): { wireBytes: Uint8Array; signature: string; }; /** True when the serialized transaction is v1 (first byte 0x81). */ export declare function isV1Transaction(bytes: Uint8Array): boolean; /** Signer layout of serialized v1 bytes, without decoding the whole message. */ export declare function readV1SignerLayout(bytes: Uint8Array): { numRequiredSignatures: number; signers: PublicKey[]; messageLength: number; }; /** * Add one signer's signature to already-serialized v1 bytes (e.g. a dApp-built * transaction a wallet is asked to sign). Returns new bytes; the input is * untouched. Throws if the keypair is not a required signer. */ export declare function signV1Bytes(bytes: Uint8Array, keypair: Keypair): Uint8Array; /** Base58 of the fee payer's signature — the transaction id. */ export declare function v1TransactionSignature(bytes: Uint8Array): string;