3

Here's the code:

enter image description here

  1. I compile these two contracts together and deploy Bar contract. After deploying it I have a contract account address where it has been deployed on the blockchain:

    0x692a70d2e424a56d2c6c27aa97d1a86395877b3a

  2. Then I call Bar.createFoo() and get a new contract account address where the newly created contract Foo has just been deployed:

    0xfcca7851eb308c57543421141f6fefbd1f4a2bef


My first question is:

What is stored in the variable whatAmI? Is it the address of Bar or is it the address of my account(externally owned account) that called Bar.createFoo()?


My second question is:

I've added some means to log the whatAmI variable here: enter image description here

Compiler throws an error: TypeError: Cannot read property 'event' of undefined

What am I doing wrong here?

1 Answer 1

3

For Q1.

whatAmI will have the address of whatever invokes the constructor Foo(). Since it was invoked by Bar (createFoo), whatAmi will have the address of Bar.

(But an external account can deploy Foo and in this case, whatAmI would be the address of the external account. In Solidity Browser, just click on Create for Foo few times and you should see the event.)


For Q2. You are not doing anything wrong to cause

TypeError: Cannot read property 'event' of undefined

since it is a known open issue at https://github.com/ethereum/browser-solidity/issues/115

You should be fine with other uses of events.

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.