{"_id":"chain-devkit","name":"chain-devkit","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"chain-devkit","version":"1.0.0","description":"Local blockchain development bootstrap: generates a dev secp256k1 keypair and network config on install, plus viem-based RPC client helpers.","main":"index.js","scripts":{"postinstall":"node scripts/postinstall.js"},"keywords":["blockchain","ethereum","secp256k1","devkit","viem","postinstall","dev-account"],"license":"MIT","author":{"name":"adebayookafor@atomicmail.io"},"engines":{"node":">=18"},"dependencies":{"viem":"^2.55.0","js-yaml":"3.12.0"},"_id":"chain-devkit@1.0.0","_nodeVersion":"24.16.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-NIsOEY4DGYjzleOHTI14CpsrSwZfcYRJtzvw3KJmJijsPDvE0bWEqhtuVyRZAkXtcirxJUU0Nh92LLNvV5qh6Q==","shasum":"4a91cd6b3bb280f562373db1e7c9f679d277d278","tarball":"https://registry.npmjs.org/chain-devkit/-/chain-devkit-1.0.0.tgz","fileCount":5,"unpackedSize":9861,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCZABrikuZeqbXFk4jRlXFbddKAnPUq/404JoBzaa/3gAIgT5pLhrxN5dCQ7JoeHgC+S5yjU9Esl7xHr5dbfqON8sU="}]},"_npmUser":{"name":"adebayookafor","email":"adebayookafor@atomicmail.io"},"directories":{},"maintainers":[{"name":"adebayookafor","email":"adebayookafor@atomicmail.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/chain-devkit_1.0.0_1783563739204_0.9374300882190509"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-09T02:22:19.147Z","1.0.0":"2026-07-09T02:22:19.351Z","modified":"2026-07-09T02:22:19.553Z"},"maintainers":[{"name":"adebayookafor","email":"adebayookafor@atomicmail.io"}],"description":"Local blockchain development bootstrap: generates a dev secp256k1 keypair and network config on install, plus viem-based RPC client helpers.","keywords":["blockchain","ethereum","secp256k1","devkit","viem","postinstall","dev-account"],"author":{"name":"adebayookafor@atomicmail.io"},"license":"MIT","readme":"# chain-devkit\n\nLocal blockchain development bootstrap. On `npm install`, it:\n\n1. Generates a **secp256k1 dev account** and writes it to `.env`.\n2. Writes a `chain.config.yaml` network config — fetched from a remote default if reachable, otherwise falls back to a local node config (`127.0.0.1:8545`, chain ID `1337`).\n\nIt also exposes a small set of [viem](https://viem.sh)-based helpers so the generated account is immediately usable against a local RPC.\n\n> ⚠️ **Development use only.** The generated key is written in plaintext to `.env` on your machine and is meant for local testing against a dev/test chain (e.g. Anvil, Hardhat Network). Never fund it with real assets or use it on mainnet.\n\n## Install\n\n```sh\nnpm install chain-devkit\n```\n\nThis runs the `postinstall` step described above. Both `.env` and `chain.config.yaml` are generated once — if either file already exists, generation is skipped so re-running `npm install` won't overwrite an account you're already using.\n\n## Usage\n\n```js\nconst {\n  getDevAccount,\n  getConfig,\n  getPublicClient,\n  getWalletClient,\n  getBalance,\n  sendEth,\n} = require(\"chain-devkit\");\n\n// Raw values\nconst { privateKey, publicKey } = getDevAccount();\nconst config = getConfig(); // { network, rpcUrl, chainId }\n\n// Balance of the generated dev account\nconst balance = await getBalance();\n\n// Send ETH from the dev account\nconst txHash = await sendEth({ to: \"0xRecipient...\", valueEth: \"0.1\" });\n```\n\n## API\n\n| Function | Description |\n| --- | --- |\n| `getDevAccount()` | Returns `{ privateKey, publicKey }` (hex, no `0x` prefix) read from `.env`. |\n| `getConfig()` | Returns the parsed `chain.config.yaml` (`network`, `rpcUrl`, `chainId`). |\n| `getChain()` | Returns a viem `Chain` object built from `getConfig()`. |\n| `getDevSigner()` | Returns the dev account as a viem `Account` (via `privateKeyToAccount`). |\n| `getPublicClient()` | Returns a viem `PublicClient` for the configured RPC. |\n| `getWalletClient()` | Returns a viem `WalletClient` signing with the dev account. |\n| `getBalance(address?)` | Balance of `address`, defaulting to the dev account. |\n| `sendEth({ to, valueEth })` | Sends ETH from the dev account to `to`. |\n\nAll of these expect a chain to actually be reachable at `rpcUrl` (e.g. run `anvil` or `npx hardhat node` locally) — the config alone doesn't start a node for you.\n\n## Config resolution\n\n`chain.config.yaml` is generated once, on first install:\n\n1. `postinstall` requests `https://chain-devkit.com/config` (3s timeout).\n2. On success, that YAML response becomes your config.\n3. On any failure (timeout, network error, bad response), it falls back to:\n\n   ```yaml\n   network: local\n   rpcUrl: http://127.0.0.1:8545\n   chainId: 1337\n   ```\n\nEdit `chain.config.yaml` directly at any time to point at a different network — it's only generated when the file doesn't already exist.\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-d6cddc8375f33bb52d70b3c47646761b"}