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

encodeTxIdFromVoucher

Encodes a transaction ID from a voucher by computing its hash.

A voucher is an intermediary object that contains transaction details before final encoding. This function computes the transaction ID that would result from submitting the transaction.

Import​

You can import the entire package and access the function:


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

Or import directly the specific function:


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

Usage​


_30
import * as fcl from "@onflow/fcl";
_30
import { encodeTxIdFromVoucher } from "@onflow/sdk"
_30
_30
// Create a voucher (usually done internally by FCL)
_30
const voucher = {
_30
cadence: `
_30
transaction {
_30
prepare(account: AuthAccount) {
_30
log("Hello")
_30
}
_30
}
_30
`,
_30
arguments: [],
_30
refBlock: "abc123...",
_30
computeLimit: 100,
_30
proposalKey: {
_30
address: "0x123456789abcdef0",
_30
keyId: 0,
_30
sequenceNum: 42
_30
},
_30
payer: "0x123456789abcdef0",
_30
authorizers: ["0x123456789abcdef0"],
_30
payloadSigs: [],
_30
envelopeSigs: []
_30
};
_30
_30
// Calculate the transaction ID
_30
const txId = encodeTxIdFromVoucher(voucher);
_30
console.log("Transaction ID:", txId);
_30
// Returns a transaction ID that can be used to track the transaction

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 containing transaction details

Returns​

string

A hex-encoded string representing the transaction ID


Rate this page