Vanity addresses on the blockchain: how they're made and what can go wrong

GoldRush TeamUpdated 14 min read

A vanity address is a crypto address with a chosen pattern, found by brute force. How they are made, CREATE2 vanity contracts, Profanity and address poisoning.

A vanity address is a normal blockchain address that happens to contain a pattern someone chose, such as an Ethereum address starting 0xdead… or a Bitcoin address starting 1Love…. Nobody can pick an address directly, because an address is derived from a key by a one-way hash, so a vanity address is found by brute force: generate key pairs (or, for contracts, deployment salts) until one produces the pattern. Each extra hex character you ask for on Ethereum makes the search 16 times longer. A vanity address is as secure as any other only if its key came from a sound random source; the 2022 Profanity bug, which cost Wintermute about $160 million, showed what happens when it doesn't.

What a vanity address is

An address is a short fingerprint of a public key. On Ethereum it is the last 20 bytes of the Keccak-256 hash of the public key, written as 0x and 40 hex characters (ethereum.org: accounts). On Bitcoin, legacy addresses are a hash of the public key in Base58Check and start with 1 (or 3 for script addresses); SegWit addresses use Bech32 and start with bc1q (BIP-173), Taproot addresses bc1p (BIP-350).

Because the hash output looks random, the only way to get a chosen pattern is to keep generating keys and hashing until one matches. The result is an ordinary address: the network can't tell it apart from any other, and it has the same 160 bits of address space. People want them for three reasons:

  • Recognition. A donation or treasury address that starts with a project's name is easier to recognise.
  • Gas. Ethereum charges less for zero bytes in transaction data than for non-zero ones (EIP-2028: 4 gas against 16), so contracts and bots called very often sometimes use addresses with many leading zeros.
  • Function. Some protocols read meaning from the address itself. A Uniswap v4 hook declares which callbacks it implements in the low bits of its address, so every hook has to be deployed to a mined address (Uniswap docs).

How vanity addresses are generated

The loop is the same everywhere: pick a random private key, derive the public key, derive the address, test the pattern, repeat. The cost is set by how rare the pattern is.

  • Ethereum (hex). Each hex character has 16 values, so a prefix of n characters takes 16n attempts on average.
  • Bitcoin legacy (Base58). Each character after the leading 1 multiplies the work by roughly 58. The Bitcoin Wiki's Vanitygen page lists 1Bitco at about 260 million attempts and 1Bitcoin at about 870 billion.
  • Bitcoin Bech32. The alphabet has 32 characters, so each one after bc1q multiplies the work by 32.
Ethereum prefix length Average attempts At 3,000 keys a second (one CPU core, JavaScript)
3 hex characters 4,096 about 1 second
4 65,536 about 22 seconds
6 16,777,216 about an hour and a half
8 4,294,967,296 about 17 days
10 1.1 trillion about 12 years

GPU generators are orders of magnitude faster than the JavaScript below, which is why 8 to 10 character prefixes are common in practice. Matching a prefix and a suffix costs the same as one pattern of the combined length.

Case makes Ethereum patterns harder

Ethereum addresses are case-insensitive, but EIP-55 writes them in a checksummed mixed case: whether each letter a–f is upper or lower case comes from a hash of the address. If you want the pattern in a particular case, say 0xABC… rather than 0xabc… or 0xAbC…, each letter in it halves your odds, so ABC takes 4,096 × 2³ = 32,768 attempts on average. Digits have no case and cost nothing extra.

A vanity address generator in JavaScript

This uses viem to generate random private keys until the checksummed address starts with the prefix you give, optionally in exact case. The scripts in this guide need Node.js 18 or later and viem, pinned to the version they were run with:

npm install viem@2.52.2

They are ES modules (they use import), so save this one as vanity.mjs and run node vanity.mjs abc, or node vanity.mjs ABC --exact to match the case too:

import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"; // Generate key pairs until the address starts with `prefix` (hex digits after 0x).// exact: also match the EIP-55 checksum case of each letter.function findVanity(prefix, { exact = false } = {}) {    const want = exact ? prefix : prefix.toLowerCase();    for (let attempts = 1; ; attempts++) {        const privateKey = generatePrivateKey(); // 32 bytes from crypto.getRandomValues        const { address } = privateKeyToAccount(privateKey); // EIP-55 checksummed        const head = address.slice(2, 2 + want.length);        if ((exact ? head : head.toLowerCase()) === want) {            return { address, privateKey, attempts };        }    }} const [prefix = "abc", flag] = process.argv.slice(2);const exact = flag === "--exact";const start = performance.now();const { address, attempts } = findVanity(prefix, { exact });const seconds = ((performance.now() - start) / 1000).toFixed(1);console.log(`${address} after ${attempts.toLocaleString("en-US")} attempts (${seconds}s)`);// In real use, write privateKey to an encrypted keystore; never log it.

