This is my contract
pragma solidity ^'0.5.2';
contract MyContract {
address[] public contracts;
event ContractCreated(address newAddress);
constructor() public { }
function createOtherContract() public {
OtherContract contract = new OtherContract();
address contractAddress=address(contract);
contracts.push(contractAddress);
emit ContractCreated(contractAddress);
}
function getDeployedContracts() public view returns (address[] memory) {
return contracts;
}
}
if I watch the events using this code
MyContract.methods
.createOtherContract()
.send({from: accounts[0]})
.on('transactionHash', function (hash) {
MyContract.events.allEvents({
fromBlock: 4477390,
toBlock: 'latest'
}, (error, events) => {
if (error) { console.log("ERR", error); }
console.log("Events", JSON.stringify(events));
});
});
If I use the contract method getDeployedContracts
From the events data, I get a lot more zeros. I think this happens because the first result is a 32-byte HEX and the function results are 20-byte address but the type of the parameter is the same in both functions: address.
What's going on?