Skip to content

Wraecca/drainer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BIP44 ETH Drainer for Optimism

A TypeScript tool that uses BIP44 derivation to scan child addresses and consolidate ETH balances to the root address on Optimism mainnet.

Features

  • Secure seed phrase input (interactive or environment variable)
  • BIP44 derivation path: m/44'/60'/0'/0/x (Ethereum standard)
  • Batch processing: 100 addresses at a time
  • Automatic balance checking via Alchemy RPC
  • Gas-optimized transfers (deducts gas fees from transfer amount)
  • Always shows dry-run results before executing
  • Continues scanning until no funded addresses are found
  • Colored console output for better visibility

Prerequisites

  • Node.js 18+ or higher
  • An Alchemy API key for Optimism Mainnet (Get one here)
  • A seed phrase for the wallet you want to drain

Installation

  1. Clone this repository:
git clone <repository-url>
cd bip44drainer
  1. Install dependencies:
npm install
  1. Create a .env file:
cp .env.example .env
  1. Edit .env and add your Alchemy API key:
ALCHEMY_API_KEY=your_alchemy_api_key_here

Usage

Interactive Mode (Recommended)

Run the script and enter your seed phrase when prompted:

npm start

The script will:

  1. Ask for your seed phrase securely
  2. Scan batches of 100 addresses for ETH balances
  3. Show a dry-run of all planned transfers
  4. Ask for confirmation before executing
  5. Execute transfers if confirmed

Environment Variable Mode

You can set the seed phrase in your .env file (not recommended for security):

SEED_PHRASE=your twelve word seed phrase goes here

Then run:

npm start

How It Works

  1. Derivation: Uses BIP44 path m/44'/60'/0'/0/x where:

    • m/44'/60'/0'/0/0 = Root address (recipient)
    • m/44'/60'/0'/0/1 = First child address
    • m/44'/60'/0'/0/2 = Second child address
    • And so on...
  2. Scanning: Checks balances in batches of 100 addresses

  3. Transfer: For each funded address:

    • Estimates gas cost
    • Calculates transfer amount = balance - gas cost
    • Transfers to root address if profitable
  4. Completion: Stops when a consecutive batch has no funded addresses

Security Warnings

  • Never share your seed phrase with anyone
  • Never commit your .env file with actual credentials
  • Use interactive mode instead of storing seed phrase in environment
  • This tool transfers real funds on mainnet - use with caution
  • Always verify the dry-run results before confirming execution

Configuration

Edit src/config.ts to customize:

  • chainId: Optimism mainnet (10)
  • bip44Path: BIP44 derivation path
  • batchSize: Number of addresses per batch (default: 100)

Example Output

═══════════════════════════════════════════════════════════
BIP44 ETH DRAINER - OPTIMISM MAINNET
═══════════════════════════════════════════════════════════
ℹ Validating configuration...
✓ Configuration valid
ℹ Connecting to Optimism network...
✓ Connected to Optimism Mainnet

Root Address (Recipient): 0x1234...5678
ℹ Derivation path: m/44'/60'/0'/0/x
ℹ Batch size: 100 addresses

═══════════════════════════════════════════════════════════
SCANNING FOR FUNDED ADDRESSES
═══════════════════════════════════════════════════════════

Batch 1: Addresses 0 - 99
────────────────────────────────────────────────────────────
ℹ Deriving 100 addresses...
ℹ Checking balances...
✓ Found 3 funded addresses with 0.15 ETH total

═══════════════════════════════════════════════════════════
DRY RUN RESULTS
═══════════════════════════════════════════════════════════
Root Address (Recipient): 0x1234...5678

Batch 1 (0-99)
────────────────────────────────────────────────────────────
0xabcd...1234 → 0x1234...5678 0.05 ETH
0xefgh...5678 → 0x1234...5678 0.07 ETH
0xijkl...9012 → 0x1234...5678 0.03 ETH

✓ Total transfers planned: 3
Total amount to transfer: 0.15 ETH
⚠ Estimated total gas cost: 0.000063 ETH

Do you want to execute these transfers? (yes/no):

Troubleshooting

"ALCHEMY_API_KEY is required"

  • Make sure you created a .env file
  • Add your Alchemy API key to the .env file

"Invalid seed phrase"

  • Check that you entered exactly 12 or 24 words
  • Verify the words are correct BIP39 words
  • Ensure there are no extra spaces

"Insufficient balance to cover gas costs"

  • The address has ETH but not enough to pay for gas
  • These addresses will be skipped automatically

License

MIT

Disclaimer

This tool is provided as-is for educational and legitimate use cases only. Always verify transactions before confirming. The authors are not responsible for any loss of funds.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published