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
_41import * as fcl from '@onflow/fcl';_41_41// Basic transaction usage_41await fcl.mutate({_41 cadence: `_41 transaction(a: Int) {_41 prepare(acct: &Account) {_41 log(acct)_41 log(a)_41 }_41 }_41 `,_41 args: (arg, t) => [arg(6, t.Int)],_41 limit: 50,_41});_41_41// Single party, single signature_41// Proposer, payer and authorizer are the same account_41await fcl.mutate({_41 cadence: `_41 transaction {_41 prepare(acct: &Account) {}_41 }_41 `,_41 authz: currentUser, // Optional. Will default to currentUser if not provided._41 limit: 50,_41});_41_41// Multiple parties_41// Proposer and authorizer are the same account, but different payer_41await fcl.mutate({_41 cadence: `_41 transaction {_41 prepare(acct: &Account) {}_41 }_41 `,_41 proposer: authzFn,_41 payer: authzTwoFn,_41 authorizations: [authzFn],_41 limit: 50,_41});
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