Skip to content

โฑ Scheduling Transactions with Time Bounds

MEE supports time-bounded execution windows using lowerBoundTimestamp and upperBoundTimestamp. These parameters let you defer execution or enforce expiration on quotes, enabling powerful UX like scheduled actions, delayed bridging, market timing, and more.

๐Ÿš€ Why Use Time Bounds?

  • Scheduled execution (e.g. trigger after a certain amount of time)
  • Custom expiry (e.g. keep trying to execute for five minutes, if simulation is error still - then discard)
  • Sequential execution (e.g. execute a transaction every five minutes)

๐Ÿ›  Setup

import { createMeeClient, toMultichainNexusAccount } from "@biconomy/abstractjs";
import { http, type Hex } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { base, optimism } from "viem/chains";
 
const eoa = privateKeyToAccount(Bun.env.PRIVATE_KEY as Hex);
const orchestrator = await toMultichainNexusAccount({
  chains: [optimism, base],
  transports: [http(), http()],
  signer: eoa
});
 
const date = new Date();
 
const meeClient = await createMeeClient({
  account: orchestrator
});
 
const minutesToSeconds = (input: number) => input * 60;

โšก Instant Execution (Default Expiry)

Executes immediately and simulates until it passes or hits a 2-minute timeout.

const instantTxDefaultExpiryTime = await meeClient.getQuote({
  instructions: [],
  feeToken: {
    address: '0xYourFeeTokenAddress',
    chainId: base.id
  },
});

โšก Instant Execution with Custom Expiry

Runs immediately but expires 1 minute after quote creation if it still errors.

const instantTxCustomExpiry = await meeClient.getQuote({
  instructions: [],
  feeToken: {
    address: '0xYourFeeTokenAddress',
    chainId: base.id
  },
  upperBoundTimestamp: Date.now() + minutesToSeconds(1)
});

โณ Scheduled Execution

Quote wonโ€™t be eligible to run until 5 minutes from now.

const scheduledTxQuote = await meeClient.getQuote({
  instructions: [],
  feeToken: {
    address: '0xYourFeeTokenAddress',
    chainId: base.id
  },
  lowerBoundTimestamp: Date.now() + minutesToSeconds(5)
});

๐Ÿ“‰ Bounded Window Execution

Will only attempt execution between 2 and 5 minutes from quote creation.

const boundedTx = await meeClient.getQuote({
  instructions: [],
  feeToken: {
    address: '0xYourFeeTokenAddress',
    chainId: base.id
  },
  lowerBoundTimestamp: Date.now() + minutesToSeconds(2),
  upperBoundTimestamp: Date.now() + minutesToSeconds(5)
});

๐Ÿง  Developer Tips

  • Timestamps are expected in seconds, not milliseconds.
  • Quotes simulate continuously within the window. If execution fails for the full duration, they will revert.
  • If both lowerBoundTimestamp and upperBoundTimestamp are omitted, quotes execute immediately with a 2-minute fallback.
  • Use in combination with cleanup for robust, failure-tolerant flows.

Time-bounded scheduling unlocks a whole new level of control over supertransactionsโ€”giving developers precision orchestration primitives without needing custom schedulers or off-chain cron jobs.