Arcium Docs
arcium.com@ArciumHQ
  • Documentation
  • Developers
  • Intro to Arcium
  • Installation
    • Arcup Version Manager
  • Hello World with Arcium
  • Arcium Computation Lifecycle
  • Encryption
    • Sealing aka re-encryption
  • Arcis
    • Operations
    • Types
    • Input/Output
    • Best practices
  • Invoking a Computation from your Solana program
    • Computation Definition Accounts
    • Callback Accounts
  • JavaScript Client
    • Encrypting inputs
    • Tracking callbacks
  • Callback Server
  • Current Limitations
Powered by GitBook
On this page
  1. JavaScript Client

Tracking callbacks

Unlike regular transactions, a confidential transaction is not executed in sync with the chain, as the MPC execution runs in a separate environment. This means we can't wait for the computation completion in the same way we do with regular transactions, we have to wait for the computation to be completed which happens when the computation's callback is invoked in its MXE. The Arcium client library provides a way to handle this:

Await computation completion with awaitComputationFinalization

// `program` is the anchor program client of the MXE we're invoking
// the instruction `ourIx` on (which then invokes a computation under the hood by CPIing into the Arcium program).
// `queueSig` is the signature of said transaction.
const queueSig = await program.methods
  .ourIx(/* some inputs */)
  .accounts(/* some accounts */)
  .rpc();

// Since this is a Arcium computation, we need to wait for it to be finalized
// a little bit differently
const finalizeSig = await awaitComputationFinalization(
  // Connection to the chain
  provider.connection,
  queueSig,
  // Program ID of the MXE
  program.programId
);

console.log("Computation was finalized with sig: ", finalizeSig);
PreviousEncrypting inputsNextCallback Server

Last updated 23 days ago