FuelLabs/fuels-ts · error · FuelError

INVALID_CONFIGURABLE_CONSTANTS

INVALID_CONFIGURABLE_CONSTANTS

Error message

The script does not have configurable constants to be set

What it means

Thrown by Script.setConfigurableConstants() when the script's ABI declares zero configurable constants (Object.keys(interface.configurables) is empty). The SDK prevents setting configurables on a script that was compiled without any `configurable` blocks, since there is nothing to patch in the bytecode.

Source

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

    this.account = account;

    this.functions = {
      main: (...args: TInput) =>
        new ScriptInvocationScope(this, this.interface.getFunction('main'), args),
    };
  }

  /**
   * 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);

View on GitHub (pinned to b3f37c91ac)

Solutions

  1. Add a `configurable { NAME: T = default; }` block to the Sway script, recompile, and regenerate types.
  2. If you did not mean to override constants, remove the setConfigurableConstants call.
  3. Re-load the correct compiled script JSON (with configurables) into the Script instance.

Example fix

// Sway
// before
fn main() { ... }
// after
configurable {
  FEE_RATE: u64 = 100,
}
fn main() { ... }
Defensive patterns

Strategy: validation

Validate before calling

function hasConfigurables(script: { interface: { configurables: Record<string, unknown> } }): boolean {
  return Object.keys(script.interface.configurables).length > 0;
}

if (!hasConfigurables(script)) {
  throw new Error('This script declares no configurables; add a `configurable` block in Sway or drop the call.');
}

Type guard

function hasConfigurables(script: { interface: { configurables: Record<string, unknown> } }): boolean {
  return Object.keys(script.interface.configurables).length > 0;
}

Try / catch

try {
  script.setConfigurableConstants(values);
} catch (e) {
  if (e instanceof FuelError && e.code === FuelError.CODES.INVALID_CONFIGURABLE_CONSTANTS) {
    // skip setting configurables, or recompile the script with a configurable block
  } else throw e;
}

Prevention

When it happens

Trigger: Calling script.setConfigurableConstants({...}) on a Sway script that has no `configurable` declarations; calling it before the script ABI was loaded; using a bytecode-only script with no ABI.

Common situations: Forgetting to add configurables in Sway; using the wrong (non-configurable) script artifact; stale artifact from before configurables were added.

Related errors


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