Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get contract address from CREATE and CREATE2 opcode #2762

Closed
tinom9 opened this issue Dec 15, 2022 · 0 comments
Closed

Get contract address from CREATE and CREATE2 opcode #2762

tinom9 opened this issue Dec 15, 2022 · 0 comments

Comments

@tinom9
Copy link
Contributor

tinom9 commented Dec 15, 2022

What was wrong?

Unlike ethers.js (5.7.2), web3.py does not include a utility method to deterministically determine the contract address from the inputs of CREATE and CREATE2 opcodes.

How can it be fixed?

The address of a CREATE opcode deployed contract can be determined as a function of its sender and its respective nonce:

new_address = hash(sender, nonce)

And the address of a CREATE2 opcode deployed contract can be determined as a function of a constant 0xFF, its sender, an arbitrary value salt and the contract's bytecode:

new_address = hash(0xFF, sender, salt, bytecode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant