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:
_10import * as fcl from "@onflow/fcl"_10_10fcl.createSignableVoucher(ix)
Or import directly the specific function:
_10import { createSignableVoucher } from "@onflow/fcl"_10_10createSignableVoucher(ix)
Usage
_27import * as fcl from "@onflow/fcl";_27import { createSignableVoucher } from "@onflow/sdk"_27_27// Build a transaction interaction_27const 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_27const voucher = createSignableVoucher(interaction);_27console.log(voucher.cadence); // The Cadence script_27console.log(voucher.arguments); // The transaction arguments_27console.log(voucher.proposalKey); // Proposer account details_27console.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