0

Is there a way to know the address of the smart contract you are writing before deploying it? Or somehow reference the smart contract address in the smart contract?

1 Answer 1

0

The contract's address can be is generated based on the account nonce and account's own address: How to deploy smart contract in predefined contract address in private ethereum network? . So you can calculate it in advance.

Or you can reference the contract's own address (whatever it is) in Solidity with address(this).

P.S. New opcode CREATE2 enables even more flexibility in knowing contract addresses in advance (but it's rather complicated): https://hackernoon.com/using-ethereums-create2-nw2137q7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.