neo-node icon indicating copy to clipboard operation
neo-node copied to clipboard

"getnep17balances" RPC vs "list asset" cli command have balance difference for GAS

Open ixje opened this issue 5 years ago • 10 comments

RPC

curl -d '
{
    "jsonrpc": "2.0",
    "method": "getnep17balances",
    "params": ["NQrEVKgpx2qEg6DpVMT5H8kFa7kc2DFgqS"],
    "id": 3}' -H 'Content-Type: application/json' http://localhost:20332

{
   "jsonrpc":"2.0",
   "id":3,
   "result":{
      "balance":[
         {
            "assethash":"0xd2a4cff31913016155e38e474a2c06d08be276cf",
            "amount":"1000",
            "lastupdatedblock":9
         },
         {
            "assethash":"0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
            "amount":"1000",
            "lastupdatedblock":9
         }
      ],
      "address":"NQrEVKgpx2qEg6DpVMT5H8kFa7kc2DFgqS"
   }
}

neo-cli

neo> list asset
NQrEVKgpx2qEg6DpVMT5H8kFa7kc2DFgqS
NEO: 1000
GAS: 0.00001

Notice the GAS balance

ixje avatar Mar 15 '21 07:03 ixje

I think it is right because getnep17balances is expressed with decimal.

cloud8little avatar Mar 15 '21 07:03 cloud8little

@cloud8little thank you for the quick response. In preview5 to send 1000 NEO and 1000 GAS we used the following RPC command

curl -d '
{
    "jsonrpc": "2.0",
    "method": "sendmany",
    "params": [
        "NhxvE7rd27zdz3qTUdaBGpeckzd26VJHZr",
        [
            {
                "asset":"0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
                "value":"1000",
                "address":"NQrEVKgpx2qEg6DpVMT5H8kFa7kc2DFgqS"
            },
            {
                "asset":"0xd2a4cff31913016155e38e474a2c06d08be276cf",
                "value":"1000",
                "address":"NQrEVKgpx2qEg6DpVMT5H8kFa7kc2DFgqS"
            }
        ]],"id": 3}' -H 'Content-Type: application/json' http://localhost:20332

This worked as intended. Are you saying that for RC1 we should now multiply the value field with the decimals of the token?

e.g. to send 1000 GAS we should do (1000 * pow(10, decimals)) ?

            {
                "asset":"0xd2a4cff31913016155e38e474a2c06d08be276cf",
                "value":"100000000000",
                "address":"NQrEVKgpx2qEg6DpVMT5H8kFa7kc2DFgqS"
            }

because the documentation isn't clear on this

ixje avatar Mar 15 '21 07:03 ixje

Related to neo-project/neo-modules#505.

roman-khimov avatar Mar 15 '21 08:03 roman-khimov

Related to neo-project/neo-modules#505.

No, the request should be the same as before. no need to change the value in the request body, but only the neo-cli shows the asset with dividing by its decimal. and All query API(getnep17balance, getunclaimedgas) will show the result with decimal. We will update the documentation to clarify this.

cloud8little avatar Mar 15 '21 08:03 cloud8little

@cloud8little it seems that I do have to change the amount in the request body. Only if I do sendmany with an amount of 100000000000 will I get 1000 GAS according to neo-cli.

ixje avatar Mar 15 '21 08:03 ixje

@cloud8little it seems that I do have to change the amount in the request body. Only if I do sendmany with an amount of 100000000000 will I get 1000 GAS according to neo-cli.

Let me confirm.

cloud8little avatar Mar 15 '21 08:03 cloud8little

@ixje it is fixed https://github.com/neo-project/neo-modules/pull/562, somehow it is changed by mistake and it should be good now.

cloud8little avatar Mar 15 '21 09:03 cloud8little

@cloud8little that PR does not seem to fix the issue with sendmany RPC call. I still have to use 100000000000 in order to receive 1000 GAS 😕

ixje avatar Mar 15 '21 14:03 ixje

00000000

It is intended since we use BigInteger (100000000000 ) rather than BigDecimal (1000) to ensure accuracy.

bettybao1209 avatar Mar 16 '21 02:03 bettybao1209

@cloud8little that PR does not seem to fix the issue with sendmany RPC call. I still have to use 100000000000 in order to receive 1000 GAS 😕

The PR fix sendfrom and sendtoaddress to keep consistent with sendmany. sorry for the confusion. keep the decimal in the input is correct.

cloud8little avatar Mar 16 '21 02:03 cloud8little

Old, if remains, please re-open

shargon avatar Dec 05 '23 13:12 shargon