transaction
A template builder to use a Cadence transaction for an interaction. FCL "mutate" does the work of building, signing, and sending a transaction behind the scenes.
Flow supports great flexibility when it comes to transaction signing, we can define multiple authorizers (multi-sig transactions) and have different payer account than proposer.
Import
You can import the entire package and access the function:
_10import * as sdk from "@onflow/sdk"_10_10sdk.transaction(args)
Or import directly the specific function:
_10import { transaction } from "@onflow/sdk"_10_10transaction(args)
Usage
_43import * as fcl from "@onflow/fcl"_43_43// Basic transaction usage_43await fcl.mutate({_43  cadence: `_43    transaction(a: Int) {_43      prepare(acct: &Account) {_43        log(acct)_43        log(a)_43      }_43    }_43  `,_43  args: (arg, t) => [_43    arg(6, t.Int)_43  ],_43  limit: 50_43})_43_43// Single party, single signature_43// Proposer, payer and authorizer are the same account_43await fcl.mutate({_43  cadence: `_43    transaction {_43      prepare(acct: &Account) {}_43    }_43  `,_43  authz: currentUser, // Optional. Will default to currentUser if not provided._43  limit: 50,_43})_43_43// Multiple parties_43// Proposer and authorizer are the same account, but different payer_43await fcl.mutate({_43  cadence: `_43    transaction {_43      prepare(acct: &Account) {}_43    }_43  `,_43  proposer: authzFn,_43  payer: authzTwoFn,_43  authorizations: [authzFn],_43  limit: 50,_43})
Parameters
args (optional)
- Type:
_10[string | TemplateStringsArray, ...any[]]
- Description: The arguments to pass to the template
Returns
_10export type InteractionBuilderFn = (_10  ix: Interaction_10) => Interaction | Promise<Interaction>
A function that processes an interaction object