Hyper-parallelized vanity address generator for the Aptos blockchain
% git clone https://github.com/econia-labs/optivanity.git
% cd optivanity
% cargo run --release -- --help
Optivanity: hyper-parallelized vanity address generator for the Aptos blockchain, brought to you by Econia Labs
Usage: optivanity [OPTIONS]
Options:
-p, --prefix <PREFIX> Address prefix to match (no leading `0x`). Each additional character slows search by 16x
-s, --suffix <SUFFIX> Address suffix to match. Each additional character slows search by 16x
-m, --multisig Use this flag if you want to search for multisig address(es)
-c, --count <COUNT> Number of vanity accounts to generate [default: 1]
-t, --threads <THREADS> Number of threads to use. Only specify if you want to use fewer cores than available [default: 10]
-h, --help Print help
# Generate a single standard account address starting with aaa, ending with bbb, maximum parallelism
% cargo run --release -- --prefix aaa --suffix bbb
Estimate: 0 minutes
Standard account address: 0xaaa52f2e7402b0b1987ec565cc355e720bfb143167be59fd74bb52d31e316bbb
Private key: 0x502b8b67570b98aba3a69649dbbb3675e633072729457be2638a5670172e9db9
Elapsed time: 15.170995791s
Total addresses generated: 8475543
# Generate 3 multisig account addresses starting with bbbbbb, parallelized across 8 cores
% cargo run --release -- --prefix bbbb --multisig --count 3 --threads 8
Multisig account address: 0xbbbb60b209c9115aed317b5e625c00be02cf4759d9a7f0a80ec5713afab1a46d
Standard account address: 0x01cceb1533cd8502bbee964b6f61cf2c97802fe02c1bd566208dec3aeb84b312
Private key: 0x28fceaad60c41da43509fc53646e879e3e0063c814ca01dc607627d6d0c5a7b6
Multisig account address: 0xbbbb44d05e29c1441f0ed2c0cbd51d1e05a933790059d984fb5ef551714e3060
Standard account address: 0x556365fcc5239c5c1b6df2aaea7e05391de657d0fc052dd4a3f193747e66765b
Private key: 0xde9e028a071a4b3de8066294a0d16639853819d56744b01d313e1d58c1ec9b45
Multisig account address: 0xbbbbdcf9d8df88dc5669f4ef970685ba36bcf161d0eecd32db917c9d29102f31
Standard account address: 0xad07cb201013bf3d7947130973bf430be51eabba1313a7adf58a870bc33793f7
Private key: 0x34565d5df3da025423da9719807b552f642dcd1f28621d9b1044db0c83e6a2ec
Elapsed time: 354.077237ms
Total addresses generated: 190621
optivanity
provides vanity address generation functionality similar to that of the aptos
CLI, but with assorted performance optimizations:
- Thread count argument for configurable execution parallelism (defaults to maximum possible parallelism)
- Byte-wise search, instead of expensive string-wise search like in the
aptos
CLI - Build enhancements including linker-time optimization and code generation unit minimization
- Minimal crate includes for reduced compile times compared with
aptos
CLI
Don't forget to use cargo
's --release
flag for maximal build performance!
The optional thread count argument controls how many independent search threads will be initiated during execution, and defaults to the maximum amount possible on your machine.
Two search threads running in parallel, for example, will on average take aptos
CLI uses.
Three threads will on average take
In other words, only specify thread count if you want to slow down the search for machine longevity.
The algorithms in optivanity
were developed on a 2021 MacBook Pro with a ten-core Apple M1 Max chip, where the optimal thread count for search speed is ten.
This is probably not the optimal thread count for machine longevity, however, because a ten-thread search results in the fan running full blast to prevent overheating.
Running with only six threads does not result in the fan noticeably turning on and is sufficient, for example, to generate an address with an eight-character vanity prefix overnight.
optivanity
relies on a two watchdog threads that close the search threads once enough addresses have been generated.
Hence for the "Activity Monitor" app on the above machine, the following command results in the following readout:
cargo run --release -- --prefix aaaaa --threads 6 --count 100
Process Name | % CPU | Threads |
---|---|---|
optivanity |
600 | 8 |
Here, six cores are each running a search thread at ~100% capacity, with a seventh non-search thread consuming almost no load. Hence without other major processes running, this results in a user CPU load of about 60%.