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

How to decode the field data type? #59

Closed
ronming1303 opened this issue Jan 9, 2024 · 1 comment
Closed

How to decode the field data type? #59

ronming1303 opened this issue Jan 9, 2024 · 1 comment

Comments

@ronming1303
Copy link

Hi There,

I notice that in Aleo there is no data type of "String". I think it uses "Field" instead, but how to decode the "Field" to human-readable string? E.g. In the vote project, when input title: 2077160157502449938194577302446444field, what does that mean?

Thanks in advance

@ronming1303 ronming1303 changed the title How to understand the filed data type? How to decode the field data type? Jan 9, 2024
@ronming1303
Copy link
Author

Just figure it out, python code to decode it:

integer_representation = 2077160157502449938194577302446444

bytes_array = integer_representation.to_bytes((integer_representation.bit_length() + 7) // 8, 'big')

original_string = bytes_array.decode('utf-8')

print("Original string:", original_string)

The output is "first proposal"

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

1 participant