I am working in a ethereum project and i want to retrieve some data from an event. Let me show the details of what i am trying to do ;
event fooev( address indexed sender, address indexed requesteeContractAddr, string indexed abc);
The fooev is an event that the contract emits
function foo(address requesteeContractAddr, string abc) public
{
fooev(msg.sender, requesteeContractAddr, abc);
}
Foo is a function, when someone sends a transaction & calls foo, the fooev' event is emitted
assume abc = 'hey'
Now i am getting event data like this :
AttributeDict({'sender': '0xfc63c3aB84fc49bfDd7aB7FAcB6A80BE890eA062',
'requesteeContractAddr': '0x4cd53503e7Ab59D2aFB379195569424Df88f5BF6',
'abc': b'&\xa2\x082:\x8c!\xa11#\xc1#\xa8\xdd|qDD\xc5a\x10;\x00b\xd1\xb8\xb6\xa9\xe9\x08\x9e*'})
notice that abc, which was input in the smart contract in a string form, is returned in a bytes form.
When i try to convert it from bytes to string by doing something like :
Web3.toText(AttributeDict.args.resourceType)
i get the error :
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 1: invalid start byte
can someone please help me ? I just want to convert abc BACK to the string form i had originally input it in