1

I'm attempting to copy the same concept as used in the ENS registrar contract like line 355:

    // Creates a new hash contract with the owner
    Deed newBid = (new Deed).value(msg.value)(msg.sender);

Coming from a C# background I basically don't understand anything about this statement.

The Deed contract is in the same file at line 24

  1. (new Deed) when the Deed contract has a constructor - how does that work and why is it in brackets? I expected it to be new Deed(someAddress)
  2. What is the .value(msg.value)? Is this supposed to set the deed.value property?
  3. How is .value(msg.value) a function so you can append (msg.sender)? And was is that is that doing?
  4. An assumption is the that other properties in the deed contract are set to their default values. e.g. uint public creationDate will be 0?
  5. Finally, it appears as though ENS is deploying each of these deeds at separate addresses - Does this line do this, or is that done somewhere else?

Sorry, I totally don't get it, but need a simple explanation about everything in this line except for the fact that in the end the variable deed is a Deed contract where I presume I could get the previousOwner property with:

address addr = deed.previousOwner;

Thanks.

1
  1. This is just the syntax of it. That's how you create new contracts from contract in Solidity.
  2. Nope. When you create the new Deed contract you can send ether along with the transaction creating the Deed contract. In this case after the creation of Deed, the balance of the new Deed contract will be msg.value
  3. The msg.sender is the argument for the constructor function of the Deed contract.
  4. Nope, it will be set to now, which is the timestamp of the block in which the new Deed contract was created.
  5. Contract addresses are calculated as the hash(creatorAddress||nonce), since nonces are incremented after each contract creation, also the created Deed contract addresses will be different.

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.