Skip to main content

Transaction

@midnight/zswap v3.0.2 β€’ Readme | API


@midnight/zswap v3.0.2 / Transaction

Class: Transaction

A Midnight transaction, consisting a guaranteed and fallible Offer, and contract call information hidden from this API.

The guaranteed section are run first, and fee payment is taken during this part. If it succeeds, the fallible section is also run, and atomically rolled back if it fails.

Constructors​

new Transaction()​

private new Transaction(): Transaction

Returns​

Transaction

Properties​

fallibleCoins​

readonly fallibleCoins: undefined | Offer;

The fallible Zswap offer


guaranteedCoins​

readonly guaranteedCoins: undefined | Offer;

The guaranteed Zswap offer


mint​

readonly mint: undefined | AuthorizedMint;

The mint this transaction represents, if applicable

Methods​

eraseProofs()​

eraseProofs(): ProofErasedTransaction

Erases the proofs contained in this transaction

Returns​

ProofErasedTransaction


fees()​

fees(params): bigint

The cost of this transaction, in the atomic unit of the base token

Parameters​

β€’ params: LedgerParameters

Returns​

bigint


identifiers()​

identifiers(): string[]

Returns the set of identifiers contained within this transaction. Any of these may be used to watch for a specific transaction.

Returns​

string[]


imbalances()​

imbalances(guaranteed, fees?): Map<string, bigint>

For given fees, and a given section (guaranteed/fallible), what the surplus or deficit of this transaction in any token type is.

Parameters​

β€’ guaranteed: boolean

β€’ fees?: bigint

Returns​

Map<string, bigint>


merge()​

merge(other): Transaction

Merges this transaction with another

Parameters​

β€’ other: Transaction

Returns​

Transaction

Throws​

If both transactions have contract interactions, or they spend the same coins


serialize()​

serialize(netid): Uint8Array

Parameters​

β€’ netid: NetworkId

Returns​

Uint8Array


toString()​

toString(compact?): string

Parameters​

β€’ compact?: boolean

Returns​

string


transactionHash()​

transactionHash(): string

Returns the hash associated with this transaction. Due to the ability to merge transactions, this should not be used to watch for a specific transaction.

Returns​

string


deserialize()​

static deserialize(raw, netid): Transaction

Parameters​

β€’ raw: Uint8Array

β€’ netid: NetworkId

Returns​

Transaction


fromUnproven()​

static fromUnproven(prove, unproven): Promise<Transaction>

Type hint that you should use an external proving function, for instance via the proof server.

Parameters​

β€’ prove

β€’ unproven: UnprovenTransaction

Returns​

Promise<Transaction>