{"record":{"id":"26bf222ab5e845fa","repo":"FuelLabs/fuels-ts","slug":"transaction-error-26bf22","errorCode":"TRANSACTION_ERROR","errorMessage":"${message}","messagePattern":"\\$\\{message\\}","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/program/src/utils.ts","lineNumber":14,"sourceCode":"import { getAllDecodedLogs, getDecodedLogs } from '@fuel-ts/account';\nimport type { TransactionResultReceipt, JsonAbisFromAllCalls, DecodedLogs } from '@fuel-ts/account';\nimport { ErrorCode, FuelError } from '@fuel-ts/errors';\n\nimport type { AbstractContract, CallConfig, InvocationScopeLike } from './types';\n\n/**\n * @hidden\n *\n * Generic assert function to avoid undesirable errors\n */\nexport function assert(condition: unknown, message: string): asserts condition {\n  if (!condition) {\n    throw new FuelError(ErrorCode.TRANSACTION_ERROR, message);\n  }\n}\n\n/**\n * @hidden\n *\n * Gets the ABI from an array of InvocationScopeLike.\n */\nexport function getAbisFromAllCalls(\n  functionScopes: Array<InvocationScopeLike>\n): JsonAbisFromAllCalls {\n  return functionScopes.reduce((acc, funcScope, i) => {\n    const { program, externalAbis } = funcScope.getCallConfig();\n\n    if (i === 0) {\n      acc.main = program.interface.jsonAbi;\n      acc.otherContractsAbis = {};\n    } else {","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/program/src/utils.ts#L1-L32","documentation":"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).","triggerScenarios":"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.","commonSituations":"Invoking a contract function without binding a wallet/account to the contract; passing null txParameters; partial construction of an invocation scope.","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."],"exampleFix":"// before\nconst contract = new Contract(id, abi, undefined as any);\nawait contract.functions.fn().simulate();\n\n// after\nconst contract = new Contract(id, abi, unlockedWallet);\nawait contract.functions.fn().simulate();","handlingStrategy":"validation","validationCode":"// Generic precondition guard — read the message to know which assert failed.\n// Example for the wallet precondition:\nif (!contract.account) {\n  throw new Error('Bind an account/wallet to the Contract before invoking functions.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await contract.functions.fn().simulate();\n} catch (e) {\n  if (e instanceof FuelError && e.code === ErrorCode.TRANSACTION_ERROR) {\n    // branch on e.message to handle the specific precondition\n  } else throw e;\n}","preventionTips":["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."],"tags":["assertion","precondition","transaction","typescript"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}