Skip to main content

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:


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

Or import directly the specific function:


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

Usage


_39
import * as fcl from "@onflow/fcl";
_39
_39
// Using current user as payer (most common case)
_39
await 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
_39
await 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)
_39
await 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

_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