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:
_10import * as sdk from "@onflow/sdk"_10_10sdk.encodeTxIdFromVoucher(voucher)
Or import directly the specific function:
_10import { encodeTxIdFromVoucher } from "@onflow/sdk"_10_10encodeTxIdFromVoucher(voucher)
Usage
_30import * as fcl from "@onflow/fcl";_30import { encodeTxIdFromVoucher } from "@onflow/sdk"_30_30// Create a voucher (usually done internally by FCL)_30const 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_30const txId = encodeTxIdFromVoucher(voucher);_30console.log("Transaction ID:", txId);_30// Returns a transaction ID that can be used to track the transaction
Parameters
voucher
- Type:
Voucher
- Description: The voucher object containing transaction details
_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}
Returns
string