FuelLabs/fuels-ts · error · Error

Data section offset is out of bounds, offset: ${offset}, bin

Error message

Data section offset is out of bounds, offset: ${offset}, binary length: ${originalBinary.length}

What it means

Thrown by getPredicateScriptLoaderInstructions() when the configurable-section offset decoded from the bytecode exceeds the bytecode's actual byte length. The offset is read via a u64 decode at CONFIGURABLE_OFFSET_INDEX (byte 16); if the bytecode is truncated, malformed, or not actual compiled Sway output, the offset will be garbage and point past the end.

Source

Thrown at packages/account/src/utils/predicate-script-loader-instructions.ts:154

    // REG_GENERAL_USE to hold the size of the blob.
    asm.bsiz(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE),
    // Push the blob contents onto the stack.
    asm.ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 1),
    // Jump into the memory where the contract is loaded.
    // What follows is called _jmp_mem by the sway compiler.
    // Subtract the address contained in IS because jmp will add it back.
    asm.sub(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, REG_IS),
    // jmp will multiply by 4, so we need to divide to cancel that out.
    asm.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),
    // Jump to the start of the contract we loaded.
    asm.jmp(REG_START_OF_LOADED_CODE),
  ];

  const offset = getBytecodeConfigurableOffset(originalBinary);

  // if the binary length is smaller than the offset
  if (originalBinary.length < offset) {
    throw new Error(
      `Data section offset is out of bounds, offset: ${offset}, binary length: ${originalBinary.length}`
    );
  }

  // Extract the configurable section from the binary (slice from the configurable offset onwards)
  const configurableSection = originalBinary.slice(offset);

  // Check if the configurable section is non-empty
  if (configurableSection.length > 0) {
    // Get the number of instructions (assuming it won't exceed u16::MAX)
    const numOfInstructions = getInstructions(0).length;
    if (numOfInstructions > 65535) {
      throw new Error('Too many instructions, exceeding u16::MAX.');
    }

    // Convert instructions to bytes
    const instructionBytes = new Uint8Array(
      getInstructions(numOfInstructions).flatMap((instruction) =>

View on GitHub (pinned to b3f37c91ac)

Solutions

  1. Recompile the predicate/script with the forc version matched to your SDK release.
  2. Verify the bytecode Uint8Array length matches the on-disk .bin file exactly.
  3. Load bytecode directly from the build artifact rather than reconstructing it.
  4. Check for truncation in any transport/encoding layer (base64, hex, JSON).

Example fix

// before
const bytecode = new Uint8Array(partialBuffer); // truncated
// after
const bytecode = await fs.readFile('./project/out/debug/predicate.bin');
Defensive patterns

Strategy: validation

Validate before calling

import { getBytecodeConfigurableOffset } from '@fuel-ts/account/utils';
const offset = getBytecodeConfigurableOffset(bytecode);
if (bytecode.length < offset) throw new Error('Bytecode shorter than configurable offset');

Type guard

const isCompleteBytecode = (b: Uint8Array): boolean => { try { return b.length >= getBytecodeConfigurableOffset(b); } catch { return false; } };

Prevention

When it happens

Trigger: Passing corrupted, truncated, or non-Sway bytecode to deployScriptOrPredicate or getPredicateScriptLoaderInstructions. Also triggered by bytecode from an incompatible Sway compiler version that lays out the configurable offset header differently than the SDK expects.

Common situations: Loading bytecode from a truncated file; passing raw source instead of compiled binary; version skew between forc/Sway compiler and fuels-ts SDK; manually constructing a Uint8Array of the wrong length; bytecode pipeline dropping bytes during transport (e.g. base64 decode mismatch).

Related errors


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