https://github.com/patronum-labs/vanity-create2
Script that generates vanity addresses based on CREATE2 Factory and a regex provided by the developer.
https://github.com/patronum-labs/vanity-create2
create2 hardhat regex vanity vanity-address
Last synced: about 2 months ago
JSON representation
Script that generates vanity addresses based on CREATE2 Factory and a regex provided by the developer.
- Host: GitHub
- URL: https://github.com/patronum-labs/vanity-create2
- Owner: Patronum-Labs
- License: mit
- Created: 2024-07-18T09:13:38.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-13T23:47:37.000Z (over 1 year ago)
- Last Synced: 2025-03-11T11:34:56.650Z (11 months ago)
- Topics: create2, hardhat, regex, vanity, vanity-address
- Language: TypeScript
- Homepage:
- Size: 76.2 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# @patronumlabs/vanity-create2
[](https://opensource.org/license/mit)
This repository provides a simple Hardhat TypeScript script that reads the bytecode of compiled contracts and generates vanity addresses based on regex provided by the developer.
## Rationale
While there are more efficient and faster examples with Rust, this script is practical for simple use cases. It can still generate very unique addresses in a short amount of time, depending on the machine's worker count.
## Benchmark
The performance of this salt generation tool heavily depends on the complexity of the regex pattern used for matching addresses. Here are some approximate benchmarks:
- **Simple regex (e.g., matching 2 characters):**
- Approximately 10 salt found in 1 second.
- **More complex regex (e.g., matching 4 characters):**
- Approximately 1 salt found every ~9 seconds.
Please note that these benchmarks are approximations and may vary based on the specific regex pattern, hardware specifications, and other factors.
## Usage
1- Clone the repository:
```bash
git clone https://github.com/Patronum-Labs/vanity-create2.git
cd vanity-create2
```
2- Install the dependencies:
```bash
npm install
```
3- Compile the contracts:
```bash
npm run build
```
4- Update the script:
* Bytecode of the contract to deploy
* [Regex Tester](https://regexr.com/)
* [Find how many CPU cores do you have - Windows](https://www.pcworld.com/article/395047/how-many-cpu-cores-do-you-have.html)
* [Find how many CPU cores do you have - Mac](https://support.macincloud.com/support/solutions/articles/8000087401-how-can-i-check-the-number-of-cpu-cores-on-a-mac#:~:text=Navigate%20towards%20the%20top%20left,of%20%22Total%20number%20of%20Cores%22)
```typescript
// Constants
import { bytecode} from "../artifacts/contracts/Lock.sol/Lock.json"; // Either import or set it as a predefined const
const FROM = "0x16A2DDa7E466aE460C5ADd1fBc64dfB8B96E11fb"; // Adjust this based on the address of the create2 deployer
const ADDRESS_REGEX = /^0x*cafe/i; // Adjust this based on the pattern of the address you want to find
const WORKER_COUNT = 16; // Adjust this based on your CPU core count
const ITERATIONS_PER_WORKER = 1_000_000; // Number of random salts generated by each worker
```
5- Run the script:
```typescript
npm run vanity
```
## Output
Salts will be written to the root in `Salt.txt`.
> On each new run, **Salt.txt** will be reset with new values.
```txt
Salt found: 0x6fb12b5567149cdb2841347ad3d340c8467acaa0c318f4c0833fe2e06c4b489a with address: 0x420000f09404F9Eb873E1F28eC779C420428A479
Salt found: 0xa976da044659a80d9036ee81644785e32632b5e87939b71fd9b59d037728b2f4 with address: 0x42000058bc71b1e667a6d07659F40b034FC62EBa
Salt found: 0x2eff16418021ac5a12dc9396bb23603a0d6850136c86368149b7b6ab0841f1e2 with address: 0x42000d47f22d22118754A54Af2d2460E7AD3362E
Salt found: 0xc867a2261180a84d339887e0a0eab323dd047bea12df50cdc73726e2551cc20c with address: 0x420006D51C4b516B015dF9Bf4F6e3d9dc1B08D5B
Salt found: 0x3cf1ea0dcf3a6a5e529e03a89e4be10eb6ce365d0852a597018859708a4776c5 with address: 0x4200062dB414f84AeD8c4313cF9499a05F51406E
Salt found: 0x334604a5f60501e927faffdb03bbf2808fc43e44985cc9bc3e25a99e18cc0e05 with address: 0x420000212B9c35ac18F990296b6D69B46Db4b836
Salt found: 0x00ec2cd9f9d1ef51d63e3479b13d64bdd07a64db85ca94d91a2541def658116e with address: 0x420004888De2eDd4e6064fF9591cf337459Fc788
Salt found: 0x38d3607f952149d53e16f52da383943a06d357731a63e9caa2171a3def2addc3 with address: 0x420005D5C3627EA6C66ed8A54a56E4Bc0C412dd3
Salt found: 0x733a1c7172b060e993be7357d8b45588012753812540071ece81b917316249f9 with address: 0x42000285E7a44C6108FE0cF073275A101823e913
Salt found: 0x589abe3b9a8fd5910e9def304ae022b042d5262180dcadb3f1cbe0bb01d9000c with address: 0x42000135982B4abaAd9747bc57e50498A7d2670e
Salt found: 0x9dbf14473d0d7d03150db392f62f2597bb4642fa5662c64217ca209b308d018a with address: 0x420004eb8ed9e55EB15e0109521537D1E09322B4
Salt found: 0x333348774c311d982146e2beedea45b2d352bbca2920104f92aca65a57622733 with address: 0x42000386f1F4ae876b6886be496f1F9Ebd971843
Salt found: 0x2c4cdba1261f6129b46d51e943e14af5b4ffbdd94cd749786828400d69b49147 with address: 0x42000d40F8F85348b4aD1FDF6A7D09Ce7fE0A4EE
Salt found: 0x89fe46c5d0d382d5a18785b723d0362e80ef1a0d89c50659ada1d86135d73669 with address: 0x4200066986a280E0A77E1F1AA35Dfc9F4213CA68
Salt found: 0x2dc4ee7d9534c8637ed8dd6a8336b12f5eb90330789ee9241758c531f81d798b with address: 0x4200062e6E051bF6Df631466CfB99FbEccaafe8e
...
```
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
[MIT License](LICENSE)