Endianness of uint128 numbers
First, I pushed an action using cleos. One of the action parameters is of type uint128 and I specified that like: {"number": 0xb3cb484ada4279ab609ca314e4209e11}. After the transaction, I did "cleos get table ..." and I saw the same number as it is in the contract table. Then, I did the same process using eosjs. This time, I specified this uint128 parameter value like: {number: '238987313771706096047051733442425298449'} since eosjs only accepts decimal format. And found that the contract table stores that value as {number: '0x119e20e414a39c60ab7942da4a48cbb3'}. This is natural considering the implementations of decimalToBinary() and binaryToDecimal() in eojs-numeric.ts. So looks like that it would be easy to modify these implementations to be compatible with cleos. I would like to know what are the intents or reasons for these current implementations.
eosjs and abieos do this to maintain consistency with all the integer types. The abi serializer used by cleos and nodeos treats (u)int128 as a raw bytes type instead of a numeric type to simplify its internal implementation.
How to pass uint128_t number as action parameter?
Update on the original question: we're considering switching nodeos and cleos to decimal for (u)int128.
How to pass uint128_t number as action parameter?
In eosjs, quote it in decimal form. e.g. "485829384751".
example in eosjs:
...,
actions: [{
account: 'foo',
name: 'bar',
authorization: [{
actor: 'useraaaaaaaa',
permission: 'active',
}],
data: [{
my_uint128_arg: '4959694834837',
my_int128_arg: '-857684798757643',
}],
}],
...
But when i pass a very big uint128_t number like 131613249979637300000000000000000000000, i got invalid number error. Is there anything wrong?
Did you quote it? "131613249979637300000000000000000000000"
Oh my fault. Quote it and it's ok~ Thanks
But in my table i have a data entry with a uint128_t value 0x01000000000000001052bc9483ac3036 which is little endian encoded from 131613249979637306740937603029919596560. I think hex string should be encoded in big endian order.
And when i pass either little endian decimal number or big endian decimal format, i cannot get the target uint128_t value from table.
When i pass hex string which retrieved from the table, it throw invalid number.
Code is below:

Table:


Like I said, we're considering changing the way nodeos and cleos handle this.
Thank you for the update on this issue.