We ran it on 20 November 2026. node vanity.mjs abc printed 0xABC687B15C523A2edafBe641F696F2fB69beAA07 after 1,159 attempts (0.4s), and node vanity.mjs ABC --exact printed 0xABC3dD0664695495eAB0f7E4bC6F9450dc4E60fe after 1,471 attempts (0.4s). The second was lucky: the average for an exact-case ABC is 32,768, and an earlier exact-case run took 17,124 attempts. Every key is independent, so the count varies a lot from run to run.

The important line is generatePrivateKey(): each key is 32 fresh bytes from the operating system's cryptographic random source. That is what keeps a vanity address as safe as any other. Fast GPU generators skip this to save time, which is where things go wrong.

Vanity contract addresses with CREATE2

A contract's address doesn't come from a key. With the CREATE2 opcode (EIP-1014) it is the last 20 bytes of keccak256(0xff ++ deployer ++ salt ++ keccak256(init_code)). The deployer and the code are fixed, so you search over the 32-byte salt instead of over private keys: "salt mining". There is no secret involved, so a weak random source can't leak anything, and the same deployer, salt and init code give the same address on every chain where that deployer exists.

Projects use this for gas and for show. Uniswap ran a public address mining challenge in November 2024 to pick the v4 PoolManager address, scoring each submission on leading zero nibbles and 4s; hook developers mine salts with Uniswap's HookMiner so the address carries the right permission bits.

This checks viem's CREATE2 derivation against EIP-1014's first example, then mines a salt for a four-zero prefix. Save it as create2-salt.mjs and run node create2-salt.mjs:

import { getContractAddress, keccak256, numberToHex } from "viem"; // EIP-1014 example 0: zero deployer, zero salt, init code 0x00.console.log(    getContractAddress({        opcode: "CREATE2",        from: "0x0000000000000000000000000000000000000000",        salt: numberToHex(0n, { size: 32 }),        bytecode: "0x00",    })); // 0x4D1A2e2bB4F88F0250f26Ffff098B0b30B26BF38 // Mine a salt so the address starts with `prefix`. The init code is fixed, so hash it once.function mineSalt(deployer, initCode, prefix) {    const bytecodeHash = keccak256(initCode);    for (let i = 0n; ; i++) {        const salt = numberToHex(i, { size: 32 });        const address = getContractAddress({ opcode: "CREATE2", from: deployer, salt, bytecodeHash });        if (address.slice(2, 2 + prefix.length).toLowerCase() === prefix) {            return { salt, address, attempts: Number(i) + 1 };        }    }} const DEPLOYER = "0x4e59b44847b379578588920cA78FbF26c0B4956C"; // the deterministic deployment proxyconst INIT_CODE = "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe"; // stand-in: use your contract's creation codeconst start = performance.now();const { salt, address, attempts } = mineSalt(DEPLOYER, INIT_CODE, "0000");console.log({ salt, address, attempts, seconds: ((performance.now() - start) / 1000).toFixed(1) });

On 20 November 2026 the first line printed EIP-1014's expected 0x4D1A2e2bB4F88F0250f26Ffff098B0b30B26BF38, and the miner found salt 0x…40ef giving 0x0000217b38BB1ed9D288360a9C75422A1aAD699b after 16,624 attempts in 0.8 seconds (the average for four hex characters is 65,536). Salt mining is much faster than key search because each attempt is one Keccak hash rather than an elliptic-curve multiplication and a hash.

The init code includes the constructor arguments, so a salt mined for one set of arguments is useless for another. The Ethereum contract address guide covers CREATE and CREATE2 derivation in more depth.

The Profanity vulnerability and the Wintermute loss

Profanity was a popular GPU vanity generator for Ethereum. On 15 September 2022, 1inch disclosed that it seeded its 256-bit private keys from a random 32-bit value. That leaves only about 4.3 billion possible starting points, and Profanity derived every candidate key from its seed deterministically. Given a vanity address's public key, which anyone can recover from one signed transaction, an attacker can walk back to the seed and recover the private key; 1inch said its proof of concept did that in roughly the time it took to generate the address. 1inch advised moving all funds out of Profanity addresses and changing the owner of any contract whose vanity address Profanity made. The author archived the Profanity repository the same day with the warning "I strongly advice against using this tool in its current state."

