Skip to content

Interface: SolanaService

Solana service interface

Methods

airdrop()

ts
airdrop(params): Promise<Signature>;

Parameters

ParameterType
params{ amount: number | bigint; recipient: string | Address; }
params.amountnumber | bigint
params.recipientstring | Address

Returns

Promise<Signature>


buildAndSignBatch()

ts
buildAndSignBatch(groups, options?): Promise<SignedBatchTransaction[]>;

Pack instruction groups into the fewest transactions, then build and sign each — but do not broadcast. Returns one signed, base64-serialized transaction per bucket for a separate process to persist and send later. This is buildSignAndSendBatch minus the send: it exists so a consumer can persist-before-send for idempotency (a crash mid-send replays the identical signed transaction, which the chain dedups by signature).

Packing and the per-transaction compute-unit limit work exactly as in buildSignAndSendBatch. Each bucket is signed with all of its embedded signers (e.g. the fresh job/run keypairs minted by a list instruction) plus the fee payer — this is inherent to signing with the message's embedded signers, so every required signature is present in the returned blob.

Performs no network send. Each transaction is signed against its own freshly fetched blockhash, so lastValidBlockHeight may differ per bucket.

Because the transaction is signed now but may be broadcast later — potentially against a deeper, costlier state than when it was signed — the static compute-unit estimate can under-budget at land time. Use computeUnitMargin to over-provision the baked-in limit (the cost of over-budgeting is only fee, and for size-bound batches it does not reduce packing density).

Parameters

ParameterTypeDescription
groups( | Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]> | Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[])[]Atomic instruction groups to bulk together.
options?{ computeUnitMargin?: number; computeUnits?: number | (instruction) => number | undefined; estimateComputeUnits?: boolean; feePayer?: TransactionSigner; maxComputeUnits?: number; maxTransactionSize?: number; }Same packing options as buildSignAndSendBatch (no commitment/sequential, which only apply to sending).
options.computeUnitMargin?numberMultiplier on each instruction's compute-unit estimate (default 1). Raise it (>1) to over-provision the limit for transactions broadcast later against a costlier state.
options.computeUnits?number | (instruction) => number | undefined-
options.estimateComputeUnits?boolean-
options.feePayer?TransactionSigner-
options.maxComputeUnits?number-
options.maxTransactionSize?number-

Returns

Promise<SignedBatchTransaction[]>

One signed, un-sent transaction per packed bucket, in packing order.


buildSignAndSend()

ts
buildSignAndSend(instructions, options?): Promise<Signature>;

Parameters

ParameterType
instructions| Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]> | Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]
options?{ commitment?: "processed" | "confirmed" | "finalized"; estimateComputeUnits?: boolean; feePayer?: TransactionSigner; }
options.commitment?"processed" | "confirmed" | "finalized"
options.estimateComputeUnits?boolean
options.feePayer?TransactionSigner

Returns

Promise<Signature>


buildSignAndSendBatch()

ts
buildSignAndSendBatch(groups, options?): Promise<BatchTransactionResult[]>;

Pack instruction groups into the fewest transactions that each stay within the Solana transaction size limit, then build, sign, and send all of them.

Each entry of groups is an atomic group: a single instruction, or an array of instructions that must stay together in the same transaction. Groups are never split across transactions; they are greedily packed into buckets sized by compiling each candidate transaction in-memory (no extra RPC calls).

Unless estimateComputeUnits is set, each transaction gets an explicit SetComputeUnitLimit equal to the sum of its instructions' estimated compute units (from computeUnits), capped at the 1.4M per-transaction maximum. This keeps priority fees — which are charged against the compute-unit limit — tight instead of being billed against Solana's inflated per-instruction default.

All transactions are attempted regardless of individual failures — the returned array reports the per-transaction outcome in input order.

Parameters

