I developed a contract which uses another contract in it state variable, but looks like the events from the contract in the state variable aren’t dispatched.
contract A {
event Hello(uint num);
function doSomething() {
Hello(1);
}
}
contract B {
A public a;
function doAnotherThing() public {
a = new A();
a.doSomething();
}
}
What is expected: To be possible to capture the events from the contract A which is a state variable in the contract B. So when call a.doSomething() in the contract B should be dispatched the event Hello(1) and be possible to capture in the watch.
eventsare tied to the contract which has anaddressand is called in a transaction so they generate events, but the state variable can't generate event because isn't called directly in the transaction. I'm not sure if I'm totally right about that, but now it makes more sense to me. – Eduardo Pereira Oct 16 '17 at 19:07contract Ahas an address, too. You can doevent LogNewA(address newContract)...LogNewA(a);and see the address in B's event log. – Rob Hitchens Oct 16 '17 at 19:30a = new A()the state variableawill receive anaddresstoo :) is possible to watch that variable by hisaddress, right ? – Eduardo Pereira Oct 16 '17 at 19:38ais cast as contractAwhich is directly convertible to typeaddress. You might find some inspiration with the pattern laid out over here: https://ethereum.stackexchange.com/questions/13415/is-there-a-simple-contract-factory-pattern – Rob Hitchens Oct 16 '17 at 20:40