When I perform a contract function-call via Truffle, and then resolve the returned promise, I get something like this:
{
"tx": "0x...",
"receipt": {
"transactionHash": "0x...",
"transactionIndex": 0,
"blockHash": "0x...",
"blockNumber": 24,
"gasUsed": 42860,
"cumulativeGasUsed": 42860,
"contractAddress": null,
"logs": [
{
"logIndex": 0,
"transactionIndex": 0,
"transactionHash": "0x...",
"blockHash": "0x...",
"blockNumber": 24,
"address": "0x...",
"data": "0x...",
"topics": [
"0x...",
"0x...",
"0x..."
],
"type": "mined"
}
],
"status": "0x1",
"logsBloom": "0x..."
},
"logs": [
{
"logIndex": 0,
"transactionIndex": 0,
"transactionHash": "0x...",
"blockHash": "0x...",
"blockNumber": 24,
"address": "0x...",
"type": "mined",
"event": "Transfer",
"args": {
"from": "0x...",
"to": "0x...",
"value": "0"
}
}
]
}
I'm not really sure how exactly Truffle wraps web3.js in order to invoke contract functions, so I'm not really sure where to look in the web3.js documentation. But I am using Truffle v4.1.14, which relies on web3.js v0.18.4, and the docs for web3.js v0.x are kinda hard to read, so I searched in the docs for web3.js v1.x instead.
Now, I guess I should be looking into web3.eth.sendSignedTransaction, which returns:
A promise combined event emitter. Will be resolved when the transaction receipt is available.
So it seems that Truffle takes this receipt, and embeds it into a JSON object which contains the following additional fields:
tx
, which is the transaction hash, I supposelogs
, which contains some or all of thereceipt.logs
, but decoded
So what exactly is going on here?
This new object is certainly not the receipt described in the docs.
Is there an official terminology for this, or is it just a "Truffle hack" designated to make my life easier decoding events?
Thank you.