ParameterTypeDescription
groups( | Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]> | Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[])[]Atomic instruction groups to bulk together.
options?{ commitment?: "processed" | "confirmed" | "finalized"; computeUnitMargin?: number; computeUnits?: number | (instruction) => number | undefined; estimateComputeUnits?: boolean; feePayer?: TransactionSigner; maxComputeUnits?: number; maxTransactionSize?: number; sequential?: boolean; }Optional configuration.
options.commitment?"processed" | "confirmed" | "finalized"Commitment level for confirmation.
options.computeUnitMargin?number-
options.computeUnits?number | (instruction) => number | undefinedPer-instruction compute-unit estimate: a fixed number for every instruction, or a function mapping an instruction to its units (return undefined to fall back to the default). Used to set each transaction's compute-unit limit and to bound packing. Defaults to Solana's per-instruction default.
options.estimateComputeUnits?booleanIf true, estimates the compute unit limit per transaction via simulation instead of the static computeUnits estimate. Default: false.
options.feePayer?TransactionSignerOptional fee payer signer. Defaults to the service feePayer or wallet.
options.maxComputeUnits?numberPer-transaction compute-unit cap. Defaults to 1,400,000.
options.maxTransactionSize?numberOverride the maximum serialized transaction size in bytes.
options.sequential?booleanIf true, sends transactions one at a time, confirming each before the next. Combined with estimateComputeUnits, this makes each simulation reflect the chain state left by the prior transactions (e.g. a market queue that grows or shrinks across the batch). Default: false (all transactions are sent concurrently).

Returns

Promise<BatchTransactionResult[]>

A per-transaction result array, in the order the buckets were packed.


buildTransaction()

ts
buildTransaction(instructions, options?): Promise<TransactionMessage & TransactionMessageWithFeePayer<string> & TransactionMessageWithBlockhashLifetime>;

Build a transaction message from instructions. This function creates a transaction message with fee payer, blockhash, and instructions.

Parameters

ParameterTypeDescription
instructions| Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]> | Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]Single instruction or array of instructions
options?{ estimateComputeUnits?: boolean; feePayer?: string | Address | TransactionSigner; }Optional configuration
options.estimateComputeUnits?booleanIf true, estimates and sets the compute unit limit. Default: false.
options.feePayer?string | Address | TransactionSignerOptional custom fee payer. Can be a TransactionSigner (for full signing) or an Address/string (for partial signing where feepayer signs later). Takes precedence over service feePayer and wallet.

Returns

Promise<TransactionMessage & TransactionMessageWithFeePayer<string> & TransactionMessageWithBlockhashLifetime>

An unsigned transaction message ready to be signed


decompileTransaction()

ts
decompileTransaction(transaction): Readonly<{
  instructions: readonly Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[];
  version: TransactionVersion;
}> & TransactionMessageWithFeePayer<string> & TransactionMessageWithLifetime;

Decompile a transaction back to a transaction message. Use this to inspect/verify the content of a deserialized transaction before signing.

Note: Decompilation is lossy - some information like lastValidBlockHeight may not be fully reconstructed. The returned message is suitable for inspection but may not be suitable for re-signing without additional context.

Parameters

ParameterTypeDescription
transactionTransactionThe compiled transaction to decompile

Returns

Readonly<{ instructions: readonly Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]; version: TransactionVersion; }> & TransactionMessageWithFeePayer<string> & TransactionMessageWithLifetime

The decompiled transaction message (with either blockhash or durable nonce lifetime)


deserializeTransaction()

ts
deserializeTransaction(base64): Promise<Readonly<{
  messageBytes: TransactionMessageBytes;
  signatures: SignaturesMap;
}> & TransactionWithBlockhashLifetime>;

Deserialize a base64 string back to a transaction. Use this to receive transactions from other parties.

Note: This method automatically restores the lastValidBlockHeight metadata that is lost during serialization by fetching the latest blockhash from the RPC.

Parameters

ParameterTypeDescription
base64stringThe base64 encoded transaction string

Returns

Promise<Readonly<{ messageBytes: TransactionMessageBytes; signatures: SignaturesMap; }> & TransactionWithBlockhashLifetime>

