https://github.com/hadv/vaneth
GPU-accelerated CREATE2 vanity address miner for Ethereum
https://github.com/hadv/vaneth
create2-contract-deployment cuda ethereum gpu gpu-acceleration gpu-programming open-cl vanity-address
Last synced: 1 day ago
JSON representation
GPU-accelerated CREATE2 vanity address miner for Ethereum
- Host: GitHub
- URL: https://github.com/hadv/vaneth
- Owner: hadv
- License: mit
- Created: 2019-02-07T09:34:02.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-12-06T16:03:19.000Z (about 2 months ago)
- Last Synced: 2025-12-08T00:17:31.952Z (about 2 months ago)
- Topics: create2-contract-deployment, cuda, ethereum, gpu, gpu-acceleration, gpu-programming, open-cl, vanity-address
- Language: Go
- Homepage:
- Size: 1.17 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Vaneth - Ethereum Vanity Address Miner ⛏️
```
__ _____ _ _ _____ _____ _ _
\ \ / / _ \ | \ | | ____|_ _| | | |
\ V / |_| | | \| | _| | | | |_| |
\_/|_/ \_\ |_|\__|_____| |_| |_| |_|
⛏️ CREATE2 Vanity Miner ⛏️
```
> GPU-accelerated CREATE2 vanity address miner for Ethereum using [Solady CREATE2 Factory](https://github.com/Vectorized/solady)
## Overview
This tool uses brute force to find a salt value that, when used with the CREATE2 opcode, will deploy a smart contract to a vanity address (e.g., starting with `0x00000000`).
The CREATE2 address is calculated as:
```
address = keccak256(0xff ++ deployer_address ++ salt ++ keccak256(init_code))[12:]
```
## Features
- 🚀 **Highly Optimized**: Direct byte comparison, pre-calculated values, zero allocations in hot loop
- 🔥 **SIMD Acceleration**: AVX2-optimized 4-way parallel Keccak256 (~10x faster than standard CPU)
- ⚡ **Multi-core Support**: Automatically uses all CPU cores with configurable goroutines
- 🎮 **GPU Acceleration**: OpenCL support on macOS/Linux, CUDA support for NVIDIA GPUs on Linux
- 🎯 **Flexible Patterns**: Search for any hex pattern (prefix matching)
- 🔑 **Salt Prefix Support**: Generate salts with fixed prefixes for Solady CREATE2 factory
- ⏱️ **Real-time Stats**: Live hash rate monitoring during mining
- 🔧 **Easy Configuration**: CLI arguments for all search parameters
## Installation
### Standard Build (CPU only)
```bash
git clone https://github.com/hadv/vaneth.git
cd vaneth
go build
```
### Build with GPU Support
#### macOS (OpenCL)
For GPU acceleration on macOS with AMD GPUs:
```bash
make build-gpu
```
**Requirements:**
- macOS with OpenCL framework (built-in)
- AMD GPU (e.g., Radeon Pro 555X, 560X, 5500M, etc.)
- CGO enabled (default on macOS)
#### Linux (OpenCL)
For GPU acceleration on Linux using OpenCL (supports AMD, NVIDIA, and Intel GPUs):
```bash
# Install OpenCL development libraries
# Ubuntu/Debian:
sudo apt install opencl-headers ocl-icd-opencl-dev
# For NVIDIA GPUs, also install:
sudo apt install nvidia-opencl-dev
# For AMD GPUs, install ROCm or AMDGPU-PRO drivers
# Build with OpenCL support
make build-gpu
```
**Requirements:**
- OpenCL 1.2+ runtime and headers
- Compatible GPU with OpenCL drivers installed
- CGO enabled
#### Linux (CUDA - NVIDIA GPUs)
For native CUDA acceleration on Linux with NVIDIA GPUs (recommended for NVIDIA hardware):
```bash
# Install NVIDIA CUDA Toolkit (Ubuntu/Debian)
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt update
sudo apt install cuda-toolkit
# Add CUDA to PATH (add to ~/.bashrc for persistence)
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
# Verify nvcc is available
nvcc --version
# Build with CUDA support
make build-cuda
```
**Requirements:**
- Linux operating system
- NVIDIA GPU with Compute Capability 5.0+ (Maxwell architecture or newer, ~2014+)
- NVIDIA CUDA Toolkit 11.0+
- `nvcc` compiler in PATH
- CGO enabled
**Supported NVIDIA GPUs:**
- GeForce GTX 750 Ti and newer
- GeForce GTX 900/1000/1600/2000/3000/4000 series
- Tesla K80 and newer
- Quadro M series and newer
## Usage
### Standard CREATE2 Deployment
#### 1. Configure the Search Parameters
Edit `main.go` and set these values:
```go
deployerAddress := common.HexToAddress("0x18Ee4C040568238643C07e7aFd6c53efc196D26b") // Your deployer address
initCodeHashStr := "ed6d47ef8858bf77ca8c43589269de4a0242b881ab9d2f8704546ce86ab20879" // keccak256(init_code)
pattern := "0x00000000" // Pattern to search for
numCores := runtime.NumCPU() // CPU cores to use
numGoroutines := numCores * 100 // Goroutines per core
```
#### 2. Get Your Init Code Hash
The init code hash is the keccak256 hash of your contract's creation bytecode. You can get this from:
- Hardhat/Foundry deployment scripts
- Remix compiler output
- Or calculate it manually: `keccak256(type(YourContract).creationCode)`
#### 3. Run the Program
```bash
./vaneth
```
#### 4. Example Output
```
Searching for CREATE2 address starting with '0x00000000'...
Deployer: 0x0000000000FFe8B47B3e2130213B802212439497
Init Code Hash: 0x747dd63dfae991117debeb008f2fb0533bb59a6eee74ba0e197e21099d034c7a
Using 12 CPU cores with 9600 goroutines
Found!
Salt: 0x18ee4c040568238643c07e7afd6c53efc196d26bb3aa4a73c14310c5a4a12b1b
Address: 0x000000006e38ec9e8074ed84cbcbf4b9d8773b7e
Time elapsed: 2m51.724719347s
```
### Using Solady CREATE2 Factory
The Solady CREATE2 factory requires salts with a specific prefix (the caller's address). This tool supports generating salts with fixed prefixes.
#### Configuration for Solady Factory
The current configuration in `main.go` is set up for the Solady CREATE2 factory:
```go
// Solady CREATE2 Factory Configuration
deployerAddress := common.HexToAddress("0x0000000000ffe8b47b3e2130213b802212439497") // Solady factory address
initCodeHashStr := "747dd63dfae991117debeb008f2fb0533bb59a6eee74ba0e197e21099d034c7a" // Your contract's init code hash
pattern := "0x000000" // Pattern to search for
// Salt prefix (pre-calculated outside the loop for performance)
saltPrefix := common.HexToAddress("0x18Ee4C040568238643C07e7aFd6c53efc196D26b") // Your address (caller)
```
#### How Salt Prefix Works
- **First 20 bytes**: Fixed prefix (your address as the caller)
- **Last 12 bytes**: Randomly generated
- The prefix is pre-calculated once for optimal performance
#### Deploying with Solady Factory
Once you find a matching salt, deploy using the Solady CREATE2 factory:
```solidity
// Solady CREATE2 factory interface
interface ICreate2Factory {
function deploy(bytes32 salt, bytes memory initCode) external returns (address);
}
// Deploy your contract
ICreate2Factory factory = ICreate2Factory(0x0000000000FFe8B47B3e2130213B802212439497);
bytes memory initCode = type(YourContract).creationCode;
bytes32 salt = 0x18Ee4C040568238643C07e7aFd6c53efc196D26b000000000000000000000123; // Salt found by the tool
address deployed = factory.deploy(salt, initCode);
```
#### Key Points
- The Solady factory is deployed at: `0x0000000000FFe8B47B3e2130213B802212439497`
- The factory automatically prepends the caller's address to the salt
- Your salt prefix must match your deploying address
- The tool optimizes by only randomizing the last 12 bytes
### SIMD Mode (Recommended for CPU)
SIMD mode uses AVX2 instructions to compute 4 Keccak256 hashes in parallel, providing up to **10x faster** mining compared to standard CPU mode.
```bash
./vaneth --simd \
-i 747dd63dfae991117debeb008f2fb0533bb59a6eee74ba0e197e21099d034c7a \
-s 0x18Ee4C040568238643C07e7aFd6c53efc196D26b \
-p 0x00000000
```
**Requirements:**
- CPU with AVX2 support (Intel Haswell 2013+ or AMD Excavator 2015+)
- Automatically falls back to standard CPU mode if AVX2 is not available
### GPU Mode
GPU acceleration provides significantly faster mining compared to CPU mode.
#### Command-Line Options
| Flag | Description | Default |
|------|-------------|---------|
| `--simd` | Enable SIMD-optimized CPU miner (AVX2) | `false` |
| `--gpu`, `-g` | Enable GPU mode | `false` |
| `--gpu-backend` | GPU backend: `opencl`, `cuda`, or `auto` | `opencl` |
| `--gpu-device` | GPU device index | `0` |
| `--batch-size` | Hashes per GPU batch | `5000000` |
| `--list-gpus` | List available GPUs and exit | - |
#### List Available GPUs
```bash
# List OpenCL GPUs (macOS/Linux)
./vaneth --list-gpus
# List CUDA GPUs (Linux with NVIDIA)
./vaneth --list-gpus --gpu-backend cuda
```
Example output (OpenCL):
```
Available GPUs:
[0] Intel(R) UHD Graphics 630
[1] AMD Radeon Pro 555X Compute Engine
```
Example output (CUDA):
```
Found 1 CUDA GPU device(s):
Device 0: NVIDIA GeForce RTX 3080
Compute Units (SMs): 68
Max Threads per Block: 1024
Total Memory: 10240 MB
```
#### Run with OpenCL (macOS/Linux)
```bash
./vaneth --gpu --gpu-device 1 \
-i 747dd63dfae991117debeb008f2fb0533bb59a6eee74ba0e197e21099d034c7a \
-s 0x18Ee4C040568238643C07e7aFd6c53efc196D26b \
-p 0x0000
```
#### Run with CUDA (Linux with NVIDIA GPU)
```bash
./vaneth --gpu --gpu-backend cuda \
-i 747dd63dfae991117debeb008f2fb0533bb59a6eee74ba0e197e21099d034c7a \
-s 0x18Ee4C040568238643C07e7aFd6c53efc196D26b \
-p 0x0000
```
#### Auto-detect GPU Backend
The `auto` backend tries CUDA first, then falls back to OpenCL:
```bash
./vaneth --gpu --gpu-backend auto \
-i 747dd63dfae991117debeb008f2fb0533bb59a6eee74ba0e197e21099d034c7a \
-s 0x18Ee4C040568238643C07e7aFd6c53efc196D26b \
-p 0x0000
```
#### GPU Example Output
```
Searching for CREATE2 address starting with '0x0000'...
Deployer: 0x0000000000FFe8B47B3e2130213B802212439497
Salt Prefix: 0x18Ee4C040568238643C07e7aFd6c53efc196D26b
Init Code Hash: 0x747dd63dfae991117debeb008f2fb0533bb59a6eee74ba0e197e21099d034c7a
Using GPU: AMD Radeon Pro 555X Compute Engine
Batch size: 5000000 hashes per iteration
Found!
Salt: 0x18ee4c040568238643c07e7afd6c53efc196d26b000000000000000000004030
Address: 0x0000e628d423549be95a4113c4b59765b6cee09d
Time elapsed: 56.4974ms
Total hashes: 5000000
Hash rate: 88.50 MH/s
```
## Performance Comparison
### CPU Mode Comparison (Standard vs SIMD)
| Mode | Throughput | Speedup |
|------|------------|---------|
| Standard CPU (single thread) | ~1.5 MH/s | baseline |
| SIMD CPU (single thread) | ~5-6 MH/s | **~4x** |
| Standard CPU (12 cores) | ~4 MH/s | baseline |
| SIMD CPU (12 cores) | ~35-40 MH/s | **~10x** |
*SIMD mode uses AVX2 4-way parallel Keccak256 with zero allocations*
### CPU vs GPU Performance
| Pattern | Standard CPU | SIMD CPU | GPU (OpenCL) |
|---------|--------------|----------|--------------|
| `0x0000` (4 hex) | ~73ms | ~7ms | ~57ms |
| `0x000000` (6 hex) | ~18s | ~2s | ~1.5s |
| `0x00000000` (8 hex) | ~5-8 min | ~30-60s | ~30-60s |
*Tested on MacBook Pro with Intel i7-9750H (12 threads) and AMD Radeon Pro 555X*
### GPU Tips
- **Thermal Management**: MacBooks may throttle under heavy GPU load. Monitor temperatures.
- **Power**: Keep the laptop plugged in for best GPU performance.
- **Batch Size**: Larger batch sizes improve throughput but increase memory usage.
- **Device Selection**: Use `--list-gpus` to find your discrete GPU (usually index 1 on MacBooks).
## Performance Tuning
### CPU Cores
```go
// Use all available cores (default)
numCores := runtime.NumCPU()
// Limit to specific number
numCores := 8
// Use half of available cores
numCores := runtime.NumCPU() / 2
```
### Goroutines
```go
// Light load
numGoroutines := numCores * 10
// Balanced (recommended)
numGoroutines := numCores * 100
// Heavy load
numGoroutines := numCores * 1000
```
## Pattern Difficulty
The difficulty increases exponentially with pattern length:
| Pattern Length | Approximate Attempts | Time (estimate) |
|---------------|---------------------|--------------------|
| 6 hex chars | ~16 million | seconds ~ minutes |
| 8 hex chars | ~4 billion | minutes ~ hours |
| 10 hex chars | ~1 trillion | hours ~ days |
## How It Works
1. **Pre-calculation**: Pattern bytes and deployer address bytes are calculated once
2. **Parallel Search**: Multiple goroutines generate random salts concurrently
3. **CREATE2 Calculation**: Each salt is used to compute the resulting contract address
4. **Direct Comparison**: Bytes are compared directly (no string operations)
5. **Early Exit**: Stops immediately when a match is found
## Optimizations
### CPU Mode (Standard)
- ✅ Direct byte comparison (no string allocations)
- ✅ Pre-calculated pattern and deployer bytes
- ✅ Pre-calculated salt prefix (for Solady factory mode)
- ✅ Returns bytes directly from CREATE2 calculation
- ✅ Early exit on byte mismatch
- ✅ Fast PRNG (xoroshiro128+) instead of crypto/rand (~800x faster)
- ✅ Zero-allocation hashing with pre-allocated buffers
- ✅ Multi-core parallel processing
- ✅ Real-time hash rate monitoring
### CPU Mode (SIMD)
- ✅ All standard CPU optimizations plus:
- ✅ AVX2 4-way parallel Keccak256 (Cloudflare CIRCL library)
- ✅ Computes 4 hashes simultaneously per CPU core
- ✅ Zero allocations in hot path (0 B/op)
- ✅ ~10x faster than standard CPU mode
### GPU Mode (OpenCL - macOS/Linux)
- ✅ OpenCL 1.2 compatible (native macOS support, Linux with drivers)
- ✅ Optimized Keccak256 kernel implementation
- ✅ Batch processing (millions of hashes per kernel launch)
- ✅ Atomic operations for early exit on match
- ✅ Efficient memory transfers between CPU and GPU
- ✅ Support for Intel, AMD, and NVIDIA GPUs
### GPU Mode (CUDA - Linux)
- ✅ Native NVIDIA GPU support via CUDA
- ✅ Optimized Keccak256 kernel with `__constant__` memory
- ✅ Loop unrolling with `#pragma unroll` for performance
- ✅ Batch processing (millions of hashes per kernel launch)
- ✅ Atomic operations (`atomicCAS`) for thread-safe early exit
- ✅ Efficient memory management with device memory allocation
- ✅ Support for Compute Capability 5.0+ (Maxwell and newer)
## Use the Salt in Your Contract
Once you find a salt, use it in your Solidity contract:
```solidity
contract Factory {
function deploy(bytes32 salt) public {
bytes memory bytecode = type(YourContract).creationCode;
address addr;
assembly {
addr := create2(0, add(bytecode, 0x20), mload(bytecode), salt)
}
require(addr != address(0), "Deploy failed");
}
}
```
## License
MIT License - see [LICENSE](LICENSE) file for details
## Contributing
Contributions are welcome! Feel free to open issues or submit pull requests.
## Author
Ha ĐANG ([@hadv](https://github.com/hadv))