Skip to main content

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:


_10
import * as sdk from "@onflow/sdk"
_10
_10
sdk.authorizations(ax)

Or import directly the specific function:


_10
import { authorizations } from "@onflow/sdk"
_10
_10
authorizations(ax)

Usage


_40
import * as fcl from "@onflow/fcl";
_40
_40
// Single authorizer (most common case)
_40
await 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
_40
await 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
_40
await 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: AccountAuthorization[]
  • Description: An array of authorization functions that produce account authorization details

_10
export type AccountAuthorization =
_10
| (AuthorizationFn & Partial<InteractionAccount>)
_10
| Partial<InteractionAccount>

Returns

InteractionBuilderFn


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


Rate this page