-
Notifications
You must be signed in to change notification settings - Fork 274
Negative value from BigInt is wrong #73
Comments
I checked... invert binary representation of |
Ok, solved... the problem is, that i return a 32 bit integer from smart contract. So it is not recognized by dart that this is a negative integer, because the returned most left bit is not the most left in the BigInt. This way it can be solved: // [...]
BigInt balanceBigInt = voucherBalance.first;
print( 'Credit: ${balanceBigInt.toSigned(32)} ');
} If this behavior is expected I can not decide. web3.js does recognize it without explicit conversion. |
This is definitely a bug in web3dart. It should report "-200" as well, without any explicit conversion. This will be fixed in 1.2.2, which I'll release after the CI passes. Thanks for the report! |
Just released version 1.2.2 to pub, which contains this fix. |
Description
Negative return value from smart contract results in a wrong number in dart. Checking the same in web3.js results in the correct value. Positive value gets printed correct.
Example
Minimal contract example
Minimal Dart code example
Minimal web3.js minimal example
Result
Expected output (= web3.js output):
-200
Dart output:
115792089237316195423570985008687907853269984665640564039457584007908834672440
The text was updated successfully, but these errors were encountered: