FuelLabs/fuels-ts · error · FuelError
MISSING_PROVIDER
MISSING_PROVIDER
Error message
Provider not set
What it means
Account.provider is a getter that returns the stored Provider instance or throws if none was set. Every network-bound operation on an Account (balances, transactions, messages) goes through this getter, so an unset provider makes the account unable to talk to the node and is rejected immediately.
Source
Thrown at packages/account/src/account.ts:184
* @param connector - A FuelConnector instance (optional).
*/
constructor(address: AddressInput, provider?: Provider, connector?: FuelConnector) {
super();
this._provider = provider;
this._connector = connector;
this.address = new Address(address);
}
/**
* The provider used to interact with the network.
*
* @returns A Provider instance.
*
* @throws `FuelError` if the provider is not set.
*/
get provider(): Provider {
if (!this._provider) {
throw new FuelError(ErrorCode.MISSING_PROVIDER, 'Provider not set');
}
return this._provider;
}
/**
* Sets the provider for the account.
*
* @param provider - A Provider instance.
*/
set provider(provider: Provider) {
this._provider = provider;
}
/**
* Changes the provider connection for the account.
*
* @param provider - A Provider instance.View on GitHub (pinned to b3f37c91ac)
Solutions
- Pass the provider when constructing: new Wallet(secret, provider) or Wallet.fromPrivateKey(secret, provider).
- Call account.provider = provider (or wallet.connect(provider)) before any network call.
- Guard the call site with a provider-set check before invoking network methods.
Example fix
// before const wallet = Wallet.fromPrivateKey(secret); await wallet.getBalance(); // throws MISSING_PROVIDER // after const wallet = Wallet.fromPrivateKey(secret, provider); await wallet.getBalance();
Defensive patterns
Strategy: type-guard
Validate before calling
function assertProvider<T extends { provider?: unknown }>(acct: T): asserts acct is T & { provider: NonNullable<T['provider']> } {
if (!acct.provider) throw new Error('Account has no provider; call connect(provider) first');
} Type guard
function hasProvider(acct: { provider?: unknown }): boolean {
return Boolean(acct.provider);
} Prevention
- Construct wallets with a provider: new Wallet(secret, provider).
- Call wallet.connect(provider) before any network operation.
- In tests, mock or provide a real Provider to avoid MISSING_PROVIDER.
When it happens
Trigger: Creating an Account/Wallet without a provider (e.g. Wallet.fromPrivateKey(address) without connect) and then calling getBalance, sendTransaction, transfer, etc.; calling account.provider directly before connecting.
Common situations: Constructing wallets offline for signing and forgetting to call wallet.connect(provider) / new Wallet(secret, provider); provider dropped after disconnect; testing without mocking the provider.
Related errors
- INVALID_INPUT_PARAMETERS
- ACCOUNT_REQUIRED
- Contract not found!
- Version '${forcVersion}' not found\n at ${pkgUrl}
- Version '${fuelCoreVersion}' not found\n at ${pkgUrl}
AI-assisted analysis of FuelLabs/fuels-ts@b3f37c91ac (2026-08-12).
Data as JSON: /api/errors/ee35274629811848.
Report an issue: GitHub.