Skip to main content

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:


_10
import * as sdk from "@onflow/sdk"
_10
_10
sdk.transaction(args)

Or import directly the specific function:


_10
import { transaction } from "@onflow/sdk"
_10
_10
transaction(args)

Usage


_43
import * as fcl from "@onflow/fcl"
_43
_43
// Basic transaction usage
_43
await 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
_43
await 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
_43
await 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: [string | TemplateStringsArray, ...any[]]
  • Description: The arguments to pass to the template

Returns

InteractionBuilderFn


_10
export type InteractionBuilderFn = (
_10
ix: Interaction
_10
) => Interaction | Promise<Interaction>


Rate this page