Skip to main content

Transaction

type Transaction<Proven, Signed>: TransactionCommon & {
"safeSend": Promise<PendingTransaction | RejectedTransaction>;
"send": PendingTransactionPromise;
} & Proven extends false ? {
"prove": Promise<Transaction<true, Signed>>;
} : {
"proofs": (Proof<ZkappPublicInput, Empty> | undefined)[];
} & Signed extends false ? {
"sign": Transaction<Proven, true>;
} : {};

Defines the structure and operations associated with a transaction. This type encompasses methods for serializing the transaction, signing it, generating proofs, and submitting it to the network.

Type declaration

safeSend()

Sends the Transaction to the network. Unlike the standard Transaction.send, this function does not throw an error if internal errors are detected. Instead, it returns a PendingTransaction if the transaction is successfully sent for processing or a RejectedTransaction if it encounters errors during processing or is outright rejected by the Mina daemon.

Returns

Promise\<PendingTransaction | RejectedTransaction>

A promise that resolves to a PendingTransaction if the transaction is accepted for processing, or a RejectedTransaction if the transaction fails or is rejected.

Example

const result = await transaction.safeSend();
if (result.status === 'pending') {
console.log('Transaction sent successfully to the Mina daemon.');
} else if (result.status === 'rejected') {
console.error('Transaction failed with errors:', result.errors);
}

send()

Returns

PendingTransactionPromise

Type parameters

Proven extends boolean

Signed extends boolean

Source

lib/mina/transaction.ts:83