Well I know that in theory the obvious answer is yes, as the constructor is a function like the others, but have its own characteristics. But, I want to be sure, because let's suppose that I pass an address that was already assigned to another contract in the blockchain, what happen in that situation? There is an option (a kind of alert) to avoid this situation? or just this didn't and will not happen never?

Maybe is 99.9% impossible, but I want to be sure. Is not better that this kind of addresses are generated by the network? I so, how can I do this in the deployment process?

Here a code, to be clear:

contract SimpleContract {
  address public personalAddress;     

  function SimpleContract(address givenAddress) {
    personalAddress = givenAddress;


It is perfectly valid to send the constructor an address even if the address you send points to an account that does not "exist."

I quoted "exist" because, in a certain sense, every address exists. Some have been used before (i.e. have bytecode, been involved in a transaction, have a non-zero ether balance) and some have not been used yet.

But every 40-character (20-byte) hex string is a valid Ethereum address, and you can send it to any function (including constructors) you want. Whether the address is useful or not is a different question.

Not expressed in your question, but possibly implied by it, is the question of whether a smart contract has an address prior to finishing its constructor. In other words, can you use address(this) in the constructor and get a valid address. I asked that question here: Is address(this) a valid address in a contract's constructor?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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