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

Precision of "value" in transaction too low for Ethereum's 18 decimal balances #1

Closed
dietersommer opened this issue Mar 10, 2023 · 3 comments

Comments

@dietersommer
Copy link

dietersommer commented Mar 10, 2023

The transaction types, e.g., transaction_1559.rs, encode the value only as a u64. However, this is not enough for accurately representing the number of tokens to be transferred in an Ethereum transaction as this is specified with 18 decimals in Ethereum (they use 32-byte / 256-bit numbers here). Assuming that the u64 value represents Wei, an u18 only allows to represent around up to 18 Ether.

Would it make sense to use type with a larger precision for representing the value? Technically, the same argument holds for the other numbers in the transaction, like the gas fee, but is's less of an issue here.

@stopak
Copy link
Contributor

stopak commented Mar 10, 2023

It is a good point, I can increase it to 256-bit number.

@dietersommer
Copy link
Author

Sounds like a good idea. Do you think that all the values that are encoded by Ethereum with 256 bits should be changed? The others like gas price are less crucial, but still it would be cleaner to have all be 256 bit.

@stopak
Copy link
Contributor

stopak commented Mar 13, 2023

I've changed to 256 bit for all transaction types. All tests are passing :). I've also updated the production canister.

@stopak stopak closed this as completed Mar 13, 2023
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