ClientWithTransactionSending

type ClientWithTransactionSending<TContext> = object;

Represents a client that can send transactions to the Solana network.

Transaction sending handles signing, submission, and confirmation of transactions. It supports flexible input formats including instructions, instruction plans, transaction messages or transaction plans.

Example

async function executeTransfer(client: ClientWithTransactionSending) {
    const instructions = [createTransferInstruction(...)];
 
    // Send a single transaction
    const result = await client.sendTransaction(instructions);
    console.log(`Transaction confirmed: ${result.context.signature}`);
 
    // Or send potentially multiple transactions
    const results = await client.sendTransactions(instructions);
}

Type Parameters

Type ParameterDefault typeDescription
TContext extends TransactionPlanResultContextTransactionPlanResultContextWithSignatureThe context attached to the results. It defaults to TransactionPlanResultContextWithSignature, which guarantees a context.signature on every successful result. Supply a different context to change or drop that guarantee — for instance, a client whose executor records extra fields on the context.

Properties

sendTransaction

sendTransaction: (input, config?) => Promise<SuccessfulSingleTransactionPlanResult<TContext>>;

Sends a single transaction to the network.

Accepts flexible input: instructions, instruction plans, a single transaction message or a single transaction plan.

Parameters

ParameterTypeDescription
input| InstructionPlanInput | SingleTransactionPlan | SingleTransactionPlan["message"]Instructions, a transaction plan, or a transaction message.
config?ConfigOptional configuration including an abort signal.

Returns

Promise<SuccessfulSingleTransactionPlanResult<TContext>>

A promise resolving to the successful transaction result.

See

  • InstructionPlanInput
  • SingleTransactionPlan

sendTransactions

sendTransactions: (input, config?) => Promise<TransactionPlanResult<TContext>>;

Sends one or more transactions to the network.

Accepts flexible input: instructions, instruction plans, transaction messages or transaction plans.

Parameters

ParameterTypeDescription
inputInstructionPlanInput | TransactionPlanInputAny instruction or a transaction plan input.
config?ConfigOptional configuration including an abort signal.

Returns

Promise<TransactionPlanResult<TContext>>

A promise resolving to the results for all transactions.

See

  • InstructionPlanInput
  • TransactionPlanInput

On this page