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.

Here are two methods for finding the contract address, via raw sender information and Etherscan, respectively.

Method 1: calculate the contract address

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)))

Where:

sender address : is the contract or wallet address that created this new contract

: is the contract or wallet address that created this new contract nonce : is the number of transactions sent from the sender address OR, if the sender is a factory contract, the nonce is the number of contract-creations made by this account.

: is the number of transactions sent from the OR, RLP : is an encoder on data structure, and is the default to serialize objects in Ethereum.

: is an encoder on data structure, and is the default to serialize objects in Ethereum. keccak : is a cryptographic primitive that compute the Ethereum-SHA-3 (Keccak-256) hash of any input.

Recreating this Remix

Let’s calculate the address of a new contract created by an existing contract located at 0x890ca422059d877085ce763187ddb12b62ab809d . Let’s assume that this is the first ever contract creation from this address, so the nonce (transaction count) should be 1 .

I nteresting fact: nonce 0 is always the smart contract’s own creation event

From documentation, the RLP encoding of a 20-byte address is: 0xd6, 0x94 . And for all integers less than 0x7f , its encoding is just its own byte value. So the RLP of 1 is 0x01 . In Remix, compute the following:

address public a = address(keccak256(0xd6, 0x94, YOUR_ADDR, 0x01));

3. This yields 0x048559A2982f50c268B80E14b1A98A1524295016 , which is presumably the first address of the new smart contract the existing contract will deploy.

4. To get subsequent contract addresses, simply increment the nonce.

Method 2: use Etherscan

An albeit faster way to derive the new contract address from the creator is with Etherscan.