FuelLabs/fuels-ts · error · FuelError

TRANSACTION_ERROR

TRANSACTION_ERROR

Error message

${message}

What it means

Generic assertion helper used throughout the program package: assert(condition, message) throws a FuelError with code TRANSACTION_ERROR and the supplied message when condition is falsy. It is not a single error but a precondition guard; the real meaning is carried by the message argument (e.g. 'Wallet is required!' at base-invocation-scope.ts:552).

Source

Thrown at packages/program/src/utils.ts:14

import { getAllDecodedLogs, getDecodedLogs } from '@fuel-ts/account';
import type { TransactionResultReceipt, JsonAbisFromAllCalls, DecodedLogs } from '@fuel-ts/account';
import { ErrorCode, FuelError } from '@fuel-ts/errors';

import type { AbstractContract, CallConfig, InvocationScopeLike } from './types';

/**
 * @hidden
 *
 * Generic assert function to avoid undesirable errors
 */
export function assert(condition: unknown, message: string): asserts condition {
  if (!condition) {
    throw new FuelError(ErrorCode.TRANSACTION_ERROR, message);
  }
}

/**
 * @hidden
 *
 * Gets the ABI from an array of InvocationScopeLike.
 */
export function getAbisFromAllCalls(
  functionScopes: Array<InvocationScopeLike>
): JsonAbisFromAllCalls {
  return functionScopes.reduce((acc, funcScope, i) => {
    const { program, externalAbis } = funcScope.getCallConfig();

    if (i === 0) {
      acc.main = program.interface.jsonAbi;
      acc.otherContractsAbis = {};
    } else {

View on GitHub (pinned to b3f37c91ac)

Solutions

  1. Read the exact message in the thrown error to identify which assertion failed.
  2. For 'Wallet is required!', pass an account when constructing the Contract: new Contract(id, abi, account).
  3. Ensure all required arguments/objects are non-null before invoking the SDK method.

Example fix

// before
const contract = new Contract(id, abi, undefined as any);
await contract.functions.fn().simulate();

// after
const contract = new Contract(id, abi, unlockedWallet);
await contract.functions.fn().simulate();
Defensive patterns

Strategy: validation

Validate before calling

// Generic precondition guard — read the message to know which assert failed.
// Example for the wallet precondition:
if (!contract.account) {
  throw new Error('Bind an account/wallet to the Contract before invoking functions.');
}

Try / catch

try {
  await contract.functions.fn().simulate();
} catch (e) {
  if (e instanceof FuelError && e.code === ErrorCode.TRANSACTION_ERROR) {
    // branch on e.message to handle the specific precondition
  } else throw e;
}

Prevention

When it happens

Trigger: Any failed precondition routed through assert(): calling simulate()/fund without a bound account (this.program.account is undefined); passing undefined where a required object is expected; other internal invariants in the program/script packages.

Common situations: Invoking a contract function without binding a wallet/account to the contract; passing null txParameters; partial construction of an invocation scope.

Related errors


AI-assisted analysis of FuelLabs/fuels-ts@b3f37c91ac (2026-08-12). Data as JSON: /api/errors/26bf222ab5e845fa. Report an issue: GitHub.