foundry icon indicating copy to clipboard operation
foundry copied to clipboard

feat(`cast compute-address`): add support for `CREATE2` addresses

Open pcaversaccio opened this issue 6 months ago • 6 comments

Component

Cast

Describe the feature you would like

Right now cast-compute-address only supports address calculation using the standard RLP encoding pattern. It would be very useful (at least for me 😄) if you could add support for CREATE2-based address creations where you need to supply the nonce and the init-code-hash.

cast-compute-address --deployer 0x... --salt 0x... --init-code-hash 0x... (or --init-code 0x...)

pcaversaccio avatar Jun 13 '25 07:06 pcaversaccio

Supportive 👍

This would look something like: cast compute-address <address> --salt <salt> --init-code-hash <code_hash>, the nonce shouldn't matter for create2.

cast compute-address currently fetches the nonce from the RPC if the --nonce is not defined. In the implementation we need to make sure that it won't attempt to do this when the --init-code-hash is passed. The salt should be optional in my opinion and default to 0x.

zerosnacks avatar Jun 13 '25 08:06 zerosnacks

Supportive 👍

This would look something like: cast compute-address <address> --salt <salt> --init-code-hash <code_hash>, the nonce shouldn't matter for create2.

cast compute-address currently fetches the nonce from the RPC if the --nonce is not defined. In the implementation we need to make sure that it won't attempt to do this when the --init-code-hash is passed. The salt should be optional in my opinion and default to 0x.

I think we should also allow for --init-code since that's what most people will have first (instead of the hash). I would be explicit about the --salt tbh, but that's maybe just me being an "explicit maxi" 😄.

pcaversaccio avatar Jun 13 '25 09:06 pcaversaccio

I think we can support both --init-code and --init-code-hash here, yeah let's keep --salt explicit

zerosnacks avatar Jun 13 '25 09:06 zerosnacks

@mablr is this something you would be interested in working on? 😃

zerosnacks avatar Jun 13 '25 09:06 zerosnacks

Yes 😄

I can do it in the next days.

mablr avatar Jun 13 '25 09:06 mablr

Amazing thanks @mablr!

zerosnacks avatar Jun 13 '25 09:06 zerosnacks