Conversion from Hex to BigNumber #3728
Unanswered
0xsanson
asked this question in
Idea / Feature Request
Replies: 1 comment 2 replies
-
We can look into expressing number-compatible properties as hex. Moving to feature request. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Check existing issues
Viem Version
2.31.0
Current Behavior
Viem tends to interpret numbers written as
"0x..."
as if they were ascii strings instead of hex numbers. This is causing me a lot of confusion since most wallets and dapps I'm interfacing with are using this format (since it's used by all raweth_
requests).For example an user might think the following transaction sends 1 wei, but it actually sends 813183025 wei
BTW, I know we are supposed to convert to BigNumber ourselves, so this can be considered a feat request, however viem doesn't raise warning or errors if we pass the wrong type (I'm using pure javascript) so it can cause unwanted consequences.
Expected Behavior
Convert
"0x01"
to1n
.Steps To Reproduce
This will output
value = 813183025n
.Link to Minimal Reproducible Example
No response
Anything else?
No response
Beta Was this translation helpful? Give feedback.
All reactions