{"record":{"id":"73969a8a7fa356fa","repo":"FuelLabs/fuels-ts","slug":"abi-main-method-missing","errorCode":"ABI_MAIN_METHOD_MISSING","errorMessage":"ABI doesn't have a 'main()' method.","messagePattern":"ABI doesn't have a 'main\\(\\)' method\\.","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/abi-typegen/src/templates/predicate/main.ts","lineNumber":30,"sourceCode":"\nexport function renderMainTemplate(params: { abi: Abi; versions: BinaryVersions }) {\n  const { abi, versions } = params;\n\n  const { types, configurables } = abi;\n\n  const {\n    rawContents,\n    capitalizedName,\n    hexlifiedBinContents: hexlifiedBinString,\n    commonTypesInUse,\n  } = params.abi;\n\n  const abiJsonString = JSON.stringify(rawContents, null, 2);\n\n  const func = abi.functions.find((f) => f.name === 'main');\n\n  if (!func) {\n    throw new FuelError(ErrorCode.ABI_MAIN_METHOD_MISSING, `ABI doesn't have a 'main()' method.`);\n  }\n\n  const { enums } = formatEnums({ types });\n  const { structs } = formatStructs({ types });\n  const { imports } = formatImports({\n    types,\n    baseMembers: [\n      'Predicate as __Predicate',\n      'Provider',\n      'InputValue',\n      'PredicateParams',\n      'decompressBytecode',\n    ],\n  });\n\n  const { prefixedInputs: inputs, output } = func.attributes;\n\n  const text = renderHbsTemplate({","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/abi-typegen/src/templates/predicate/main.ts#L12-L48","documentation":"The predicate template requires the ABI to declare a `main` function (the predicate entrypoint). abi.functions.find(f => f.name === 'main') returning undefined means the ABI cannot be turned into a predicate, since the predicate's configurable inputs are derived from main's parameters.","triggerScenarios":"Running typegen with programType=PREDICATE against an ABI whose functions array has no entry named exactly 'main'; using a contract ABI by mistake for predicate generation.","commonSituations":"Wrong programType for the supplied ABI (contract ABI used as predicate); Sway predicate whose entrypoint was renamed away from `main`; ABI for an older predicate that used a different entrypoint name.","solutions":["Verify the ABI is a predicate ABI and contains a function named exactly 'main'.","Recompile the Sway predicate with `forc build` (predicates emit a main function) and regenerate the ABI.","Ensure programType passed to typegen matches the actual ABI kind."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function assertPredicateMain(abi: JsonAbi) {\n  if (!abi.functions.some(f => f.name === 'main')) {\n    throw new Error('predicate ABI must declare a main() function');\n  }\n}","typeGuard":"function isPredicateAbi(abi: JsonAbi): boolean {\n  return abi.functions.some(f => f.name === 'main');\n}","tryCatchPattern":null,"preventionTips":["Confirm the ABI is a predicate ABI before generating predicate bindings.","Recompile the Sway predicate so it emits a `main` entrypoint.","Match programType to the actual ABI kind."],"tags":["typegen","predicate","abi-main-method-missing","abi-validation"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}