FuelLabs/fuels-ts · error · FuelError

WALLET_MANAGER_ERROR

WALLET_MANAGER_ERROR

Error message

No private key found for address '${address}'.

What it means

Thrown by PrivateKeyVault.exportAccount() when none of the vault's stored private keys derives to the requested address. The vault holds an explicit list of private keys; if the address was never added (or its key was removed), export fails with WALLET_MANAGER_ERROR.

Source

Thrown at packages/account/src/wallet-manager/vaults/privatekey-vault.ts:64

    return this.#privateKeys.map((pk) => this.getPublicAccount(pk));
  }

  addAccount() {
    const wallet = Wallet.generate();

    this.#privateKeys.push(wallet.privateKey);

    return this.getPublicAccount(wallet.privateKey);
  }

  exportAccount(address: AddressInput): string {
    const ownerAddress = new Address(address);
    const privateKey = this.#privateKeys.find((pk) =>
      Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
    );

    if (!privateKey) {
      throw new FuelError(
        ErrorCode.WALLET_MANAGER_ERROR,
        `No private key found for address '${address}'.`
      );
    }

    return privateKey;
  }

  getWallet(address: string | Address): WalletUnlocked {
    const privateKey = this.exportAccount(address);
    return Wallet.fromPrivateKey(privateKey);
  }
}

View on GitHub (pinned to b3f37c91ac)

Solutions

  1. Confirm the address was added via PrivateKeyVault (constructor secret/accounts or addAccount()).
  2. If the address is mnemonic-derived, use MnemonicVault instead.
  3. Inspect the serialized vault state to verify the accounts/privateKeys list is intact.
  4. Re-import the private key for the address using addAccount() or the constructor.

Example fix

// before
const pk = pkVault.exportAccount(unknownAddress);
// after
const accounts = pkVault.getAccounts();
if (!accounts.some(a => a.address.equals(unknownAddress))) {
  pkVault.addAccount(); // or import the known key
}
Defensive patterns

Strategy: validation

Validate before calling

const accounts = pkVault.getAccounts();
if (!accounts.some(a => a.address.equals(new Address(target)))) {
  throw new Error('Address not present in private-key vault');
}

Type guard

const vaultHasKey = (v: PrivateKeyVault, addr: AddressInput): boolean => v.getAccounts().some(a => a.address.equals(new Address(addr)));

Prevention

When it happens

Trigger: Calling privateKeyVault.exportAccount(address) / walletManager.exportWallet(address) with an address not corresponding to any stored key. The find() over this.#privateKeys returns undefined and the throw fires.

Common situations: Address came from a mnemonic-derived wallet but the vault only stores raw keys; the key was removed during state migration; deserialized vault lost its accounts array; address format/casing differences in storage.

Related errors


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