The deserialized transaction with restored lifetime metadata


getBalance()

ts
getBalance(addressStr?): Promise<bigint>;

Get the SOL balance for a specific address.

Parameters

ParameterTypeDescription
addressStr?string | AddressOptional address to query. If not provided, uses the wallet address.

Returns

Promise<bigint>

The SOL balance in lamports

Throws

If neither address nor wallet is provided


getBalanceInfo()

ts
getBalanceInfo(addressStr?): Promise<SolBalanceInfo>;

Get SOL balance metadata for a specific address.

Parameters

ParameterTypeDescription
addressStr?string | AddressOptional address to query. If not provided, uses the wallet address.

Returns

Promise<SolBalanceInfo>

Exact lamports plus display-oriented SOL metadata

Throws

If neither address nor wallet is provided


getCreateATAInstructionIfNeeded()

ts
getCreateATAInstructionIfNeeded(
   ata,
   mint,
   owner,
   payer?): Promise<
  | Instruction<Address, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]> & InstructionWithData<ReadonlyUint8Array<ArrayBufferLike>> & InstructionWithAccounts<[AccountMeta<string> & object & AccountSignerMeta<string, TransactionSigner<string>>, WritableAccount<string>, ReadonlyAccount<string>]>
| null>;

Get an instruction to create an associated token account if it doesn't exist. Checks if the ATA exists, and if not, returns an instruction to create it. Uses the idempotent version so it's safe to call even if the account already exists.

Parameters

ParameterTypeDescription
ataAddressThe associated token account address
mintAddressThe token mint address
ownerAddressThe owner of the associated token account
payer?Address | TransactionSignerOptional payer for the account creation. Can be a TransactionSigner (for full signing) or an Address (for deferred signing scenarios where the payer signs later). If not provided, uses the wallet or service feePayer.

Returns

Promise< | Instruction<Address, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]> & InstructionWithData<ReadonlyUint8Array<ArrayBufferLike>> & InstructionWithAccounts<[AccountMeta<string> & object & AccountSignerMeta<string, TransactionSigner<string>>, WritableAccount<string>, ReadonlyAccount<string>]> | null>

An instruction to create the ATA if it doesn't exist, or null if it already exists


partiallySignTransaction()

ts
partiallySignTransaction(transactionMessage): Promise<Readonly<{
  messageBytes: TransactionMessageBytes;
  signatures: SignaturesMap;
}> & TransactionWithBlockhashLifetime>;

Partially sign a transaction message with the signers embedded in the transaction. The transaction message must already have a fee payer address set (via buildTransaction with an address). Signers are extracted from instructions in the message (e.g., transfer source signer). Use this when building transactions where the fee payer will sign later.

Parameters

ParameterTypeDescription
transactionMessageTransactionMessage & TransactionMessageWithFeePayer<string> & TransactionMessageWithBlockhashLifetimeThe transaction message to sign (must have fee payer address set and signers embedded in instructions)

Returns

Promise<Readonly<{ messageBytes: TransactionMessageBytes; signatures: SignaturesMap; }> & TransactionWithBlockhashLifetime>

A partially signed transaction


pda()

ts
pda(seeds, programId): Promise<Address>;

Parameters

ParameterType
seeds(string | Address)[]
programIdAddress

Returns

Promise<Address>


sendTransaction()

ts
sendTransaction(transaction, options?): Promise<Signature>;

Parameters

ParameterType
transactionFullySignedTransaction & TransactionWithinSizeLimit & Readonly<{ messageBytes: TransactionMessageBytes; signatures: SignaturesMap; }> & TransactionWithBlockhashLifetime
options?{ commitment?: "processed" | "confirmed" | "finalized"; }
options.commitment?"processed" | "confirmed" | "finalized"

Returns

Promise<Signature>


serializeTransaction()

ts
serializeTransaction(transaction): string;

Serialize a transaction to a base64 string. Works with both partially signed and fully signed transactions. Use this to transmit transactions to other parties (e.g., for fee payer signing).

