8000 GitHub - tamtamchik/depositor
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

tamtamchik/depositor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Depositor - Ethereum 2.0 Validator Key Generator

A modern TypeScript implementation of the Ethereum 2.0 deposit tool built with Node.js 23.

Features

  • ✅ 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

Prerequisites

  • Node.js (23+)

Installation

  1. Clone the repository:
git clone https://github.com/tamtamchik/depositor.git
cd depositor
  1. Install dependencies:
npm install

Usage

CLI Interface

Run the tool directly with npx tsx:

npx tsx src/cli.ts [options]

Or use the provided npm scripts:

npm run generate -- [options]

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

Example

Generate 2 validators for sepolia with ETH withdrawal address:

npm run generate -- --validators=2 --wc-address=0xYourEthAddress --chain=sepolia --password=YourSecurePassword

API Usage

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);

Project Structure

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

Development

Running Tests

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.

Building

Build the TypeScript code:

npm run build

License

MIT

Project History

This project started as a refactoring effort to modernize and optimize an Ethereum 2.0 deposit tool. Key improvements included:

  1. Consolidating 7 separate files into 3 core files
  2. Implementing a modular design with clear separation of concerns
  3. Adding comprehensive test coverage (100% line coverage)
  4. Modernizing the codebase with TypeScript and ES Modules
  5. Enhancing developer experience with better error handling and documentation
  6. Adding support for debugging and verification

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0