Skip to main content

createSignableVoucher

Creates a signable voucher object from an interaction for signing purposes.

A voucher is a standardized representation of a transaction that contains all the necessary information for signing and submitting to the Flow network. This function transforms an interaction object into a voucher format.

Import

You can import the entire package and access the function:


_10
import * as sdk from "@onflow/sdk"
_10
_10
sdk.createSignableVoucher(ix)

Or import directly the specific function:


_10
import { createSignableVoucher } from "@onflow/sdk"
_10
_10
createSignableVoucher(ix)

Usage


_27
import * as fcl from "@onflow/fcl";
_27
import { createSignableVoucher } from "@onflow/sdk"
_27
_27
// Build a transaction interaction
_27
const interaction = await fcl.build([
_27
fcl.transaction`
_27
transaction(amount: UFix64) {
_27
prepare(account: AuthAccount) {
_27
log(amount)
_27
}
_27
}
_27
`,
_27
fcl.args([fcl.arg("10.0", fcl.t.UFix64)]),
_27
fcl.proposer(proposerAuthz),
_27
fcl.payer(payerAuthz),
_27
fcl.authorizations([authorizerAuthz]),
_27
fcl.limit(100)
_27
]);
_27
_27
// Create a voucher for signing
_27
const voucher = createSignableVoucher(interaction);
_27
console.log(voucher.cadence); // The Cadence script
_27
console.log(voucher.arguments); // The transaction arguments
_27
console.log(voucher.proposalKey); // Proposer account details
_27
console.log(voucher.authorizers); // List of authorizer addresses
_27
_27
// The voucher can now be signed and submitted

Parameters

ix

  • Type: Interaction
  • Description: The interaction object containing transaction details

Returns

{ cadence: string; refBlock: string; computeLimit: number; arguments: any[]; proposalKey: { address: string; keyId: string | number; sequenceNum: number; } | { address?: undefined; keyId?: undefined; sequenceNum?: undefined; }; payer: string; authorizers: string[]; payloadSigs: { address: string; keyId: string | number; sig: string; }[]; envelopeSigs: { address: string; keyId: string | number; sig: string; }[]; }


Rate this page