The code compiles well. But it gives the following error, when event LogData is activated. LogAddress works well. Do I have to set up explicit getters for the State Variables?
transact to browser/Test.sol:Factory.getContract errored: VM error: invalid opcode. The constructor should be payable if you send value. The execution might have thrown. Debug the transaction to get more information.
pragma solidity ^0.4.15;
contract TestContract {
uint public iD;
bytes32 public name;
function setAttr(uint _id, bytes32 _name) {
iD = _id;
name = _name;
}
}
contract Factory {
TestContract myTest;
address contractAddress;
function Factory () {
myTest = new TestContract();
myTest.setAttr(100,"0x111");
contractAddress = address(myTest);
}
event LogData(uint _mydata, bytes32 _name);
event LogAddress(address _add);
function getContract() {
myTest = TestContract(contractAddress);
LogAddress(contractAddress);
LogData(myTest.iD(), myTest.name());
}
}