getCompDefInitialisationTransactionBuilder
Umbra SDK reference for Get Comp Def Initialisation Transaction Builder.
getCompDefInitialisationTransactionBuilder(
compDefName): (owner) =>Promise<Transaction>
Defined in: src/utils/arcium.ts:116
Creates a transaction builder function for initializing a computation definition account.
Parameters
compDefName
string
The name of the computation definition (in snake_case, e.g., 'share_patient_data')
Returns
A function that takes an owner address and returns a promise resolving to a Transaction for initializing the computation definition
(
owner):Promise<Transaction>
Parameters
owner
Returns
Promise<Transaction>
Throws
CompDefInitialisationError When the computation definition name is invalid, the program method doesn't exist, or transaction building fails
Remarks
This function creates a factory function that builds transactions for initializing computation definition accounts in the Arcium Multi-Execution Environment (MXE). Computation definitions specify the zero-knowledge circuits and execution parameters for private computations.
Process:
- Converts the computation definition name from snake_case to camelCase
- Derives the Program Derived Address (PDA) for the computation definition account
- Looks up the corresponding initialization method in the program (e.g.,
initSharePatientDataCompDef) - Builds a transaction with the required accounts (compDefAccount, payer, mxeAccount)
Method Name Convention:
The function expects method names in the format: init{CompDefName}CompDef
where {CompDefName} is the camelCase version of the input compDefName.
For example:
'share_patient_data'→'initSharePatientDataCompDef''update_master_viewing_key'→'initUpdateMasterViewingKeyCompDef'
Accounts Required:
compDefAccount: The PDA for the computation definition accountpayer: The owner/account that will pay for the initializationmxeAccount: The Multi-Execution Environment account address
Examples
// Create a transaction builder for a specific computation definition
const builder = getCompDefInitialisationTransactionBuilder('share_patient_data');
// Build the transaction with an owner address
const owner = new PublicKey('...') as SolanaAddress;
const transaction = await builder(owner);
// Sign and send the transaction
const signedTx = await signer.signTransaction(transaction);
await connection.sendTransaction(signedTx);// Handle errors
try {
const builder = getCompDefInitialisationTransactionBuilder('invalid_name');
const transaction = await builder(owner);
} catch (error) {
if (error instanceof CompDefInitialisationError) {
console.error('Failed to build transaction:', error.message);
}
}