ClientWithTransactionSigning

type ClientWithTransactionSigning<TContext> = object;

Represents a client that can sign transactions without submitting them to the network.

Transaction signing accepts the same flexible inputs as ClientWithTransactionSending — instructions, instruction plans, transaction messages or transaction plans — but stops short of sending the resulting transactions. Use it to hand transactions off to another party, such as an authority wallet signing a transaction that a relayer will pay for and submit later.

Example

async function signTransfer(client: ClientWithTransactionSigning<{ transaction: Transaction }>) {
    const instructions = [createTransferInstruction(...)];
 
    // Sign a single transaction
    const result = await client.signTransaction(instructions);
    const transaction = result.context.transaction;
 
    // Or sign potentially multiple transactions
    const results = await client.signTransactions(instructions);
}

See

ClientWithTransactionSending

Type Parameters

Type ParameterDefault typeDescription
TContext extends TransactionPlanResultContextTransactionPlanResultContextThe context attached to the results. The interface makes no claim about what that context contains: it is entirely decided by the plugin providing the capability, which would typically guarantee a context.transaction on successful results. Note that this differs from ClientWithTransactionSending, whose default context preserves the context.signature guarantee that predates configurable contexts.

Properties

signTransaction

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

Signs a single transaction without sending it.

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, carrying the TContext the client was parameterised with.

See

  • InstructionPlanInput
  • SingleTransactionPlan

signTransactions

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

Signs one or more transactions without sending them.

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. Successful leaves carry the TContext the client was parameterised with.

See

  • InstructionPlanInput
  • TransactionPlanInput

On this page