authorizations
A utility builder to set the authorizations on a transaction.
Authorizations define the accounts that are responsible for paying the transaction fees and providing signatures for the transaction. You can have multiple authorizers in a single transaction (multi-signature transactions).
Read more about transaction roles and signing transactions.
Import
You can import the entire package and access the function:
_10import * as fcl from '@onflow/fcl';_10_10fcl.authorizations(ax);
Or import directly the specific function:
_10import { authorizations } from '@onflow/fcl';_10_10authorizations(ax);
Usage
_40import * as fcl from '@onflow/fcl';_40_40// Single authorizer (most common case)_40await fcl.mutate({_40 cadence: `_40 transaction {_40 prepare(acct: AuthAccount) {_40 log("Hello from: ".concat(acct.address.toString()))_40 }_40 }_40 `,_40 authorizations: [fcl.authz], // Current user authorization_40});_40_40// Multiple authorizers - both accounts must approve_40await fcl.mutate({_40 cadence: `_40 transaction {_40 prepare(acct1: AuthAccount, acct2: AuthAccount) {_40 log("Transaction signed by both accounts")_40 }_40 }_40 `,_40 authorizations: [userOneAuthz, userTwoAuthz],_40});_40_40// Using builder pattern_40await fcl.send([_40 fcl.transaction`_40 transaction {_40 prepare(acct: AuthAccount) {_40 acct.save("Hello, World!", to: /storage/greeting)_40 }_40 }_40 `,_40 fcl.authorizations([fcl.authz]),_40 fcl.proposer(fcl.authz),_40 fcl.payer(fcl.authz),_40 fcl.limit(100),_40]);
Parameters
ax
(optional)
- Type:
_10export type AccountAuthorization =_10 | (AuthorizationFn & Partial<InteractionAccount>)_10 | Partial<InteractionAccount>;
- Description: An array of authorization functions that produce account authorization details
Returns
_10export type InteractionBuilderFn = (_10 ix: Interaction,_10) => Interaction | Promise<Interaction>;
A function that processes an interaction object