Short answer
You can actually get the value of the indexed values.
Long answer
Let's say in your logs file you get an event with indexed values
{
address: '0xA339447189Ec1f4CD93A959c4eE758B4fB3ED516',
topics:
[ '0x6f60e5b2581736becbd13dcf6c74309cbe82ea5136dc0936a9db0273e8776261',
'0x00000000000000000000000090f8bf6a479f320ead074411a4b0e7944ea8c9c1' ],
data: '0x0000000000000000000000000000000000000000000000000000000000000005',
blockNumber: 504611,
transactionHash: '0x2f8e22fabd86f6c35faec5f613ccab3725b45c3340882a0468381b27bfda024c',
transactionIndex: 0,
blockHash: '0x3e92bbf536918228df236df3731a92f449161558a892f72a539911479c1ac112',
logIndex: 0,
removed: false,
id: 'log_a41aab0a'
}
The above logs have been created using this event:
event ContractReached(address indexed from, uint number);
And the event is called with the following arguments:
ContractReached(msg.sender, 5);
You can see that the event has 2 values:
- one indexed which is
msg.sender
- one non-indexed which is
5
The topics
array consist of one event signature topic and one additional topic per indexed value (in our case just one).
Event Signature Topic: This is equal to a Keccak-256 hash of the signature of the event in utf-8.
sha3(ContractReached(address,uint256))
would equal to our first topic 6f60e5b2581736becbd13dcf6c74309cbe82ea5136dc0936a9db0273e8776261
Topic per indexed value: These ones are 32 byte hex values of the indexed arguments, they are not hashed like the signature topic was.
We can see that this is an address (without the 0x
infront of it): 90f8bf6a479f320ead074411a4b0e7944ea8c9c1
padded up to 32 bytes.
Data: The non-indexed values follow the same pattern as the topics containing the indexed values. They are non-hashed 32 byte hex representations of the values. The only difference is that they are all appended to the data
field one after another.
Because 1 hex value is equal to a nibble(4 bits or half a byte) we end with the following data string with a length of 64 nibbles (64/2 = 32 bytes).
0000000000000000000000000000000000000000000000000000000000000005
If you then convert the hexadecimal representation of that into a decimal you would end up with 5
which is the value we passed in the event.
If our address wasn't indexed we would have received a data
of size 128 nibbles.
e.g.00000000000000000000000090f8bf6a479f320ead074411a4b0e7944ea8c9c10000000000000000000000000000000000000000000000000000000000000005
Only by eye-ing the string above you can easily see the two arguments, each being 64 nibbles.
Please feel free to correct me if anyone finds any mistake in my explanation.