(feature request?) parse transaction receipts for event log data output?
See original GitHub issueHow to extract event logged output?
Please have a look first how it is working in javascript/truffle:
logArgs.contractId
txLoggedArgs
I really want to work with Python and not JS - and apart from some minor hickups it is looking good.
But now, I need to get a specific value logArgs.contractId
from an event log after a contract call, and I am stuck.
Because when I try the same as above with the py transaction receipts that I get via
rec = web3py.eth.getTransactionReceipt(tx)
then this of course fails:
logargs = rec.logs[0].args
with
AttributeError: 'AttributeDict' object has no attribute 'args'
because it simply does not exist - and that seems different from javascript/truffle?
Is it because the event output args
are still all mixed up in the rec.logs [0].topics
field (or in the rec.logs [0].data
field) ?
Example (complete receipt below).
'data': '0x00000000000000000000000000000000000000000000000000038d7ea4c68000ec099eeb7c6385269c410da8eb2e028bf832c8418d731bf99f987e9d9357abe9000000000000000000000000000000000000000000000000000000005a0c6ae0'
'topics': ['0xa0085ce7b3f5d49ff7ac7b4f8caaf2f75147d0228c3811a6d3d41eb2029fe122', '0xa4162351c79a5ed77bfc705394785c93842b6fc2e55d2b302c86ee55540c5b24', '0x000000000000000000000000c62d9f5092737fa7689579e279a3a1dd5543fb9e', '0x00000000000000000000000025f579697ce3fe1cf122fc5ffae9f1d83f16c676'],
Wouldn’t the ABI now help, to take those outputs apart?
Is there a helper function for that in web3py? which one?
If not, wouldn’t it be useful to have? Or … which external tool can I use now?
Or am I thinking this in a completely twisted way?
Is there a more direct way to access the answered contractId
after a newContract
call (solidity, abi) ?
because the web3.eth.contract(...).newContract(parameters, transact={...})
works well - but it returns only a a transaction hash. How does truffle actually manage it differently?
Thanks a lot.
{'blockHash': '0x9a120c06c6950f1a3fa29ebd2bfdd349652cda382087d3e402ccb0b56e87ac04',
'blockNumber': 2076033,
'contractAddress': None,
'cumulativeGasUsed': 146500,
'from': '0xc62d9f5092737fa7689579e279a3a1dd5543fb9e',
'gasUsed': 146500,
'logs': [AttributeDict({'removed': False, 'blockNumber': 2076033, 'logIndex': 0, 'data': '0x00000000000000000000000000000000000000000000000000038d7ea4c68000ec099eeb7c6385269c410da8eb2e028bf832c8418d731bf99f987e9d9357abe9000000000000000000000000000000000000000000000000000000005a0c6ae0', 'transactionIndex': 0, 'address': '0x131c7ba3ec8ebe69a6c58d084fd70adfacec76c5', 'topics': ['0xa0085ce7b3f5d49ff7ac7b4f8caaf2f75147d0228c3811a6d3d41eb2029fe122', '0xa4162351c79a5ed77bfc705394785c93842b6fc2e55d2b302c86ee55540c5b24', '0x000000000000000000000000c62d9f5092737fa7689579e279a3a1dd5543fb9e', '0x00000000000000000000000025f579697ce3fe1cf122fc5ffae9f1d83f16c676'], 'transactionHash': '0x3cffaa0926589452f9ead7eb016a8a63087051021beaab511fce366b5dcec3d8', 'blockHash': '0x9a120c06c6950f1a3fa29ebd2bfdd349652cda382087d3e402ccb0b56e87ac04'})],
'logsBloom': '0x00000000000000000000000000000000000000000000002000000000000800400000000000000000000000000000000200000000080000400000000000000000000000000000000000000000000000000000002000200000000000000000000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000000000100000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000010000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000',
'status': '0x1',
'to': '0x131c7ba3ec8ebe69a6c58d084fd70adfacec76c5',
'transactionHash': '0x3cffaa0926589452f9ead7eb016a8a63087051021beaab511fce366b5dcec3d8',
'transactionIndex': 0}
Issue Analytics
- State:
- Created 6 years ago
- Comments:22 (7 by maintainers)
Top GitHub Comments
Released in beta 9: http://web3py.readthedocs.io/en/latest/releases.html#v4-0-0-beta-9
@drandreaskrueger glad to get this resolved.