FuelLabs/fuels-ts · error · FuelError

INVALID_CHUNK_SIZE_MULTIPLIER

INVALID_CHUNK_SIZE_MULTIPLIER

Error message

Chunk size multiplier must be between 0 and 1

What it means

Thrown by ContractFactory.getMaxChunkSize() (packages/contract/src/contract-factory.ts:477) when the chunkSizeMultiplier parameter is less than 0 or greater than 1. The multiplier scales the maximum blob chunk size as a fraction of the chain's transaction/contract size limit. The default value is CHUNK_SIZE_MULTIPLIER (0.95). This validation runs before any chain queries, so it fails immediately on bad input.

Source

Thrown at packages/contract/src/contract-factory.ts:477

  private blobTransactionRequest(options: { bytecode: BytesLike } & DeployContractOptions) {
    const { bytecode } = options;
    return new BlobTransactionRequest({
      blobId: hash(bytecode),
      witnessIndex: 0,
      witnesses: [bytecode],
      ...options,
    });
  }

  /**
   * Get the maximum chunk size for deploying a contract by chunks.
   */
  private async getMaxChunkSize(
    deployOptions: DeployContractOptions,
    chunkSizeMultiplier: number = CHUNK_SIZE_MULTIPLIER
  ) {
    if (chunkSizeMultiplier < 0 || chunkSizeMultiplier > 1) {
      throw new FuelError(
        ErrorCode.INVALID_CHUNK_SIZE_MULTIPLIER,
        'Chunk size multiplier must be between 0 and 1'
      );
    }

    const account = this.getAccount();
    const { consensusParameters } = await account.provider.getChain();
    const contractSizeLimit = consensusParameters.contractParameters.contractMaxSize.toNumber();
    const transactionSizeLimit = consensusParameters.txParameters.maxSize.toNumber();
    const maxLimit = 64000;
    const chainLimit =
      transactionSizeLimit < contractSizeLimit ? transactionSizeLimit : contractSizeLimit;
    const sizeLimit = chainLimit < maxLimit ? chainLimit : maxLimit;

    // Get an estimate base tx length

    const blobTx = this.blobTransactionRequest({
      ...deployOptions,

View on GitHub (pinned to b3f37c91ac)

Solutions

  1. Set chunkSizeMultiplier to a value between 0 and 1 (exclusive); the default 0.95 is almost always correct.
  2. If you intended a percentage, divide by 100: e.g. 95 → 0.95.
  3. Omit chunkSizeMultiplier entirely to use the default 0.95.

Example fix

// before
await factory.deployAsBlobTx({ chunkSizeMultiplier: 95 });

// after
await factory.deployAsBlobTx({ chunkSizeMultiplier: 0.95 });
// or simply omit it:
// await factory.deployAsBlobTx();
Defensive patterns

Strategy: validation

Validate before calling

function validateChunkMultiplier(m?: number): number {
  if (m === undefined) return 0.95; // default
  if (m < 0 || m > 1) {
    throw new Error(`chunkSizeMultiplier must be between 0 and 1, got: ${m}`);
  }
  return m;
}

await factory.deployAsBlobTx({ chunkSizeMultiplier: validateChunkMultiplier(userValue) });

Type guard

function isValidChunkMultiplier(value: unknown): value is number {
  return typeof value === 'number' && value >= 0 && value <= 1;
}

Try / catch

try {
  await factory.deployAsBlobTx({ chunkSizeMultiplier: userValue });
} catch (e) {
  if (e instanceof FuelError && e.code === 'invalid-chunk-size-multiplier') {
    // userValue was outside [0, 1]; default to 0.95
    await factory.deployAsBlobTx({ chunkSizeMultiplier: 0.95 });
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Calling deployAsBlobTx({ chunkSizeMultiplier: X }) or deploy() (when it routes to blob-tx) with a chunkSizeMultiplier outside the range [0, 1] — e.g. passing a percentage like 95 instead of 0.95, a negative value, or a value > 1.

Common situations: Misinterpreting the multiplier as a percentage (passing 95 instead of 0.95); copying a value from configuration that uses a different scale; accidental integer division or type coercion producing a value outside bounds.

Related errors


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