{"record":{"id":"1a6037df029981a3","repo":"FuelLabs/fuels-ts","slug":"missing-required-parameter-1a6037","errorCode":"MISSING_REQUIRED_PARAMETER","errorMessage":"You must provide a privateKey via config.privateKey or env PRIVATE_KEY","messagePattern":"You must provide a privateKey via config\\.privateKey or env PRIVATE_KEY","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/fuels/src/cli/commands/deploy/createWallet.ts","lineNumber":12,"sourceCode":"import { Wallet, Provider } from '@fuel-ts/account';\nimport { FuelError } from '@fuel-ts/errors';\n\nexport async function createWallet(providerUrl: string, privateKey?: string) {\n  let pvtKey: string;\n\n  if (privateKey) {\n    pvtKey = privateKey;\n  } else if (process.env.PRIVATE_KEY) {\n    pvtKey = process.env.PRIVATE_KEY;\n  } else {\n    throw new FuelError(\n      FuelError.CODES.MISSING_REQUIRED_PARAMETER,\n      'You must provide a privateKey via config.privateKey or env PRIVATE_KEY'\n    );\n  }\n\n  try {\n    const provider = new Provider(providerUrl);\n    await provider.init(); // can probably be removed\n\n    return Wallet.fromPrivateKey(pvtKey, provider);\n  } catch (e) {\n    const error = e as Error & { cause?: { code: string } };\n    if (/EADDRNOTAVAIL|ECONNREFUSED/.test(error.cause?.code ?? '')) {\n      throw new FuelError(\n        FuelError.CODES.CONNECTION_REFUSED,\n        `Couldn't connect to the node at \"${providerUrl}\". Check that you've got a node running at the config's providerUrl or set autoStartFuelCore to true.`\n      );\n    } else {","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/fuels/src/cli/commands/deploy/createWallet.ts#L1-L30","documentation":"Thrown by createWallet when neither a privateKey argument nor a PRIVATE_KEY environment variable is available. The deploy command needs a funded signer to submit transactions, so the CLI refuses to proceed without one rather than silently using an empty key.","triggerScenarios":"Running `fuels deploy` (or calling createWallet directly) with no --privateKey and no PRIVATE_KEY in the environment, and no privateKey in the fuels config.","commonSituations":"CI/CD that forgot to set PRIVATE_KEY, local .env not loaded by the CLI, deploy from a fresh shell, config missing the privateKey field.","solutions":["Export PRIVATE_KEY in the shell or CI secret before running fuels: `export PRIVATE_KEY=0x...`.","Load your .env first (e.g. `dotenv -e .env -- fuels deploy`).","Set `privateKey` in fuels.config.ts (not recommended for shared repos).","Pass the key via the CLI flag if the command supports it."],"exampleFix":"// before\nfuels deploy   # PRIVATE_KEY unset\n// after\nexport PRIVATE_KEY=0x$(cat ~/.fuel/private-key)\nfuels deploy","handlingStrategy":"validation","validationCode":"function resolvePrivateKey(arg?: string): string {\n  const key = arg ?? process.env.PRIVATE_KEY;\n  if (!key) {\n    throw new Error('PRIVATE_KEY is not set; export it or pass via config.privateKey');\n  }\n  return key;\n}","typeGuard":"const hasPrivateKey = (cfg?: { privateKey?: string }): cfg is { privateKey: string } =>\n  !!cfg && typeof cfg.privateKey === 'string' && cfg.privateKey.length > 0;","tryCatchPattern":null,"preventionTips":["Set PRIVATE_KEY in your CI secrets and load it before invoking fuels.","Validate required env at app startup with a fail-fast check.","Never commit the key to fuels.config.ts; use env injection."],"tags":["cli","deploy","credentials","environment","configuration"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}