FuelLabs/fuels-ts · error · FuelError

FUNCTION_NOT_FOUND

FUNCTION_NOT_FOUND

Error message

Function with name '${name}' doesn't exist in the ABI

What it means

findFunctionByName linearly searches abi.functions for an entry whose name equals the supplied string. A miss means the requested function is not declared in the loaded ABI, so the SDK cannot resolve its input/output coders or encode a call to it.

Source

Thrown at packages/abi-coder/src/utils/json-abi.ts:40

    default:
      throw new FuelError(
        ErrorCode.UNSUPPORTED_ENCODING_VERSION,
        `Encoding version '${encoding}' is unsupported.`
      );
  }
};

/**
 * Find a function by name in the ABI.
 *
 * @param abi - the JsonAbi object
 * @param name - the name of the function to find
 * @returns the JsonAbi function object
 */
export const findFunctionByName = (abi: JsonAbi, name: string): AbiFunction => {
  const fn = abi.functions.find((f) => f.name === name);
  if (!fn) {
    throw new FuelError(
      ErrorCode.FUNCTION_NOT_FOUND,
      `Function with name '${name}' doesn't exist in the ABI`
    );
  }
  return fn;
};

/**
 * Find a type by its typeId in the ABI.
 *
 * @param abi - the JsonAbi object
 * @param typeId - the typeId of the type to find
 * @returns the JsonAbi type object
 */
export const findTypeById = (abi: JsonAbiOld, typeId: number): JsonAbiType => {
  const type = abi.types.find((t) => t.typeId === typeId);
  if (!type) {
    throw new FuelError(

View on GitHub (pinned to b3f37c91ac)

Solutions

  1. Print abi.functions.map(f => f.name) to confirm the exact function name (and casing).
  2. Ensure the ABI used by Interface/Contract matches the contract deployed at the target address.
  3. Regenerate the ABI from current Sway source and reload it.

Example fix

// before
const tx = contract.functions.myFunc(...); // typo / renamed

// after
const names = contract.interface.jsonABI.functions.map(f => f.name);
if (!names.includes('myFunc')) {
  throw new Error(`function not in ABI. available: ${names.join(', ')}`);
}
const tx = contract.functions.myFunc(...);
Defensive patterns

Strategy: validation

Validate before calling

function ensureFunction(abi: JsonAbi, name: string) {
  const fn = abi.functions.find(f => f.name === name);
  if (!fn) {
    const available = abi.functions.map(f => f.name).join(', ');
    throw new Error(`function '${name}' not in ABI. available: ${available}`);
  }
  return fn;
}

Type guard

function hasFunction(abi: JsonAbi, name: string): boolean {
  return abi.functions.some(f => f.name === name);
}

Prevention

When it happens

Trigger: Calling interface.functions.<name>, contract.functions.<name>(...) or Invoker with a name not present in the ABI; loading the wrong ABI for the deployed contract; typo or case mismatch in the function name.

Common situations: ABI/contract address mismatch (pointing at contract A with ABI of contract B); renamed Sway function after recompile; case sensitivity (`Main` vs `main`); using a minified/older ABI artifact.

Related errors


AI-assisted analysis of FuelLabs/fuels-ts@b3f37c91ac (2026-08-12). Data as JSON: /api/errors/619029956e52e1f8. Report an issue: GitHub.