You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a bug in the manner of setting the result of ethGetBalance in the EmbeddedWeb3jService.kt
I tested on an alchemy ethereum branch :
val balance = web3j.ethGetBalance(accountAddress, DefaultBlockParameterName.LATEST).send()
And I got the result :
Now I tested the same code on embedded service and got :
The difference is coming from the 0 prefixing the value 0x 00000000000 ....
The object return is an EthGetBalance object with a getBalance()
getBalance will use Numeric.decodeQuantity(getResult())
Well I will not write all the details but it checks the validity of the string.
You can see the code here
One of the test is : value.length() > 3 && value.charAt(2) == '0'
So the value is incorrect and will return an Exception when having 0 following 0x
There is a bug in the manner of setting the result of ethGetBalance in the EmbeddedWeb3jService.kt
I tested on an alchemy ethereum branch :
And I got the result :
Now I tested the same code on embedded service and got :
The difference is coming from the 0 prefixing the value 0x 00000000000 ....
The object return is an
EthGetBalance
object with agetBalance()
getBalance will use
Numeric.decodeQuantity(getResult())
Well I will not write all the details but it checks the validity of the string.
You can see the code here
One of the test is :
value.length() > 3 && value.charAt(2) == '0'
So the value is incorrect and will return an Exception when having 0 following 0x
The error is coming from this code :
https://github.com/web3j/web3j-evm/blob/a40b044df37a0c3426dc24f71589b03327b3a8bc/src/main/kotlin/org/web3j/evm/EmbeddedEthereum.kt#L219-L227
and
https://github.com/web3j/web3j-evm/blob/a40b044df37a0c3426dc24f71589b03327b3a8bc/src/main/kotlin/org/web3j/evm/EmbeddedWeb3jService.kt#L220-L230
.map(Wei::toHexString)
will add all those 0The solution is to use:
.map(Wei::toShortHexString)
(Edit : Tested with success !!)The text was updated successfully, but these errors were encountered: