MENU

Calculate smart contract address

0
633
0

It’s a common flub for Solidity developers to lose a newly created contract address. This becomes frustrating, especially if you also lose the transaction receipt and other means of retracing your steps. ?

But no worry!

Contract addresses are deterministically calculated. From the yellow paper: The address of the new account is defined as being the rightmost 160 bits of the Keccak hash of the RLP encoding of the structure containing only the sender and the account nonce. Thus we define the resultant address for the new account a ≡ B96..255 KEC RLP (s, σ[s]n − 1)

An easier way to represent this function is: address = rightmost_20_bytes(keccak(RLP(sender address, nonce)))

So, what is the nonce? how to get it?

Check "Recovery" solidity game. A contract creator has built a very simple token factory contract. Anyone can create new tokens with ease. After deploying the first token contract, the creator sent 0.5 ether to obtain more tokens. They have since lost the contract address. This game will be completed if you can recover (or remove) the 0.5 ether from the lost contract address.

https://github.com/maAPPsDEV/recovery-attack

Sorry, the comment form is closed at this time.