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β
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β
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β
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β
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>