LLM Notice: This documentation site supports content negotiation for AI agents. Request any page with Accept: text/markdown or Accept: text/plain header to receive Markdown instead of HTML. Alternatively, append ?format=md to any URL. All markdown files are available at /md/ prefix paths. For all content in one file, visit /llms-full.txt
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 fcl from "@onflow/fcl"
_10
_10
fcl.voucherToTxId(voucher)

Or import directly the specific function:


_10
import { voucherToTxId } from "@onflow/fcl"
_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:

_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
}

  • Description: The voucher object to convert

Returns​

string

A transaction ID string


Rate this page