Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: How to decode contract events? #3445

Open
BoboTiG opened this issue Jan 29, 2025 · 1 comment
Open

Q: How to decode contract events? #3445

BoboTiG opened this issue Jan 29, 2025 · 1 comment

Comments

@BoboTiG
Copy link

BoboTiG commented Jan 29, 2025

Using RUES, I listen to withdrawal events, and I got something like:

b'\xbf\x00\x00\x00{"Content-Location":"/on/contracts:0200000000000000000000000000000000000000000000000000000000000000/withdraw","Rusk-Origin":"21a95b9c87290832d20d1087d43fa65f86a7555ab4690ead29aed26d223a1618"}\x00\x00\x00\x00\x00\x00\x00\x00\'m$\xb5\xb0w\xde\xa76\xeb\xe1\xed\xde%\xd9;KC\x03\xce\xd3a\x94\xd8{\xb3_Ox51\x00\xde\x13e\x98Y@\xd4p:\x14y\xbb\xec\xe5\x11\r\xf0\xf3\\\xa9;W\x7f\xe2\xe32\xb0\x13\x98XX\x84\x04P>\xc7\xa6=\xe7L\xee\x9e\x1f1\xde\'.\xe4n\xf3\x91\xae\x0c\x807\nZ;\x85\x10\xd9jZ\x12i\x08T\xc9:\x0bD\x90\xff\x8b\x96\x89?\xaaq\x8dI\x93\x8d8{=\x06\x03\x81dF\x8az\x01\x14\x04\xe4\x99}U\xa5\xc2"\xce\x11\x9c\xe2\x1a\xce\xed\xb8\x08W/\x94\xb4\xa6\xd8\x1e\xee\x9f\xf4\xfa\x16m\xb4*\x1f\x1d\xeb\xbeh@M\x00\x1dx\xe2\x9bK\xbb\x95\x07\x04y_\x92\xec_p];f\x19\xc4\x05m*\xb9\t\x00\x00\x00\x00\x00\x00\x00\x00\'m$\xb5\xb0w\xde\xa76\xeb\xe1\xed\xde%\xd9;KC\x03\xce\xd3a\x94\xd8{\xb3_Ox51\x00\xde\x13e\x98Y@\xd4p:\x14y\xbb\xec\xe5\x11\r\xf0\xf3\\\xa9;W\x7f\xe2\xe32\xb0\x13\x98XX\x84\x04P>\xc7\xa6=\xe7L\xee\x9e\x1f1\xde\'.\xe4n\xf3\x91\xae\x0c\x807\nZ;\x85\x10\xd9jZ\x12i\x08T\xc9:\x0bD\x90\xff\x8b\x96\x89?\xaaq\x8dI\x93\x8d8{=\x06\x03\x81dF\x8az\x01\x14\x04\xe4\x99}U\xa5\xc2"\xce\x11\x9c\xe2\x1a\xce\xed\xb8\x08W/\x94\xb4\xa6\xd8\x1e\xee\x9f\xf4\xfa\x16m\xb4*\x1f\x1d\xeb\xbeh@M\x00\x1dx\xe2\x9bK\xbb\x95\x07\x04y_\x92\xec_p];f\x19\xc4\x05m*\xb9\t\x00\x00\x00\x00\x00\x00\x00\x00\xee\xcd\xb7\xd8\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

From the code (and if I read it correctly), this is ciphered data using staking keys.

For this example, I'm not the owner of the call, but lets imagine I have an event of mine. How can I decode the data to effectively know how many tokens I've withdrawed? (This question is about withdraw events, but it applies to any other events as well).

Note that I'm using Python to do the work, so maybe a rought process on how it should be done could be sufficient (given that the data can be decoded from the "outside").

@tminus92
Copy link

As per the docs:

The event is returned as raw binary data

You need to decode the raw binary data and convert that into an appropriate data structure. You can find an example on this test which basically represent the RUES lifecycle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants