{"record":{"id":"e607eb6016e73d09","repo":"unionlabs/union","slug":"private-key-not-found","errorCode":null,"errorMessage":"Private key not found","messagePattern":"Private key not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"typescript-sdk/playground/stride-to-union-legacy.ts","lineNumber":22,"sourceCode":"import { parseArgs } from \"node:util\"\nimport { consola } from \"scripts/logger\"\nimport { http } from \"viem\"\nimport { hexToBytes } from \"../src/convert.ts\"\nimport { createUnionClient, type TransferAssetsParametersLegacy } from \"../src/mod.ts\"\n\n/* `bun playground/stride-to-union.ts --private-key \"...\"` */\n\nconst { values } = parseArgs({\n  args: process.argv.slice(2),\n  options: {\n    \"private-key\": { type: \"string\" },\n    \"estimate-gas\": { type: \"boolean\", default: false },\n  },\n})\n\nconst PRIVATE_KEY = values[\"private-key\"]\nif (!PRIVATE_KEY) {\n  throw new Error(\"Private key not found\")\n}\nconst ONLY_ESTIMATE_GAS = values[\"estimate-gas\"] ?? false\n\nconst cosmosAccount = await DirectSecp256k1Wallet.fromKey(\n  Uint8Array.from(hexToBytes(PRIVATE_KEY)),\n  \"stride\",\n)\nconst [account] = await cosmosAccount.getAccounts()\nconsole.info(account?.address)\n\ntry {\n  const client = createUnionClient({\n    account: cosmosAccount,\n    chainId: \"stride-internal-1\",\n    gasPrice: { amount: \"0.0025\", denom: \"ustrd\" },\n    transport: http(\"https://stride-testnet-rpc.polkachu.com\"),\n  })\n","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/unionlabs/union/blob/031785bb6dc6b957c624e62bc64c184409c97d7b/typescript-sdk/playground/stride-to-union-legacy.ts#L4-L40","documentation":"The playground script stride-to-union-legacy.ts parses --private-key from process.argv via node:util parseArgs and hard-fails when the flag is absent or empty. It is a CLI usage error: the Cosmos (Stride) sender key must be supplied on every invocation, as noted in the script's header comment.","triggerScenarios":"Running `bun playground/stride-to-union-legacy.ts` without any flags; using a wrong flag spelling (--privateKey, --privateKey=...); passing an empty string.","commonSituations":"Copy-pasting the documented run command minus the key; CI jobs where the secret env var was never exported; new contributors running the playground for the first time.","solutions":["Run with the flag: bun playground/stride-to-union-legacy.ts --private-key \"<your hex/bech32 key>\"","Indirect the secret: --private-key \"$PRIVATE_KEY\" after exporting the env var","If absent, print a usage line and exit non-zero instead of a bare stack trace"],"exampleFix":"// before\nconst PRIVATE_KEY = values[\"private-key\"]\nif (!PRIVATE_KEY) {\n  throw new Error(\"Private key not found\")\n}\n\n// after\nconst PRIVATE_KEY = values[\"private-key\"]\nif (!PRIVATE_KEY) {\n  console.error(\"Usage: bun playground/stride-to-union-legacy.ts --private-key <key> [--estimate-gas]\")\n  process.exit(1)\n}","handlingStrategy":"validation","validationCode":"const PRIVATE_KEY = values[\"private-key\"] ?? process.env.PRIVATE_KEY\nif (!PRIVATE_KEY) {\n  console.error(\"Usage: bun playground/stride-to-union-legacy.ts --private-key <key> [--estimate-gas]\")\n  process.exit(1)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the key indirectly: --private-key \"$PRIVATE_KEY\" from a secrets manager","Fail fast with a usage message instead of a stack trace for missing CLI args","Never paste raw keys into shell history — use env files excluded from git"],"tags":["cli","private-key","args","playground"],"backgroundTag":null,"analyzedSha":"031785bb6dc6b957c624e62bc64c184409c97d7b","analyzedAt":"2026-08-16T06:24:09.996Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}