Skip to main content

withContractScopedTransaction

For the complete documentation index, see llms.txt

Midnight.js API Reference v4.0.4


Midnight.js API Reference / @midnight-ntwrk/midnight-js-contracts / withContractScopedTransaction

Variable: withContractScopedTransaction

const withContractScopedTransaction: <C, PCK>(providers, fn, options?) => Promise<FinalizedCallTxData<C, PCK>>

Executes a function within the context of a contract-scoped transaction.

Type Parameters​

C​

C extends Contract.Any

PCK​

PCK extends Contract.ProvableCircuitId<C> = Contract.ProvableCircuitId<C>

Parameters​

providers​

ContractProviders<C, PCK>

The contract providers to use within the transaction.

fn​

(txCtx) => Promise<void>

The function to execute within the transaction context.

options?​

ScopedTransactionOptions

Optional transaction scope options.

Returns​

Promise<FinalizedCallTxData<C, PCK>>

A Promise that resolves with the finalized transaction data of the single transaction created for all circuit calls made within fn.

Remarks​

Where fn make circuit calls, these are batched together and submitted as a single transaction when the function completes successfully. If fn throws an error, any unsubmitted circuit calls are discarded.