I have a smart contract and on my web interface I'd like to display the 5 latest transactions. Currently these include any ether being sent to my contract which are retrieved using web3.eth.getTransaction()
and transaction hash.
However, I have a variable leaf
which any address is allowed to buy, this is logged using an event function. Can the number of leaf purchased be logged and retrieved using the transaction hash?
EDIT: So, I've managed to retrieve all the events using the allEvents()
functions. Unfortunately, it returns two different structured objects:
The first one, returns this, which contains the args
variable - as expected:
- Event:
event depositedFunds(uint amount, uint newBalance);
- Returned object:
{logIndex: 0, transactionIndex: 0, transactionHash: "0x82b69effb105ef1998fefdbf47d471c54c33a5b3b6b6462da33ecb790b2ce410", blockHash: "0xd16a7efac06f35725ae75bc3bca5a862a2847a94c2f2084c6a6f4d22c71958ec", blockNumber: 3, …}
The second, which is logged when the desired event is called returns this, which does not contain the args
variable:
- Event:
event leafWasPicked(uint leavesLeft, uint numberTaken);
- Returned object:
{logIndex: "0x0", transactionIndex: "0x0", transactionHash: "0xbfd6a21c6d782e18f7636be9895849de8333678f5d7d28a0a406575988e7d653", blockHash: "0x765264a7c21d9c088adfc70a15a69a7b3f3c0408eb3758390bda2596d47aa48f", blockNumber: "0x5", …}
Why are both of these different?
leaf
purchused using events. More infor how to get the log (event) here: github.com/ethereum/wiki/wiki/JavaScript-API#web3ethfilterallEvents
functions: When it return this:{logIndex: 0, transactionIndex: 0, transactionHash: "0xc88bc5a0c318a9cc74d8f", blockHash: "0xea475411b5b18be2b7e5a0d7ae231dc1329", blockNumber: 31, …}
the event is correctly logged inside it. But when the event function that I actually need is called it returns this which does not contain log information:{logIndex: "0x0", transactionIndex: "0x0", transactionHash: "0x7035283a8eafacb754399110be2", blockHash: "0xf9162db97c83e68c4a777", blockNumber: "0x21", …}