LLM Notice: This documentation site supports content negotiation for AI agents. Request any page with Accept: text/markdown or Accept: text/plain header to receive Markdown instead of HTML. Alternatively, append ?format=md to any URL. All markdown files are available at /md/ prefix paths. For all content in one file, visit /llms-full.txt
Skip to main content

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:


_10
import * as fcl from "@onflow/fcl"
_10
_10
fcl.serialize(args, opts)

Or import directly the specific function:


_10
import { serialize } from "@onflow/fcl"
_10
_10
serialize(args, opts)

Usage​


_19
// Serialize a simple transaction
_19
import * as fcl from "@onflow/fcl"
_19
_19
const 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:

_10
export interface SerializeOptions {
_10
resolve?: InteractionBuilderFn
_10
}

  • Description: Optional configuration object

Properties:​

  • resolve - Custom resolve function to use instead of the default

Returns​

Promise<string>

A JSON string representation of the signable voucher that contains all the transaction details needed for signing


Rate this page