I have written a contract with the hub/factory pattern in which I need to capture the address of the contract that is being created, for this I am using events.
Contract A
Function A1
-- Call to Function B1
--- emit event Contract B
Contract B
Function B1
-- Actions
However, I try making an event with a single contract and it works perfectly, I receive the receipt with the associated events and the resulting elements.
I uploaded to my repository the code I'm using, the contract in question is as follows
https://github.com/DanielZambranoC/Capachain/blob/master/bc/contracts/Capachain.sol
As you can see in line 11 I have changed the content of the event to 'daniel' proving that it was not a problem with the address I was sending, basically I need to return the contract address that was created to the front end to notify the user.
I am using web3js in its version 1.0.0 beta 36 and 55 with my application
In Remix I can see that the log returns the events raised, but I have not managed to capture them from my application.
Issues on Github
https://github.com/ethereum/web3.js/issues/2853 https://github.com/ethereum/solidity/issues/6877
In the test with only 1 contract you can see that I have the key/value structure of the event, name with their respective values.
In the test with the hub/factory contracts you can see what comes if the events, if I send 2, send me 2 arrays but without content but with raw data, I think that if I sent 100 events, they would sell the 100 array but without information.
Result with 1 Contract
{
"transactionHash": "0xdaf5eec6c4b5a767d1d6c4e5ca23b80afcba91b889731358ab0a27c706b981f6",
"transactionIndex": 0,
"blockHash": "0x1b43bd4ebf57105be29bbbdb80b2b9d12c041fb60b014cdb6d08db46e628353e",
"blockNumber": 178,
"from": "0x3377b79a500b6d4a8e2e391b86ebc7f88e99f2c4",
"to": "0xc3e0cb472f5763a34472afcd546fcce4231a950a",
"gasUsed": 23031,
"cumulativeGasUsed": 23031,
"contractAddress": null,
"status": true,
"logsBloom": "0x00000000010000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000020000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000",
"v": "0x1c",
"r": "0xcfe3006057312a461cb0c52c6786eee4f46df6d720da92581e28ec5dab5382f0",
"s": "0x3d42b3dcc12aa4b902bcdceec6ef1333460ffa8798ef991bcb202a769d173a20",
"events": {
"RegistroQueja": {
"logIndex": 0,
"transactionIndex": 0,
"transactionHash": "0xdaf5eec6c4b5a767d1d6c4e5ca23b80afcba91b889731358ab0a27c706b981f6",
"blockHash": "0x1b43bd4ebf57105be29bbbdb80b2b9d12c041fb60b014cdb6d08db46e628353e",
"blockNumber": 178,
"address": "0xC3E0CB472f5763A34472AfCd546FCCe4231A950a",
"type": "mined",
"id": "log_2191ede5",
"returnValues": {
"0": "test",
"nomre": "test"
},
"event": "RegistroQueja",
"signature": "0x4704303a8919b51a4c52e7794ce51a432970e0b441ef60bf5283fe4520dc5308",
"raw": {
"data": "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000047465737400000000000000000000000000000000000000000000000000000000",
"topics": [
"0x4704303a8919b51a4c52e7794ce51a432970e0b441ef60bf5283fe4520dc5308"
]
}
}
}
}
Result with Hub/Factory Contract
{
"transactionHash": "0x41bb7b355a3c08d0ae99ae7ccad38c2877688fe97da4d773e70a139c5e246c5a",
"transactionIndex": 0,
"blockHash": "0xca5049734f587fcd21c80d531433a961365f5778c25a78b861820f9a166ba5c1",
"blockNumber": 177,
"from": "0x3377b79a500b6d4a8e2e391b86ebc7f88e99f2c4",
"to": "0xbf62861d2ab3c1fc05098f71b97886c050fff0b6",
"gasUsed": 753055,
"cumulativeGasUsed": 753055,
"contractAddress": null,
"status": true,
"logsBloom": "0x00000000010000000000000200000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000100000000000000000000000000000000001000000000000000400000000000010000000020000000000000001000000000000000000000000000000000000000000000000000000002000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"v": "0x1b",
"r": "0x5ea7230a484061a85cfea0276597f4cb07be1e866aa7828a6f54ea766c4d8faa",
"s": "0x2f74d47b31216caf8b3314e34834355f54e61fdb3641662a4e2477a375c18add",
"events": {
"0": {
"logIndex": 0,
"transactionIndex": 0,
"transactionHash": "0x41bb7b355a3c08d0ae99ae7ccad38c2877688fe97da4d773e70a139c5e246c5a",
"blockHash": "0xca5049734f587fcd21c80d531433a961365f5778c25a78b861820f9a166ba5c1",
"blockNumber": 177,
"address": "0x7bEf0Ce786E1610f9a962C522A5B16b5C8FDbf70",
"type": "mined",
"id": "log_4f962706",
"returnValues": {},
"signature": null,
"raw": {
"data": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000664616e69656c0000000000000000000000000000000000000000000000000000",
"topics": [
"0xabf569c29023498f9292dbb4f02d15221cbfeb36d71a45c619158c2f2c8b91f4"
]
}
},
"1": {
"logIndex": 1,
"transactionIndex": 0,
"transactionHash": "0x41bb7b355a3c08d0ae99ae7ccad38c2877688fe97da4d773e70a139c5e246c5a",
"blockHash": "0xca5049734f587fcd21c80d531433a961365f5778c25a78b861820f9a166ba5c1",
"blockNumber": 177,
"address": "0xbf62861D2aB3C1fc05098f71b97886c050Fff0b6",
"type": "mined",
"id": "log_ce96a782",
"returnValues": {},
"signature": null,
"raw": {
"data": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000664616e69656c0000000000000000000000000000000000000000000000000000",
"topics": [
"0x4704303a8919b51a4c52e7794ce51a432970e0b441ef60bf5283fe4520dc5308"
]
}
}
}
}