On 20 September 2022 the market maker Wintermute lost about $160 million from the vault it used for DeFi trading. The vault's admin address started 0x0000000, and Wintermute's CEO, Evgeny Gaevoy, attributed the hack to a "Profanity-type exploit", saying the many leading zeros were for gas optimisation, not vanity (The Block). Researchers cited by The Block said the firm had moved its ETH off the address but had not removed its admin rights. Amber Group later reproduced the attack, recovering the key in 48 hours on a MacBook.

The lessons are specific:

  • The pattern isn't the risk; the key generation is. A vanity address from a cryptographic random source is fine. One from a tool that cuts corners on randomness can be predictable.
  • Retire keys as well as balances. An address that still holds admin rights, token approvals or contract ownership is still live after you empty it.
  • Generate offline, with open-source code you can read. Never use a website that generates a vanity key for you: whoever runs it can keep the key.
  • Contracts don't need vanity keys. Mine a CREATE2 salt instead, so no private key is involved.

Address poisoning: vanity generation as an attack

Vanity generation is also an attacker's tool. Wallets and explorers often shorten addresses to their first and last few characters (0xa0b1…c3d4), and people check only those. In address poisoning, an attacker watches for wallets that send funds, mines an address with the same first and last characters as one of the victim's real recipients, and plants it in the victim's transaction history, hoping the victim copies it from there next time.

There are a few ways to plant it:

  • Zero-value transfers. EIP-20 requires zero-value transfers to be treated as normal transfers and to emit a Transfer event, and many tokens let anyone call transferFrom for zero tokens without an allowance. The attacker sends a transaction that "moves" 0 USDT from the victim to the lookalike, so the victim's history shows an outgoing transfer the victim never signed.
  • Fake tokens. A token contract with a copied name and ticker emits transfers from the lookalike address.
  • Dust. A tiny real amount sent from the lookalike to the victim.

Researchers at Carnegie Mellon measured two years of Ethereum and BNB Chain activity and found 270 million poisoning attempts aimed at 17 million victims, with 6,633 successful incidents costing at least $83.8 million (Tsuchiya et al., USENIX Security 2025).

The defence is to never copy a recipient from your transaction history, and to compare whole addresses, in code where you can.

Check a recipient before you send

A wallet or payment tool can check a pasted recipient against the sender's own history before it signs. GoldRush's Wallet Transaction History API (transactions_v3) returns a wallet's most recent transactions on a chain, each with its from_address, to_address, value, successful flag and decoded log_events, so token transfers show up as Transfer events with from, to and value. It costs 0.1 per item.

This script builds the set of addresses the wallet really sent value to, in transactions it signed, and then flags a recipient that looks like one of them, or that appears in a token transfer "from" the wallet that someone else sent. It needs a GoldRush API key in the GOLDRUSH_API_KEY environment variable and uses top-level await: save it as check-recipient.mjs and run node check-recipient.mjs <wallet> <recipient>.

const API = "https://api.covalenthq.com/v1";const headers = { Authorization: `Bearer ${process.env.GOLDRUSH_API_KEY}` }; // The wallet's most recent transactions on one chain (first page only).async function recentTransactions(chain, wallet) {    const res = await fetch(`${API}/${chain}/address/${wallet}/transactions_v3/`, { headers });    if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);    const { data } = await res.json();    return data.items;} const lower = (a) => a.toLowerCase();// Same first 4 and last 4 hex characters, but a different address: what a poisoner mines for.const looksAlike = (a, b) => a !== b && a.slice(2, 6) === b.slice(2, 6) && a.slice(-4) === b.slice(-4); // Has `wallet` really sent to `recipient` before, or is `recipient` a lookalike of an address it has?function checkRecipient(items, wallet, recipient) {    const me = lower(wallet);    const to = lower(recipient);    const sentTo = new Set(); // addresses this wallet sent native or token value to, in txs it signed    const unsignedFromMe = []; // token transfers "from" this wallet in txs someone else sent    for (const tx of items) {        const signed = lower(tx.from_address) === me;        if (signed && tx.successful && tx.to_address && tx.value !== "0") sentTo.add(lower(tx.to_address));        for (const log of tx.log_events ?? []) {            if (log.decoded?.name !== "Transfer") continue;            const p = Object.fromEntries(log.decoded.params.map((x) => [x.name, x.value]));            if (!p.from || !p.to || lower(p.from) !== me) continue;            if (signed && tx.successful) sentTo.add(lower(p.to));            else unsignedFromMe.push({ tx: tx.tx_hash, to: lower(p.to), value: p.value });        }    }    if (sentTo.has(to)) return { verdict: "sent to before" };    const lookalikeOf = [...sentTo].filter((a) => looksAlike(a, to));    const planted = unsignedFromMe.filter((t) => t.to === to);    if (lookalikeOf.length || planted.length) return { verdict: "DO NOT SEND", lookalikeOf, planted };    return { verdict: "new recipient: confirm it out of band" };} const [wallet, recipient] = process.argv.slice(2);const items = await recentTransactions("eth-mainnet", wallet);console.log(checkRecipient(items, wallet, recipient));

