Skip to main content

voucherToTxId

Converts a voucher object to a transaction ID.

This function computes the transaction ID by encoding and hashing the voucher. The transaction ID can be used to track the transaction status on the Flow network.

Import

You can import the entire package and access the function:


_10
import * as sdk from "@onflow/sdk"
_10
_10
sdk.voucherToTxId(voucher)

Or import directly the specific function:


_10
import { voucherToTxId } from "@onflow/sdk"
_10
_10
voucherToTxId(voucher)

Usage


_27
import { voucherToTxId, createSignableVoucher } from "@onflow/sdk"
_27
import * as fcl from "@onflow/fcl";
_27
_27
// Create a voucher from an interaction
_27
const interaction = await fcl.build([
_27
fcl.transaction`
_27
transaction {
_27
prepare(account: AuthAccount) {
_27
log("Hello, Flow!")
_27
}
_27
}
_27
`,
_27
fcl.proposer(authz),
_27
fcl.payer(authz),
_27
fcl.authorizations([authz])
_27
]);
_27
_27
const voucher = createSignableVoucher(interaction);
_27
_27
// Calculate the transaction ID
_27
const txId = voucherToTxId(voucher);
_27
console.log("Transaction ID:", txId);
_27
// Returns something like: "a1b2c3d4e5f6789..."
_27
_27
// You can use this ID to track the transaction
_27
const txStatus = await fcl.tx(txId).onceSealed();
_27
console.log("Transaction status:", txStatus);

Parameters

voucher

  • Type: Voucher
  • Description: The voucher object to convert

_11
export interface Voucher {
_11
cadence: string
_11
refBlock: string
_11
computeLimit: number
_11
arguments: VoucherArgument[]
_11
proposalKey: VoucherProposalKey
_11
payer: string
_11
authorizers: string[]
_11
payloadSigs: Sig[]
_11
envelopeSigs: Sig[]
_11
}

Returns

string


Rate this page