FuelLabs/fuels-ts · error · FuelError

INVALID_EVM_ADDRESS

INVALID_EVM_ADDRESS

Error message

Invalid Evm Address: ${evmAddress}.

What it means

Thrown by the deprecated Address.fromEvmAddress(evmAddress) static factory when isEvmAddress(evmAddress) returns false. A valid EVM address here is a 0x-prefixed 40-hex-character string (42 chars total). Other lengths or non-hex content are rejected. New code should use `new Address(evmAddress)`.

Source

Thrown at packages/address/src/address.ts:218

   * @throws Error - Unknown address if the format is not recognized
   * @returns A new `Address` instance
   *
   * @deprecated Use `new Address` instead
   */
  static fromDynamicInput(address: string | Address): Address {
    return new Address(address);
  }

  /**
   * Takes an Evm Address and returns back an `Address`
   *
   * @returns A new `Address` instance
   *
   * @deprecated Use `new Address` instead
   */
  static fromEvmAddress(evmAddress: string): Address {
    if (!isEvmAddress(evmAddress)) {
      throw new FuelError(
        FuelError.CODES.INVALID_EVM_ADDRESS,
        `Invalid Evm Address: ${evmAddress}.`
      );
    }

    return new Address(evmAddress);
  }

  /**
   * Takes an ChecksumAddress and validates if it is a valid checksum address.
   *
   * @returns A `boolean` instance indicating if the address is valid.
   */
  static isChecksumValid(address: ChecksumAddress): boolean {
    let addressParsed = address;

    if (!address.startsWith('0x')) {
      addressParsed = `0x${address}`;

View on GitHub (pinned to b3f37c91ac)

Solutions

  1. Supply a 0x-prefixed 40-hex-character EVM address.
  2. If you actually have a B256 address, use new Address(b256) instead.
  3. Trim whitespace from the input string.
  4. Prefer `new Address(evmAddress)` over the deprecated factory.

Example fix

// before
const a = Address.fromEvmAddress(b256Address); // wrong length
// after
const a = new Address(evmAddress); // 0x + 40 hex chars
Defensive patterns

Strategy: validation

Validate before calling

import { isEvmAddress } from '@fuel-ts/address/utils';
if (!isEvmAddress(maybeEvm)) throw new Error('Not an EVM address');
const addr = new Address(maybeEvm);

Type guard

import { isEvmAddress } from '@fuel-ts/address/utils';
const isEvm = (s: unknown): s is string => typeof s === 'string' && isEvmAddress(s);

Prevention

When it happens

Trigger: Calling Address.fromEvmAddress() with a string that is not 42 characters, not 0x-prefixed, contains non-hex characters, or is actually a 64-char B256 address.

Common situations: Passing a B256 address (64 hex chars) where an EVM address (40 hex chars) was expected; missing 0x prefix; address from a checksummed-EVM context that altered casing (casing alone is fine for hex, but length errors are not); whitespace in the input.

Related errors


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