How we sent ETH to the wrong address and successfully recovered them

in #ethereum7 years ago

banner_ether01 (1).png

The story begins with a problem we faced in BitClave: during the preparation of the ICO some amount of ETH was sent to contract address, which was previously deployed to the test Ethereum network. The money was sent to the address which does not belong neither to a private key nor to a smart contract. Initially, it seemed we had lost $2000 with no way to return it 💸💸💸

1*gzT9zLHvE9l4Z1dTEwh2dg.png

But it was just the beginning of the story. My collegue asked me if I had a private key for the address 0x9c86825280b1d6c7dB043D4CC86E1549990149f9. I had sent him a private key for address 0x231A3925A014EF0a11a0DC5c33bF7cdB3bd9919f, which was used to deploy a contract to the first address. We discussed the issue and decided it was not possible to recover this money 😔

Every contract deployed to Ethereum network has a specific address, which looks random, but I discovered exactly how contract address is generated on deploy: https://ethereum.stackexchange.com/a/761/3032. Simply it is just hash of transaction sender address and nonce number (equals to number of transactions by this sender):

deployed_address = sha3(rlp.encode([sender, nonce]))


This gave me an idea to use the original wallet (the one I used in TESTNET previously) to deploy several new smart contracts to MAINNET. I developed a simple wallet smart contract, which would allow me to display and reclaim lost funds:

contract SimpleWallet is Ownable {
    function () public payable {
    }
    function weiBalance() public constant returns(uint256) {
        return this.balance;
    }
    function claim(address destination) public onlyOwner {
        destination.transfer(this.balance);
    }
}


Then I found a transaction which deployed contract in TESTNET: 0xc4c32a3d97dbd691eb3646e4c0c404e899a632010bc48d7182d75bef6803b7bc and discovered that nonce field was equal to 13. So I sent 0.03 ETH to this wallet in MAINNET and started to deploy a simple wallet smart contract to MAINNET multiple times, until nonce had reached value 13. And thats it, I got smart contract deployed to the desired address! Here are 2 transactions with nonce equal to 13, which deployed 2 diffrerent smart contracts into 2 different networks to exactly the same addresses with 5 days difference 😎:

  1. 0xc4c32a3d97dbd691eb3646e4c0c404e899a632010bc48d7182d75bef6803b7bc
  2. 0xeaeb29871ceaabb3dc200b424f38ae1b493262eb8c7f5be7d000f2399e4edba0

Funds were successfully claimed by calling the claim method of a freshly deployed simple wallet smart contract 👏👏👏

Also you may notice that this contract in MAINNET was deployed two days later, after it had been funded 🤗:

1*aEldldAt47irdljAMcxv4g.png

Finally, funds were sent in main Ethereum network to the address of smart contract, deployed to the test Ethereum network. We used the same wallet to deploy different smart contract to the main Ethereum network several times until transaction field nonce achieved the same value 13, as were used to deploy to the test network. We called the special method of freshly deployed smart contract to reclaim funds. So, the smart contract was deployed after it was funded 🎩🐰

Hope this trick will be helpful in case you send crypto funds to a wrong address in future. Or maybe it will help you to claim some funds you lost earlier. Let us know anyway.

Coin Marketplace

STEEM 0.19
TRX 0.14
JST 0.030
BTC 60907.24
ETH 3249.66
USDT 1.00
SBD 2.45