Arcium LogoArcium TS SDK Docs

subscribeComputations

subscribeComputations(conn, mxeProgramId, callback, opts?): Promise<number>

Subscribe to computation events for an MXE program.

Listens for queue, execute, and finalize events via Solana log subscriptions. Resolves once the RPC server is streaming, so a transaction sent immediately afterwards has its events delivered.

Parameters

ParameterTypeDescription
connConnectionSolana connection object.
mxeProgramIdPublicKeyPublic key of the MXE program to monitor.
callback(event, name) => voidHandler called for each event with event data and event name.
optsSubscribeComputationsOptsOptional SubscribeComputationsOpts.

Returns

Promise<number>

Subscription ID for cleanup with unsubscribeComputations.

Throws

Error if the RPC server does not acknowledge the subscription in time.

Example

const subId = await subscribeComputations(
  connection,
  mxeProgramId,
  (event, name) => {
    if (name === 'FinalizeComputationEvent') {
      console.log('Computation finalized:', event.computationOffset.toString());
    }
  },
);

// When done, clean up the subscription
await unsubscribeComputations(connection, subId);

On this page