serialize
Serializes a Flow transaction or script to a JSON-formatted signable voucher that can be used for offline signing or inspection. This is useful for creating signable transactions that can be signed by external wallets or hardware devices.
Import
You can import the entire package and access the function:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.serialize(args, opts)
Or import directly the specific function:
_10import { serialize } from "@onflow/fcl-core"_10_10serialize(args, opts)
Usage
_19// Serialize a simple transaction_19import * as fcl from "@onflow/fcl"_19_19const voucher = await fcl.serialize([_19 fcl.transaction`_19 transaction(amount: UFix64, to: Address) {_19 prepare(signer: AuthAccount) {_19 // Transaction logic here_19 }_19 }_19 `,_19 fcl.args([_19 fcl.arg("10.0", fcl.t.UFix64),_19 fcl.arg("0x01", fcl.t.Address)_19 ]),_19 fcl.proposer(authz),_19 fcl.payer(authz),_19 fcl.authorizations([authz])_19])
Parameters
args
- Type:
(false
|InteractionBuilderFn)[]
|Interaction
- Description: Array of interaction builder functions or a pre-built interaction object. Builder functions are typically from
opts
(optional)
- Type:
_10export interface SerializeOptions {_10 resolve?: InteractionBuilderFn_10}
- Description: Optional configuration object
Returns
Promise<string>
A JSON string representation of the signable voucher that contains all the transaction details needed for signing