{"record":{"id":"74ca8da4ee5b387f","repo":"FuelLabs/fuels-ts","slug":"function-not-found","errorCode":"FUNCTION_NOT_FOUND","errorMessage":"function ${nameOrSignatureOrSelector} not found: ${JSON.stringify(fn)}.","messagePattern":"function (.+?) not found: (.+?)\\.","errorType":"error_code","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/abi-coder/src/Interface.ts","lineNumber":49,"sourceCode":"  }\n\n  /**\n   * Returns function fragment for a dynamic input.\n   * @param nameOrSignatureOrSelector - name (e.g. 'transfer'), signature (e.g. 'transfer(address,uint256)') or selector (e.g. '0x00000000a9059cbb') of the function fragment\n   */\n  getFunction(nameOrSignatureOrSelector: string): FunctionFragment {\n    const fn = Object.values<FunctionFragment>(this.functions).find(\n      (f) =>\n        f.name === nameOrSignatureOrSelector ||\n        f.signature === nameOrSignatureOrSelector ||\n        f.selector === nameOrSignatureOrSelector\n    );\n\n    if (fn !== undefined) {\n      return fn;\n    }\n\n    throw new FuelError(\n      ErrorCode.FUNCTION_NOT_FOUND,\n      `function ${nameOrSignatureOrSelector} not found: ${JSON.stringify(fn)}.`\n    );\n  }\n\n  // Decode the result of a function call\n  decodeFunctionResult(functionFragment: FunctionFragment | string, data: BytesLike): any {\n    const fragment =\n      typeof functionFragment === 'string' ? this.getFunction(functionFragment) : functionFragment;\n\n    return fragment.decodeOutput(data);\n  }\n\n  decodeLog(data: BytesLike, logId: string): any {\n    const loggedType = this.jsonAbiOld.loggedTypes.find((type) => type.logId === logId);\n    if (!loggedType) {\n      throw new FuelError(\n        ErrorCode.LOG_TYPE_NOT_FOUND,","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/abi-coder/src/Interface.ts#L31-L67","documentation":"Thrown by `Interface.getFunction` (code `FUNCTION_NOT_FOUND`) when no function in the parsed ABI matches the supplied `nameOrSignatureOrSelector` by name, full signature, or 4-byte selector. The lookup walks `this.functions` (built from the ABI) and falls back to this error if nothing matches.","triggerScenarios":"Calling `interface.getFunction('typoName')`, passing a selector computed from an outdated ABI, or using a full signature whose input types do not exactly match the ABI (including whitespace/casing).","commonSituations":"ABI regenerated after a rename and call sites still use the old name; manually typed selector string from a different contract; copy-paste of a signature with different type formatting (e.g. `u32` vs `uint32`).","solutions":["Inspect `Object.keys(interface.functions)` and use an exact name/selector/signature from the list.","Regenerate types with `fuels typegen` and rely on the generated `contract.functions.<name>` accessor instead of string lookups.","If using a selector, recompute it from the current ABI via `FunctionFragment.getFunctionSelector`.","For signature lookups, ensure the signature string matches `name(type1,type2)` exactly — no spaces, correct Sway type names."],"exampleFix":"// before\nconst fn = iface.getFunction('transfer'); // ABI name is 'transfer_to'\n// after\nconst fn = iface.getFunction('transfer_to');\n// or, preferred:\nconst fn = contract.functions.transfer_to.fragment;","handlingStrategy":"type-guard","validationCode":"// check before lookup\nconst known = Object.values(iface.functions).some(\n  (f) => f.name === key || f.signature === key || f.selector === key\n);\nif (!known) throw new Error(`Unknown function key: ${key}`);","typeGuard":"function hasFunction(iface, key) {\n  return Object.values(iface.functions).some(\n    (f) => f.name === key || f.signature === key || f.selector === key\n  );\n}","tryCatchPattern":"try {\n  const fn = iface.getFunction(key);\n} catch (e) {\n  if (e.code === 'FUNCTION_NOT_FOUND') {\n    console.error('Valid keys:', Object.keys(iface.functions));\n  }\n  throw e;\n}","preventionTips":["Prefer generated `contract.functions.<name>` accessors over string lookups.","Regenerate bindings after any rename so stale names surface at compile time.","When using selectors/signatures, derive them from the current ABI rather than hardcoding."],"tags":["abi-coder","interface","function-lookup","abi-mismatch"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}