We ran checkRecipient against a made-up two-transaction history in the documented response shape: a real 25,000 USDT send from the wallet to 0xa0b17e2f…c3d4, then a 0 USDT transferFrom that another address sent, "from" the wallet to the lookalike 0xa0b1c2d3…c3d4. Pasting the lookalike returned DO NOT SEND, naming the real recipient it imitates and the planted transfer; pasting the real address returned sent to before.

  • It reads the first page only. For a long history, follow data.links.next or narrow by time; older counterparties won't be in the set otherwise.
  • 4 + 4 characters is a heuristic. Poisoners match whatever the victim's wallet displays; widen the comparison if yours shows more.
  • A clean result isn't proof. "New recipient" means only that nothing in this history matches. Confirm a new address through another channel before sending a large amount.

If funds have already gone to a poisoned address, GoldRush's Fund Flow Tracer follows where they went and looks for the cause, including address poisoning, a phishing approval or a leaked key.

Handle errors from the transaction history API

A failed call returns the same envelope as a successful one, with data set to null. The GoldRush error handling docs show this body for a chain name the API doesn't recognise, such as a typo in eth-mainnet:

{ "data": null, "error": true, "error_message": "Chain nosuchchain-mainnet not supported.", "error_code": 501 }

error_code is a JSON number and always equals the HTTP status, so the if (!res.ok) check in recentTransactions throws with the status and this message, and the script stops before it gives a verdict. A 501 means the chain or endpoint can't serve the request, so retrying it unchanged won't succeed: fix the chain name. A wrong or malformed key returns a JSON 401 in the same envelope, but a request with no Authorization header at all gets an HTML page from the edge proxy (<title>401 Authorization Required</title>), which is why the script reads the error body as text. Failed requests cost no credits. A wallet tool should treat any error as "can't check" and never as "safe to send".

Frequently asked questions

What is a vanity address in crypto?

A normal blockchain address that contains a pattern someone chose, such as a word or a run of zeros. It is found by generating keys (or, for contracts, CREATE2 salts) until one produces the pattern. The network treats it exactly like any other address.

Are vanity addresses safe?

Yes, if the private key came from a cryptographically secure random source and was generated on a machine you control. They are unsafe when the generator's randomness is weak, as with Profanity in 2022, or when a website generated the key and could have kept a copy.

How long does it take to generate an Ethereum vanity address?

Each hex character multiplies the average work by 16: 4,096 attempts for three characters, about 16.8 million for six and about 4.3 billion for eight. Asking for exact upper or lower case doubles the work for every letter. A single CPU core running JavaScript managed about 3,000 attempts a second in our test; GPU tools are far faster.

What was the Profanity vulnerability?

Profanity, a GPU vanity generator for Ethereum, seeded its private keys from only 32 random bits, so anyone with an address's public key could recover the private key. 1inch disclosed it on 15 September 2022, and five days later Wintermute lost about $160 million from a vault whose admin address had a Profanity-style vanity prefix.

Can you make a vanity address for a smart contract?

Yes. With CREATE2 the address depends on the deployer, a salt and the contract's init code, so you search for a salt that gives the pattern you want. No private key is involved, so the Profanity class of bug doesn't apply. The salt only works with the exact deployer and init code it was mined for.

What is address poisoning?

A scam where an attacker mines an address with the same first and last characters as one you send to, then plants it in your transaction history with a zero-value transfer, a fake token or dust, hoping you copy it next time. Compare whole addresses and never copy a recipient from your history.

Next steps

Get new guides by email

New tutorials and best practices for building with blockchain data, sent as they're published.