{"record":{"id":"1e3a77fcab9d89dc","repo":"FuelLabs/fuels-ts","slug":"missing-provider-1e3a77","errorCode":"MISSING_PROVIDER","errorMessage":"Cannot create transaction request without provider","messagePattern":"Cannot create transaction request without provider","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/contract/src/contract-factory.ts","lineNumber":146,"sourceCode":"   */\n  createTransactionRequest(deployOptions?: DeployContractOptions & { bytecode?: BytesLike }) {\n    const storageSlots = (deployOptions?.storageSlots ?? [])\n      .concat(this.storageSlots)\n      .map(({ key, value }) => ({\n        key: hexlifyWithPrefix(key),\n        value: hexlifyWithPrefix(value),\n      }))\n      .filter((el, index, self) => self.findIndex((s) => s.key === el.key) === index)\n      .sort(({ key: keyA }, { key: keyB }) => keyA.localeCompare(keyB));\n\n    const options = {\n      salt: randomBytes(32),\n      ...(deployOptions ?? {}),\n      storageSlots,\n    };\n\n    if (!this.provider) {\n      throw new FuelError(\n        ErrorCode.MISSING_PROVIDER,\n        'Cannot create transaction request without provider'\n      );\n    }\n\n    if (deployOptions?.configurableConstants) {\n      this.setConfigurableConstants(deployOptions.configurableConstants);\n    }\n\n    const bytecode = deployOptions?.bytecode || this.bytecode;\n    const stateRoot = options.stateRoot || getContractStorageRoot(options.storageSlots);\n    const contractId = getContractId(bytecode, options.salt, stateRoot);\n    const transactionRequest = new CreateTransactionRequest({\n      bytecodeWitnessIndex: 0,\n      witnesses: [bytecode],\n      ...options,\n    });\n    transactionRequest.addContractCreatedOutput(contractId, stateRoot);","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/contract/src/contract-factory.ts#L128-L164","documentation":"Thrown by ContractFactory.createTransactionRequest() (packages/contract/src/contract-factory.ts:146) when this.provider is null/undefined. A provider is required to compute the contract ID and assemble the CreateTransactionRequest with correct chain parameters. The provider is set during construction: if the third argument to new ContractFactory() is null, or is an object that does not expose a 'provider' property, this.provider stays null.","triggerScenarios":"Constructing a ContractFactory without a provider/account (third constructor argument omitted or null), then calling createTransactionRequest(), deploy(), deployAsCreateTx(), or deployAsBlobTx(). Also triggered if a non-Account, non-Provider object is passed as the third argument (it is treated as a Provider and assigned directly but may be null).","commonSituations":"Building a ContractFactory from bytecode and ABI for later use (e.g. in tests or scripts) without immediately connecting a provider; forgetting to pass the wallet/provider; refactoring code that previously passed the provider separately.","solutions":["Pass an Account (Wallet) or Provider as the third argument to new ContractFactory(bytecode, abi, accountOrProvider).","Call factory.connect(provider) to obtain a new factory instance bound to a provider.","If using deploy methods, ensure the factory was constructed with a connected Wallet/Account, not just a raw provider for read-only access."],"exampleFix":"// before\nconst factory = new ContractFactory(bytecode, abi);\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);\nif (!factory.provider) {\n  throw new Error('ContractFactory has no provider. Pass a Provider or Account as the 3rd argument.');\n}\nconst { transactionRequest } = factory.createTransactionRequest();","typeGuard":"function hasProvider(factory: ContractFactory): factory is ContractFactory & { provider: Provider } {\n  return factory.provider !== null && factory.provider !== undefined;\n}","tryCatchPattern":"try {\n  const { transactionRequest } = factory.createTransactionRequest();\n} catch (e) {\n  if (e instanceof FuelError && e.code === 'missing-provider') {\n    // re-create factory with provider/account\n    const factoryWithProvider = new ContractFactory(bytecode, abi, wallet);\n  }\n  throw e;\n}","preventionTips":["Always pass an Account/Wallet or Provider as the third argument to new ContractFactory().","Use factory.connect(provider) to create a provider-bound copy if the factory was initially created without one.","Check factory.provider before calling deploy or createTransactionRequest in code paths where the provider may be absent."],"tags":["contract","deployment","provider","configuration"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}