-
hi. the way I usually get event params is by declaring an interface and then doing in this case, where the event contains a
[
'0x1B444446eC828A5cDC8f4c2ab92A9A0DF2095fAE',
BigNumber { _hex: '0x09a715a8', _isBigNumber: true },
{
_isIndexed: true,
hash: '0xb40123284ea5c832806ac2203e1a779a0b866247d161403705d68cbba78e8a9b',
constructor: [Function: Indexed] { isIndexed: [Function (anonymous)] }
}
] how do I get the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The event indexing works by having a upto 4 bytes32 topics which can be included in the filter. A string value is dynamic and doesn't fit in bytes32 so solidity hashes it so it fits in the bytes32. Basically getting the You may switch the event Lock(address indexed user, uint256 amount, string indexed usernameTopic, string username); |
Beta Was this translation helpful? Give feedback.
-
alright! thanks for the answer 🙏 |
Beta Was this translation helpful? Give feedback.
The event indexing works by having a upto 4 bytes32 topics which can be included in the filter. A string value is dynamic and doesn't fit in bytes32 so solidity hashes it so it fits in the bytes32. Basically getting the
username
param would be finding the preimage of the hash function, which doesn't seem something you can do with keccak256 practically.You may switch the
string
type tobytes32
, it will limit the username to 32 length (which can be reasonable). If it's necessary to stick withstring
you can include it again.