Skip to main content

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:


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

Or import directly the specific function:


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

Usage


_24
import * as fcl from "@onflow/fcl";
_24
_24
await 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
_24
await 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


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


Rate this page