{"record":{"id":"ee35274629811848","repo":"FuelLabs/fuels-ts","slug":"missing-provider","errorCode":"MISSING_PROVIDER","errorMessage":"Provider not set","messagePattern":"Provider not set","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/account/src/account.ts","lineNumber":184,"sourceCode":"   * @param connector - A FuelConnector instance (optional).\n   */\n  constructor(address: AddressInput, provider?: Provider, connector?: FuelConnector) {\n    super();\n    this._provider = provider;\n    this._connector = connector;\n    this.address = new Address(address);\n  }\n\n  /**\n   * The provider used to interact with the network.\n   *\n   * @returns A Provider instance.\n   *\n   * @throws `FuelError` if the provider is not set.\n   */\n  get provider(): Provider {\n    if (!this._provider) {\n      throw new FuelError(ErrorCode.MISSING_PROVIDER, 'Provider not set');\n    }\n\n    return this._provider;\n  }\n\n  /**\n   * Sets the provider for the account.\n   *\n   * @param provider - A Provider instance.\n   */\n  set provider(provider: Provider) {\n    this._provider = provider;\n  }\n\n  /**\n   * Changes the provider connection for the account.\n   *\n   * @param provider - A Provider instance.","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/account/src/account.ts#L166-L202","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst wallet = Wallet.fromPrivateKey(secret);\nawait wallet.getBalance(); // throws MISSING_PROVIDER\n\n// after\nconst wallet = Wallet.fromPrivateKey(secret, provider);\nawait wallet.getBalance();","handlingStrategy":"type-guard","validationCode":"function assertProvider<T extends { provider?: unknown }>(acct: T): asserts acct is T & { provider: NonNullable<T['provider']> } {\n  if (!acct.provider) throw new Error('Account has no provider; call connect(provider) first');\n}","typeGuard":"function hasProvider(acct: { provider?: unknown }): boolean {\n  return Boolean(acct.provider);\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["account","missing-provider","wallet","network","config"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}