payer
A builder function that adds payer account(s) to a transaction.
Every transaction requires at least one payer.
The payer is the account that pays the transaction fee for executing the transaction on the network. The payer account must have sufficient Flow tokens to cover the transaction fees.
Read more about transaction roles and transaction fees.
Import
You can import the entire package and access the function:
_10import * as sdk from "@onflow/sdk"_10_10sdk.payer(ax)
Or import directly the specific function:
_10import { payer } from "@onflow/sdk"_10_10payer(ax)
Usage
_39import * as fcl from "@onflow/fcl";_39_39// Using current user as payer (most common case)_39await fcl.mutate({_39 cadence: `_39 transaction {_39 prepare(acct: AuthAccount) {_39 log("Transaction fees paid by: ".concat(acct.address.toString()))_39 }_39 }_39 `,_39 payer: fcl.authz // Current user as payer_39});_39_39// Using custom payer with builder pattern_39await fcl.send([_39 fcl.transaction`_39 transaction {_39 prepare(acct: AuthAccount) {_39 // Transaction logic_39 }_39 }_39 `,_39 fcl.proposer(fcl.authz), // Current user as proposer_39 fcl.authorizations([fcl.authz]), // Current user as authorizer_39 fcl.payer(customPayerAuthz) // Custom payer pays fees_39]);_39_39// Multiple payers (advanced use case)_39await fcl.send([_39 fcl.transaction`_39 transaction {_39 prepare(acct: AuthAccount) {_39 // Transaction logic_39 }_39 }_39 `,_39 fcl.payer([payerAuthz1, payerAuthz2]) // Multiple payers split fees_39]);
Parameters
ax
(optional)
- Type:
AccountAuthorization[]
- Description: An account address or an array of account addresses
_10export type AccountAuthorization =_10 | (AuthorizationFn & Partial<InteractionAccount>)_10 | Partial<InteractionAccount>
Returns
InteractionBuilderFn
_10export type InteractionBuilderFn = (_10 ix: Interaction_10) => Interaction | Promise<Interaction>