Parameters

ParameterTypeDescription
transactionTransactionThe transaction to serialize

Returns

string

Base64 encoded wire transaction string


signTransaction()

ts
signTransaction(transactionMessage): Promise<FullySignedTransaction & TransactionWithinSizeLimit & Readonly<{
  messageBytes: TransactionMessageBytes;
  signatures: SignaturesMap;
}> & TransactionWithBlockhashLifetime>;

Parameters

ParameterType
transactionMessageTransactionMessage & TransactionMessageWithFeePayer<string> & TransactionMessageWithBlockhashLifetime

Returns

Promise<FullySignedTransaction & TransactionWithinSizeLimit & Readonly<{ messageBytes: TransactionMessageBytes; signatures: SignaturesMap; }> & TransactionWithBlockhashLifetime>


signTransactionWithSigners()

ts
signTransactionWithSigners(transaction, signers): Promise<FullySignedTransaction & TransactionWithinSizeLimit & Readonly<{
  messageBytes: TransactionMessageBytes;
  signatures: SignaturesMap;
}> & TransactionWithBlockhashLifetime>;

Sign a transaction with the provided signers. Use this when receiving a partially signed transaction that needs additional signatures. This adds signatures from the provided signers to the transaction.

Parameters

ParameterTypeDescription
transactionReadonly<{ messageBytes: TransactionMessageBytes; signatures: SignaturesMap; }> & TransactionWithBlockhashLifetimeThe transaction to sign (typically partially signed, received from another party)
signersReadonly<{ address: Address<string>; signTransactions: Promise<readonly Readonly<Record<Address, SignatureBytes>>[]>; }>[]Array of TransactionPartialSigners to sign with

Returns

Promise<FullySignedTransaction & TransactionWithinSizeLimit & Readonly<{ messageBytes: TransactionMessageBytes; signatures: SignaturesMap; }> & TransactionWithBlockhashLifetime>

The signed transaction with additional signatures


transfer()

ts
transfer(params): Promise<TransferSolInstruction<Address, string, string, []>>;

Get an instruction to transfer SOL from one address to another.

Parameters

ParameterTypeDescription
params{ amount: number | bigint; from?: TransactionSigner; to: string | Address; }Transfer parameters
params.amountnumber | bigintAmount in lamports (number or bigint)
params.from?TransactionSignerOptional sender TransactionSigner. If not provided, uses wallet from client.
params.tostring | AddressRecipient address

Returns

Promise<TransferSolInstruction<Address, string, string, []>>

An instruction to transfer SOL

Properties

PropertyModifierTypeDescription
configreadonlySolanaConfig-
estimateAndSetComputeUnitLimitreadonly<T>(transactionMessage) => Promise<AppendTransactionMessageInstructions<T, readonly [SetComputeUnitLimitInstruction<Address, []>]>>-
feePayerpublicTransactionSigner | undefinedOptional fee payer for transactions. If set, will be used as fallback when no feePayer is provided in options. Set this property directly to configure the fee payer.
rpcreadonly| Rpc<SolanaRpcApiForAllClusters | SolanaRpcApiForTestClusters> | RpcDevnet<SolanaRpcApiForAllClusters | SolanaRpcApiForTestClusters> | RpcMainnet<SolanaRpcApiForAllClusters | SolanaRpcApiForTestClusters> | RpcTestnet<SolanaRpcApiForAllClusters | SolanaRpcApiForTestClusters>-
rpcSubscriptionsreadonly| RpcSubscriptions<SolanaRpcSubscriptionsApi> | RpcSubscriptionsDevnet<SolanaRpcSubscriptionsApi> | RpcSubscriptionsMainnet<SolanaRpcSubscriptionsApi> | RpcSubscriptionsTestnet<SolanaRpcSubscriptionsApi>-
sendAndConfirmTransactionreadonlySendAndConfirmTransactionWithBlockhashLifetimeFunction-