Type alias SimulateNamespace<IDL, I>

SimulateNamespace<IDL, I>: MakeInstructionsNamespace<IDL, I, Promise<SimulateResponse>>

The namespace provides functions to simulate transactions for each method of a program, returning a list of deserialized events and raw program logs.

One can use this to read data calculated from a program on chain, by emitting an event in the program and reading the emitted event client side via the simulate namespace.

Usage

program.simulate.<method>(...args, ctx);

Parameters

  1. args - The positional arguments for the program. The type and number of these arguments depend on the program being used.
  2. ctx - [[Context]] non-argument parameters to pass to the method. Always the last parameter in the method call.

Example

To simulate the increment method above,

const events = await program.simulate.increment({
accounts: {
counter,
},
});

Type Parameters

  • IDL extends Idl = Idl
  • I extends AllInstructions<IDL> = AllInstructions<IDL>