{"record":{"id":"7c7dd234297612ed","repo":"FuelLabs/fuels-ts","slug":"invalid-configurable-constants-7c7dd2","errorCode":"INVALID_CONFIGURABLE_CONSTANTS","errorMessage":"The script does not have configurable constants to be set","messagePattern":"The script does not have configurable constants to be set","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/script/src/script.ts","lineNumber":94,"sourceCode":"    this.account = account;\n\n    this.functions = {\n      main: (...args: TInput) =>\n        new ScriptInvocationScope(this, this.interface.getFunction('main'), args),\n    };\n  }\n\n  /**\n   * Set the configurable constants of the script.\n   *\n   * @param configurables - An object containing the configurable constants and their values.\n   * @throws Will throw an error if the script has no configurable constants to be set or if an invalid constant is provided.\n   * @returns This instance of the `Script`.\n   */\n  setConfigurableConstants(configurables: { [name: string]: unknown }) {\n    try {\n      if (!Object.keys(this.interface.configurables).length) {\n        throw new FuelError(\n          FuelError.CODES.INVALID_CONFIGURABLE_CONSTANTS,\n          `The script does not have configurable constants to be set`\n        );\n      }\n\n      Object.entries(configurables).forEach(([key, value]) => {\n        if (!this.interface.configurables[key]) {\n          throw new FuelError(\n            FuelError.CODES.CONFIGURABLE_NOT_FOUND,\n            `The script does not have a configurable constant named: '${key}'`\n          );\n        }\n\n        const { offset } = this.interface.configurables[key];\n\n        const encoded = this.interface.encodeConfigurable(key, value as InputValue);\n\n        this.bytes.set(encoded, offset);","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/script/src/script.ts#L76-L112","documentation":"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.","triggerScenarios":"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.","commonSituations":"Forgetting to add configurables in Sway; using the wrong (non-configurable) script artifact; stale artifact from before configurables were added.","solutions":["Add a `configurable { NAME: T = default; }` block to the Sway script, recompile, and regenerate types.","If you did not mean to override constants, remove the setConfigurableConstants call.","Re-load the correct compiled script JSON (with configurables) into the Script instance."],"exampleFix":"// Sway\n// before\nfn main() { ... }\n// after\nconfigurable {\n  FEE_RATE: u64 = 100,\n}\nfn main() { ... }","handlingStrategy":"validation","validationCode":"function hasConfigurables(script: { interface: { configurables: Record<string, unknown> } }): boolean {\n  return Object.keys(script.interface.configurables).length > 0;\n}\n\nif (!hasConfigurables(script)) {\n  throw new Error('This script declares no configurables; add a `configurable` block in Sway or drop the call.');\n}","typeGuard":"function hasConfigurables(script: { interface: { configurables: Record<string, unknown> } }): boolean {\n  return Object.keys(script.interface.configurables).length > 0;\n}","tryCatchPattern":"try {\n  script.setConfigurableConstants(values);\n} catch (e) {\n  if (e instanceof FuelError && e.code === FuelError.CODES.INVALID_CONFIGURABLE_CONSTANTS) {\n    // skip setting configurables, or recompile the script with a configurable block\n  } else throw e;\n}","preventionTips":["Declare a `configurable` block in Sway before relying on setConfigurableConstants.","Regenerate types after adding configurables so the ABI exposes them.","Guard the call with a configurables-length check when scripting generically."],"tags":["configurable","script","abi","sway","typescript"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}