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:
_10import * as sdk from "@onflow/sdk"_10_10sdk.voucherToTxId(voucher)
Or import directly the specific function:
_10import { voucherToTxId } from "@onflow/sdk"_10_10voucherToTxId(voucher)
Usage
_27import { voucherToTxId, createSignableVoucher } from "@onflow/sdk"_27import * as fcl from "@onflow/fcl";_27_27// Create a voucher from an interaction_27const 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_27const voucher = createSignableVoucher(interaction);_27_27// Calculate the transaction ID_27const txId = voucherToTxId(voucher);_27console.log("Transaction ID:", txId);_27// Returns something like: "a1b2c3d4e5f6789..."_27_27// You can use this ID to track the transaction_27const txStatus = await fcl.tx(txId).onceSealed();_27console.log("Transaction status:", txStatus);
Parameters
voucher
- Type:
_11export 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}
- Description: The voucher object to convert
Returns
string
A transaction ID string