How to deploy a contract that starts with 0x000000000000 like https://etherscan.io/address/0x0000000000007f150bd6f54c40a34d7c3d5e9f56

2 Answers 2


Assume you want to deploy a contract using truffle, you will go with the regular CREATE. The contract address is then determined from the contract owner's address and the transaction count of that address.

So let's say you want to deploy an OpenZeppelin Upgradeable contract with truffle. The publicly visible contract will be deployed in the fourth transaction, so you would need to be looking for the contract address that results from the fourth transaction.

Alike, if your contract is not Upgradeable but a simple one, then you may be looking for the second transaction, since the first will be the Truffle Migrations contract.

Sample code in node:

const rlp    = require('rlp');
const keccak = require('keccak');
const web3   = require('web3');
var Accounts = require('web3-eth-accounts');
var accounts = new Accounts('ws://localhost:8546');

// Determine the contract address for a certain owner address and nonce value    
function calcContractAddress(addressObject) {
    let nonce = 0x00;
    address    = addressObject.address;
    privateKey = addressObject.privateKey;

    // Add four to the nonce since we need to look for the fourth transaction
    nonce = nonce + 4;

    var nonceHex    = "0x"+nonce.toString(16).padStart(16,'0');
    var input_arr   = [ address, nonce ];
    var rlp_encoded = rlp.encode(input_arr);
    var contract_address_long = keccak('keccak256').update(rlp_encoded).digest('hex');
    var contract_address = contract_address_long.substring(24); // Trim the first 24 characters.
    if ((contract_address.startsWith("000000000000"))) {
        console.log("contract_address with nonce "+nonce+": 0x" + contract_address+"\t address = "+address+", privateKey = "+privateKey);

while (true) {
    addressObject = accounts.create("someRandomStuff");

Start it then go on a world trip until it found an address ...

It is important that you start truffle with this clean new address, since the transaction count needs to be zero! Otherwise you will end up with a completely different contract address.


You should calculate the needed input data to "randomly" get such convenient address for you contract. For example, in the case of CREATE2, you can iterate over the salt values.

So basically you just have to brute force it: try different combinations until you accidentally get the desired address format.

  • How would I do that using Truffle, Hardhat or Remix? Or what tool should I use to do that?
    – jose
    Nov 16, 2021 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.