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: Voucher
  • Description: The voucher object containing transaction details

_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