limit
A utility builder to set the compute limit on a transaction.
The compute limit is the maximum amount of computation that can be performed during transaction execution. Setting an appropriate compute limit helps prevent infinite loops and ensures predictable transaction costs.
Read more about computation cost and transaction fees.
Import
You can import the entire package and access the function:
_10import * as sdk from "@onflow/sdk"_10_10sdk.limit(limit)
Or import directly the specific function:
_10import { limit } from "@onflow/sdk"_10_10limit(limit)
Usage
_24import * as fcl from "@onflow/fcl";_24_24await fcl.mutate({_24 cadence: `_24 transaction {_24 prepare(account: AuthAccount) {_24 // Complex transaction logic here_24 }_24 }_24 `,_24 limit: 1000 // Set compute limit to 1000_24});_24_24// Using builder pattern_24await fcl.send([_24 fcl.transaction`_24 transaction {_24 prepare(account: AuthAccount) {_24 // Transaction logic_24 }_24 }_24 `,_24 fcl.limit(9999) // Set higher limit for complex operations_24]);
Parameters
limit
- Type:
number
- Description: The maximum amount of computation for the transaction
Returns
InteractionBuilderFn
_10export type InteractionBuilderFn = (_10 ix: Interaction_10) => Interaction | Promise<Interaction>