Skip to main content

ref

A builder function that sets the reference block for a transaction.

The reference block specifies an expiration window (measured in blocks) during which a transaction is considered valid by the network. A transaction will be rejected if it is submitted past its expiry block. Flow calculates transaction expiry using the reference block field.

Import

You can import the entire package and access the function:


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

Or import directly the specific function:


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

Usage


_20
import * as fcl from "@onflow/fcl";
_20
_20
// Set specific reference block for transaction
_20
await fcl.send([
_20
fcl.transaction`
_20
transaction {
_20
prepare(account: AuthAccount) {
_20
log("Transaction with custom reference block")
_20
}
_20
}
_20
`,
_20
fcl.ref("a1b2c3d4e5f6789..."), // Custom reference block ID
_20
fcl.proposer(fcl.authz),
_20
fcl.payer(fcl.authz),
_20
fcl.authorizations([fcl.authz]),
_20
fcl.limit(100)
_20
]);
_20
_20
// Usually, you don't need to set reference block manually
_20
// as FCL will automatically set it to the latest block

Parameters

refBlock

  • Type: string
  • Description: The reference block ID

Returns

InteractionBuilderFn


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


Rate this page