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


_41
import * as fcl from '@onflow/fcl';
_41
_41
// Basic transaction usage
_41
await 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
_41
await 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
_41
await 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


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

A function that processes an interaction object


Rate this page