{"record":{"id":"15775423f86ca5b3","repo":"FuelLabs/fuels-ts","slug":"account-required","errorCode":"ACCOUNT_REQUIRED","errorMessage":"Account not assigned to contract.","messagePattern":"Account not assigned to contract\\.","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/contract/src/contract-factory.ts","lineNumber":431,"sourceCode":"        const encoded = this.interface.encodeConfigurable(key, value as InputValue);\n\n        const bytes = arrayify(this.bytecode);\n\n        bytes.set(encoded, offset);\n\n        this.bytecode = bytes;\n      });\n    } catch (err) {\n      throw new FuelError(\n        ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,\n        `Error setting configurable constants on contract: ${(<Error>err).message}.`\n      );\n    }\n  }\n\n  private getAccount(): Account {\n    if (!this.account) {\n      throw new FuelError(ErrorCode.ACCOUNT_REQUIRED, 'Account not assigned to contract.');\n    }\n    return this.account;\n  }\n\n  private async prepareDeploy(deployOptions: DeployContractOptions) {\n    const { configurableConstants } = deployOptions;\n\n    if (configurableConstants) {\n      this.setConfigurableConstants(configurableConstants);\n    }\n\n    const { contractId, transactionRequest } = this.createTransactionRequest(deployOptions);\n\n    await this.assembleTx(transactionRequest, deployOptions);\n\n    return {\n      contractId,\n      transactionRequest,","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/contract/src/contract-factory.ts#L413-L449","documentation":"Thrown by the private ContractFactory.getAccount() (packages/contract/src/contract-factory.ts:431) when this.account is null. An Account is required for any operation that submits transactions (deploy, assembleTx, getMaxChunkSize). The account is set during construction only if the third argument has a 'provider' property (duck-typed as a Wallet/Account); if a bare Provider or null is passed, this.account stays null.","triggerScenarios":"Constructing a ContractFactory with a Provider (not an Account/Wallet) or with null as the third argument, then calling deploy(), deployAsCreateTx(), deployAsBlobTx(), or any method that internally calls getAccount().","commonSituations":"Creating a factory for read-only inspection (connected to a Provider only) and then accidentally calling a deploy method; refactoring from provider-only to account-bound deployment; forgetting to pass the wallet; testing with a mock provider that lacks the 'provider' property.","solutions":["Construct the ContractFactory with a Wallet/Account: new ContractFactory(bytecode, abi, wallet).","Ensure the passed object exposes a 'provider' property — the SDK duck-types Accounts by checking 'provider' in accountOrProvider.","If you only have a provider, obtain a Wallet from it first: Wallet.fromPrivateKey(pk, provider) or Wallet.generate({ provider })."],"exampleFix":"// before\nconst factory = new ContractFactory(bytecode, abi, provider);\nawait factory.deploy();\n\n// after\nconst factory = new ContractFactory(bytecode, abi, wallet);\nawait factory.deploy();","handlingStrategy":"validation","validationCode":"const factory = new ContractFactory(bytecode, abi, provider);\nif (!factory.account) {\n  throw new Error('No account bound to ContractFactory. Pass a Wallet/Account as the 3rd argument.');\n}\nawait factory.deploy();","typeGuard":"function hasAccount(factory: ContractFactory): factory is ContractFactory & { account: Account } {\n  return factory.account !== null && factory.account !== undefined;\n}","tryCatchPattern":"try {\n  await factory.deploy();\n} catch (e) {\n  if (e instanceof FuelError && e.code === 'account-required') {\n    // Factory was created with a Provider, not an Account\n    const factoryWithAccount = new ContractFactory(bytecode, abi, wallet);\n    await factoryWithAccount.deploy();\n  } else {\n    throw e;\n  }\n}","preventionTips":["Pass a Wallet/Account (not just a Provider) as the third argument when you intend to deploy.","The SDK duck-types Accounts by checking for a 'provider' property — ensure the passed object has one.","Check factory.account before calling deploy methods in code paths where it may be null."],"tags":["contract","deployment","account","wallet","configuration"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}