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
Hi, so I am using ethabi library to try and decode an int24 on a Mint event. It seems that the returned value is not correct.
Here is how I reproduce the issue.
First I check etherscan for the Mint event (log ord 29).
The values in decimal for tickLower and tickHigher are, respectively, -50580 and -36720.
The values in hex for tickLower and tickHigher are, respectively, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3a6c and 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7090.
Rust main.rs to reproduce the issue:
use bigdecimal::ToPrimitive;
use num_bigint::BigInt;
use ethabi;
use ethabi::Token;
fn main() {
// bytes representation for ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3a6c
let bytes_array = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 58, 108];
let mut bytes_str = String::new();
for bytes in &bytes_array {
bytes_str.push_str(&format!("{:x}", bytes));
}
println!("{:?}", bytes_str);
println!("{:?}", bytes_array);
let eth_int: Vec<Token> = ethabi::decode(
&[ethabi::ParamType::Int(24usize)],
bytes_array.as_slice(),
).unwrap();
println!("{:?}", eth_int);
let bi = BigInt::from_signed_bytes_be(&bytes_array);
println!("{}", bi.to_i32().unwrap());
}
And this is the result I get when running the code:
The decoded value is an "int" which is equal to 115792089237316195423570985008687907853269984665640564039457584007913129589356 however, when looking at etherscan the value is off and doesn't seem correct. It should be -50580.
I was able to hack my way with this issue by converting the value to a BigInt which works correctly.
Am I doing something wrong or is there something else that I have to do to get the correct value?
The text was updated successfully, but these errors were encountered:
Hi, so I am using
ethabi
library to try and decode anint24
on aMint
event. It seems that the returned value is not correct.Here is how I reproduce the issue.
First I check etherscan for the
Mint
event (log ord 29).The values in decimal for
tickLower
andtickHigher
are, respectively,-50580
and-36720
.The values in hex for
tickLower
andtickHigher
are, respectively,0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3a6c
and0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7090
.Rust
main.rs
to reproduce the issue:And this is the result I get when running the code:
Dependencies needed:
The decoded value is an "int" which is equal to
115792089237316195423570985008687907853269984665640564039457584007913129589356
however, when looking at etherscan the value is off and doesn't seem correct. It should be -50580.I was able to hack my way with this issue by converting the value to a BigInt which works correctly.
Am I doing something wrong or is there something else that I have to do to get the correct value?
The text was updated successfully, but these errors were encountered: