1

I am using quoram distribution through Azure blockchain service.. we are emitting few events according to our logic and these events are being used to get specific data from the transaction.. though we see that the data in each event is duplicated.

Event declaration in solidity -

event Added(
    address sender,
    string Key,
    string ControlNumber,
    string Content,
    Status Status,
    uint256 Index,
    string epochdatetime
);

Sample data emitted by the event :

{
    "address": "0xdummyaddress",
    "blockNumber": 298905,
    "transactionHash": "0xdummyhash",
    "transactionIndex": 0,
    "blockHash": "0xdummyhash",
    "logIndex": 0,
    "removed": false,
    "id": "log_1",
    "returnValues": {
        "0": "0xdummysenderAddress",
        "1": "110_E222222222",
        "2": "222222",
        "3": "content",
        "4": "0",
        "5": "11",
        "6": "1585329530",
        "7": "111113",
        "sender": "0xdummysenderAddress",
        "Key": "110_E222222222",
        "ControlNumber": "222222",
        "Content": "content",
        "Status": "0",
        "Index": "11",
        "epochdatetime": "1585329530"
    }
}

If you notice the returnValues is having duplicate data.. first it is using numbered keys ("0") for emitting the data, then it is having the same data, but key name is now same as what we defined in event definition ("sender" is same as "0").

Is there any way to suppress the numbered keys?

0

That's just how web3.js processes the data before handing it over to your application.

It is quite useful in the sense that you can access it directly by name, for example:

const ControlNumber = myEvent.returnValues.ControlNumber;

And also iterate it sequentially using the __length__ field (which you forgot to mention):

for (let i = 0; i < myEvent.returnValues.__length__; i++) {
    const returnValue = myEvent.returnValues[i];
    // do something with returnValue, for example, save it in a DB
}
| improve this answer | |
0

This is normal behavior. You can just now access your data either by index key returnedData.sender or index iteration returnedData[0]

If you want to trim/supress this data, you have to do it on the client layer.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.