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 fcl from "@onflow/fcl"
_10
_10
fcl.createSignableVoucher(ix)

Or import directly the specific function:


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


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

A voucher object containing all transaction data and signatures


Rate this page