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
- Read the exact message in the thrown error to identify which assertion failed.
- For 'Wallet is required!', pass an account when constructing the Contract: new Contract(id, abi, account).
- 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
- Always pass a non-null account when constructing a Contract you will call.
- Satisfy documented preconditions (wallet, params) before calling SDK methods.
- Treat the message text as the authoritative description for this generic guard.
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
- INVALID_TRANSACTION_INPUT
- INVALID_TRANSACTION_INPUT
- Witness at index "${index}" was not found
- NOT_IMPLEMENTED
- UNSUPPORTED_TRANSACTION_TYPE
AI-assisted analysis of FuelLabs/fuels-ts@b3f37c91ac (2026-08-12).
Data as JSON: /api/errors/26bf222ab5e845fa.
Report an issue: GitHub.