{"record":{"id":"5b0b52fa09f82d90","repo":"FuelLabs/fuels-ts","slug":"script-reverted-5b0b52","errorCode":"SCRIPT_REVERTED","errorMessage":"Transaction reverted.","messagePattern":"Transaction reverted\\.","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/program/src/script-request.ts","lineNumber":78,"sourceCode":"    | TransactionResultReturnReceipt\n    | TransactionResultReturnDataReceipt\n    | TransactionResultRevertReceipt\n    | undefined;\n\n  receipts.forEach((receipt) => {\n    if (receipt.type === ReceiptType.ScriptResult) {\n      scriptResultReceipt = receipt;\n    } else if (\n      receipt.type === ReceiptType.Return ||\n      receipt.type === ReceiptType.ReturnData ||\n      receipt.type === ReceiptType.Revert\n    ) {\n      returnReceipt = receipt;\n    }\n  });\n\n  if (!scriptResultReceipt || !returnReceipt) {\n    throw new FuelError(ErrorCode.SCRIPT_REVERTED, `Transaction reverted.`);\n  }\n\n  const scriptResult: ScriptResult = {\n    code: scriptResultReceipt.result,\n    gasUsed: scriptResultReceipt.gasUsed,\n    receipts,\n    scriptResultReceipt,\n    returnReceipt,\n    callResult,\n  };\n\n  return scriptResult;\n}\n\ntype DecodeCallResultParams<TResult> = {\n  callResult: CallResult;\n  scriptResultDecoder: (scriptResult: ScriptResult) => TResult;\n  logs?: DecodedLogs['logs'];","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/program/src/script-request.ts#L60-L96","documentation":"Thrown by getScriptResult() when, after scanning all receipts, it could not find both a ScriptResult receipt and a Return/ReturnData/Revert receipt. A well-formed script execution must produce a return receipt and a script-result receipt; their absence means the receipt set is incomplete or malformed, not that the script ran and reverted (that is a separate code path).","triggerScenarios":"Processing a receipt array from a dryRun/submit where the node returned partial receipts; a receipt set containing only message/log receipts and no ScriptResult; manual construction of a CallResult with incomplete receipts; node/SDK consensus-parameter skew that changes receipt emission.","commonSituations":"Intercepting and trimming receipts before decoding; a transaction that was squeezed out or timed out so receipts are missing; mocking the provider's call result without a ScriptResult receipt.","solutions":["Log/inspect the full `receipts` array to confirm which receipt type is missing.","Ensure the transaction actually reached the ScriptResult stage (check the transaction status / submit response) before decoding.","Verify the SDK version matches the node's consensus parameters / Fuel Core version."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import { ReceiptType } from '@fuel-ts/transactions';\n\nfunction hasCompleteReceipts(receipts: any[]): boolean {\n  return receipts.some(r => r.type === ReceiptType.ScriptResult)\n    && receipts.some(r => [ReceiptType.Return, ReceiptType.ReturnData, ReceiptType.Revert].includes(r.type));\n}","typeGuard":"function isCompleteReceiptSet(receipts: any[]): boolean {\n  return receipts.some(r => r.type === ReceiptType.ScriptResult)\n    && receipts.some(r => [ReceiptType.Return, ReceiptType.ReturnData, ReceiptType.Revert].includes(r.type));\n}","tryCatchPattern":"try {\n  const res = getScriptResult(receipts, callResult);\n} catch (e) {\n  if (e instanceof FuelError && e.code === ErrorCode.SCRIPT_REVERTED && /Transaction reverted/.test(e.message)) {\n    console.error('Incomplete receipts:', receipts);\n    // verify tx status / node connectivity before retrying\n  } else throw e;\n}","preventionTips":["Do not strip or filter receipts before decoding.","Verify the transaction reached a final state with a ScriptResult before decoding.","Keep SDK and node versions aligned."],"tags":["receipts","script","transaction","typescript"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}