A modern TypeScript implementation of the Ethereum 2.0 deposit tool built with Node.js 23.
- ✅ Generate Ethereum 2.0 validator keys
- ✅ Create deposit data for staking
- ✅ Use BIP39 mnemonics for key derivation
- ✅ Support for multiple validators in one run
- ✅ Verification of generated data
- ✅ Support for multiple networks (mainnet, sepolia, hoodi)
- ✅ Support for different withdrawal credential types (BLS, ETH address)
- ✅ High test coverage (100% line, 97.7% branch coverage)
- ✅ Modern codebase with TypeScript and ES Modules
- Node.js (23+)
- Clone the repository:
git clone https://github.com/tamtamchik/depositor.git
cd depositor
- Install dependencies:
npm install
Run the tool directly with npx tsx
:
npx tsx src/cli.ts [options]
Or use the provided npm scripts:
npm run generate -- [options]
Option | Description | Default |
---|---|---|
--mnemonic |
Mnemonic seed for key generation (optional, will be generated if not provided) | |
--validators |
Number of validators to generate | 1 |
--wc-type |
Withdrawal credentials type (0=BLS, 1/2=ETH address) | 1 |
--wc-address |
Ethereum address for withdrawal (required when wc-type is 1 or 2) | |
--chain |
Network chain to use (mainnet, sepolia, hoodi) | mainnet |
--password |
Password for keystore encryption | |
--out |
Output directory for keystores | ./validator_keys |
--verify |
Whether to verify generated deposit data | true |
--amount |
Amount in ETH to deposit per validator | 32 |
--debug |
Enable debug logging | false |
Generate 2 validators for sepolia with ETH withdrawal address:
npm run generate -- --validators=2 --wc-address=0xYourEthAddress --chain=sepolia --password=YourSecurePassword
You can also use the library programmatically:
import {
generateValidatorKeys,
buildWithdrawalCredentials,
generateDepositData,
verifyDepositData,
getNetworkConfig,
computeDomain,
ZERO_HASH,
DOMAIN_DEPOSIT,
} from "./src/core.js";
// Generate validator keys
const { signing, pubkey } = await generateValidatorKeys(
"your mnemonic phrase",
0, // index
"password",
"./keys"
);
// Build withdrawal credentials
const withdrawalCredentials = buildWithdrawalCredentials(
0, // type
pubkey
);
// Generate deposit data
const depositData = await generateDepositData(
pubkey,
signing,
withdrawalCredentials,
32000000000, // 32 ETH in Gwei
"mainnet"
);
// Verify deposit data
const networkConfig = getNetworkConfig("mainnet");
const domain = computeDomain(
DOMAIN_DEPOSIT,
networkConfig.forkVersion,
ZERO_HASH
);
const isValid = await verifyDepositData(depositData, domain);
depositor/
├── src/
│ ├── core.ts # Core functionality and utilities
│ ├── cli.ts # Command-line interface
│ ├── types.ts # Type definitions
│ └── index.ts # Main entry point and exports
├── test/
│ ├── unit/ # Unit tests for core functionality
│ └── integration.test.ts # End-to-end tests
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── .eslintrc.json # ESLint configuration
└── setup.sh # Setup script
Run unit tests:
npm test
Generate test coverage:
npm run test:coverage
Current coverage metrics:
- Line coverage: 100%
- Branch coverage: 97.7%
- Function coverage: 100%
See the test README for more details about testing.
Build the TypeScript code:
npm run build
MIT
This project started as a refactoring effort to modernize and optimize an Ethereum 2.0 deposit tool. Key improvements included:
- Consolidating 7 separate files into 3 core files
- Implementing a modular design with clear separation of concerns
- Adding comprehensive test coverage (100% line coverage)
- Modernizing the codebase with TypeScript and ES Modules
- Enhancing developer experience with better error handling and documentation
- Adding support for debugging and verification