FuelLabs/fuels-ts · error · FuelError

CONFIGURABLE_NOT_FOUND

CONFIGURABLE_NOT_FOUND

Error message

The script does not have a configurable constant named: '${key}'

What it means

Thrown by Script.setConfigurableConstants() when a key in the supplied configurables object does not match any name in interface.configurables. Each configurable must exist in the ABI so its offset is known for patching the bytecode; an unknown name means either a typo or a stale ABI.

Source

Thrown at packages/script/src/script.ts:102

  /**
   * Set the configurable constants of the script.
   *
   * @param configurables - An object containing the configurable constants and their values.
   * @throws Will throw an error if the script has no configurable constants to be set or if an invalid constant is provided.
   * @returns This instance of the `Script`.
   */
  setConfigurableConstants(configurables: { [name: string]: unknown }) {
    try {
      if (!Object.keys(this.interface.configurables).length) {
        throw new FuelError(
          FuelError.CODES.INVALID_CONFIGURABLE_CONSTANTS,
          `The script does not have configurable constants to be set`
        );
      }

      Object.entries(configurables).forEach(([key, value]) => {
        if (!this.interface.configurables[key]) {
          throw new FuelError(
            FuelError.CODES.CONFIGURABLE_NOT_FOUND,
            `The script does not have a configurable constant named: '${key}'`
          );
        }

        const { offset } = this.interface.configurables[key];

        const encoded = this.interface.encodeConfigurable(key, value as InputValue);

        this.bytes.set(encoded, offset);
      });
    } catch (err) {
      throw new FuelError(
        FuelError.CODES.INVALID_CONFIGURABLE_CONSTANTS,
        `Error setting configurable constants: ${(<Error>err).message}.`
      );
    }

View on GitHub (pinned to b3f37c91ac)

Solutions

  1. Inspect the script ABI / interface.configurables keys and use the exact declared name.
  2. Regenerate types (typegen) after changing configurable names in Sway.
  3. Match casing exactly (Sway configurables are typically SCREAMING_SNAKE_CASE).

Example fix

// before
script.setConfigurableConstants({ fee_rate: 200 }); // typo / wrong case

// after
script.setConfigurableConstants({ FEE_RATE: 200 });
Defensive patterns

Strategy: validation

Validate before calling

function isValidConfigurableName(script: { interface: { configurables: Record<string, unknown> } }, name: string): boolean {
  return name in script.interface.configurables;
}

for (const key of Object.keys(values)) {
  if (!isValidConfigurableName(script, key)) {
    throw new Error(`Unknown configurable '${key}'. Known: ${Object.keys(script.interface.configurables).join(', ')}`);
  }
}

Type guard

function isKnownConfigurable(script: { interface: { configurables: Record<string, unknown> } }, name: string): boolean {
  return name in script.interface.configurables;
}

Try / catch

try {
  script.setConfigurableConstants(values);
} catch (e) {
  if (e instanceof FuelError && e.code === FuelError.CODES.CONFIGURABLE_NOT_FOUND) {
    // correct the key names against interface.configurables, regenerate types if stale
  } else throw e;
}

Prevention

When it happens

Trigger: Calling setConfigurableConstants({ WRONG: ... }) where WRONG is not declared in the Sway configurable block; renaming a configurable in Sway but passing the old key; case mismatch.

Common situations: Typos; stale typegen after renaming a configurable; passing camelCase vs the Sway-declared SCREAMING_SNAKE_CASE name.

Related errors


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