build
A builder function that creates an interaction from an array of builder functions.
The build function takes an array of builder functions and applies them to create a complete interaction object. This is the foundation for constructing all interactions in Flow, whether they're scripts, transactions, or queries.
Each builder function modifies specific parts of the interaction object, such as adding Cadence code, arguments, authorization details, or other configuration.
Import
You can import the entire package and access the function:
_10import * as sdk from "@onflow/sdk"_10_10sdk.build(fns)
Or import directly the specific function:
_10import { build } from "@onflow/sdk"_10_10build(fns)
Usage
_30import * as fcl from "@onflow/fcl";_30_30// Build a script interaction_30const scriptInteraction = await fcl.build([_30 fcl.script`_30 access(all) fun main(a: Int, b: Int): Int {_30 return a + b_30 }_30 `,_30 fcl.args([_30 fcl.arg(1, fcl.t.Int),_30 fcl.arg(2, fcl.t.Int)_30 ])_30]);_30_30// Build a transaction interaction_30const txInteraction = await fcl.build([_30 fcl.transaction`_30 transaction(name: String) {_30 prepare(account: AuthAccount) {_30 log("Hello, " + name)_30 }_30 }_30 `,_30 fcl.args([fcl.arg("World", fcl.t.String)]),_30 fcl.proposer(proposerAuthz),_30 fcl.payer(payerAuthz),_30 fcl.authorizations([authorizerAuthz]),_30 fcl.limit(100)_30]);
Parameters
fns
(optional)
- Type:
(false | InteractionBuilderFn)[]
- Description: The functions to apply to the interaction