Skip to main content

TransactionContext

Midnight.js API Reference v3.1.0


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

Interface: TransactionContext<C, ICK>

Encapsulates the context for managing a scoped contract transaction.

Type Parameters

C

C extends Contract.Any

ICK

ICK extends Contract.ImpureCircuitId<C> = Contract.ImpureCircuitId<C>

Properties

[CacheStates]()

readonly [CacheStates]: (states) => void

Parameters

states

PublicContractStates | ContractStates<PrivateState<C>>

Returns

void


[MergeUnsubmittedCallTxData]()

readonly [MergeUnsubmittedCallTxData]: (circuitId, callData, privateStateId?) => void

Parameters

circuitId

ICK

callData

UnsubmittedCallTxData<C, ICK>

privateStateId?

string

Returns

void


[Submit]()

readonly [Submit]: () => Promise<FinalizedCallTxData<C, ICK>>

Returns

Promise<FinalizedCallTxData<C, ICK>>


[TypeId]

readonly [TypeId]: typeof TypeId

Methods

getCurrentStates()

getCurrentStates(): PublicContractStates | ContractStates<PrivateState<C>> | undefined

Gets the current cached contract states within the transaction context.

Returns

PublicContractStates | ContractStates<PrivateState<C>> | undefined

A cached ContractStates instance, or undefined if circuit calls are yet to be made.

Remarks

The returned states represent the unsubmitted running state of the contract within the transaction context, reflecting any unsubmitted circuit calls made to the contract during the scope of the transaction.


getLastUnsubmittedCallTxDataToTransact()

getLastUnsubmittedCallTxDataToTransact(): [UnsubmittedCallTxData<C, ICK>, string?] | undefined

Gets the last unsubmitted call transaction data.

Returns

[UnsubmittedCallTxData<C, ICK>, string?] | undefined

A tuple containing an UnsubmittedCallTxData instance, and an optional private state ID, or undefined if circuit calls are yet to be made.