Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missed token returned by ankr_getAccountBalance method #13

Closed
aminhdev opened this issue Nov 9, 2022 · 9 comments
Closed

Missed token returned by ankr_getAccountBalance method #13

aminhdev opened this issue Nov 9, 2022 · 9 comments

Comments

@aminhdev
Copy link

aminhdev commented Nov 9, 2022

Get account balance by running this

curl --location --request POST 'https://rpc.ankr.com/multichain' \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: $$$$$$$$$$$$$$$$$$$$$$' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "ankr_getAccountBalance",
    "params": {  
        "walletAddress": "0xdaf835f11537fca6db91e91c266d153200f46d52",
        "pageSize": 10000
    },
    "id": 1
}'

This is list tokens of 0xdaf835f11537fca6db91e91c266d153200f46d52
image

Expected result
ETH token returned in the result

Current result
Missed ETH token in the result

@aminhdev aminhdev changed the title Missed token returned Missed token returned by ankr_getAccountBalance method Nov 9, 2022
@bogatyr285
Copy link
Contributor

Greetings!

The issue is that in optimism chain you didn't receive ETH price?

{
    "jsonrpc": "2.0",
    "method": "ankr_getAccountBalance",
    "params": {  
        "blockchain":["optimism"],
        "walletAddress": "0xdaf835f11537fca6db91e91c266d153200f46d52",
        "pageSize": 10000
    },
    "id": 1
}

like this query results zero prices?

@aminhdev
Copy link
Author

aminhdev commented Nov 9, 2022

Greetings!

The issue is that in optimism chain you didn't receive ETH price?

{
    "jsonrpc": "2.0",
    "method": "ankr_getAccountBalance",
    "params": {  
        "blockchain":["optimism"],
        "walletAddress": "0xdaf835f11537fca6db91e91c266d153200f46d52",
        "pageSize": 10000
    },
    "id": 1
}

like this query results zero prices?

Sorry to confuse you, I should have described this issues in more detail

I ran this method

curl --location --request POST 'https://rpc.ankr.com/multichain' \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: $$$$$$$$$$$$$$$$$$$$$$' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "ankr_getAccountBalance",
    "params": {
        "blockchain":["optimism"],
        "walletAddress": "0xdaf835f11537fca6db91e91c266d153200f46d52",
        "pageSize": 10000
    },
    "id": 1
}'

This is the result returned by ankr_getAccountBalance method above

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "totalBalanceUsd": "0",
    "assets": [{
      "blockchain": "optimism",
      "tokenName": "Synthetix Network Token",
      "tokenSymbol": "SNX",
      "tokenDecimals": 18,
      "tokenType": "ERC20",
      "contractAddress": "0x8700daec35af8ff88c16bdf0418774cb3d7599b4",
      "holderAddress": "0xdaf835f11537fca6db91e91c266d153200f46d52",
      "balance": "0.005883172287304306",
      "balanceRawInteger": "5883172287304306",
      "balanceUsd": "0",
      "tokenPrice": "0",
      "thumbnail": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/optimism/assets/0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4/logo.png"
    }, {
      "blockchain": "optimism",
      "tokenName": "Dai Stablecoin",
      "tokenSymbol": "DAI",
      "tokenDecimals": 18,
      "tokenType": "ERC20",
      "contractAddress": "0xda10009cbd5d07dd0cecc66161fc93d7c9000da1",
      "holderAddress": "0xdaf835f11537fca6db91e91c266d153200f46d52",
      "balance": "0.12201000950112047",
      "balanceRawInteger": "122010009501120470",
      "balanceUsd": "0",
      "tokenPrice": "0",
      "thumbnail": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/arbitrum/assets/0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1/logo.png"
    }, {
      "blockchain": "optimism",
      "tokenName": "Optimism",
      "tokenSymbol": "OP",
      "tokenDecimals": 18,
      "tokenType": "NATIVE",
      "holderAddress": "0xdaf835f11537fca6db91e91c266d153200f46d52",
      "balance": "0.000062982972903158",
      "balanceRawInteger": "62982972903158",
      "balanceUsd": "0",
      "tokenPrice": "0",
      "thumbnail": "https://www.ankr.com/protocol/static/media/optimism.53b7f574.svg"
    }]
  }
}

You can see no ETH token info is returned in the result even though ETH token actually exists in the account
Link scan
image

@bogatyr285
Copy link
Contributor

Got it. Yes, we have some issues with optimism network.
Thanks for report. We'll figure it out

@shlomich
Copy link

shlomich commented Apr 2, 2023

I think the API is alright, however since Optimism uses Ethereum as it's NATIVE token you can notice the tokenType that shows "NATIVE", I do agree though it needs to be "Ethereum" with that native tokenType aswell. But you can surely add a small validation to get that right. :P

@aminhdev
Copy link
Author

aminhdev commented Apr 3, 2023

I think the API is alright, however since Optimism uses Ethereum as it's NATIVE token you can notice the tokenType that shows "NATIVE", I do agree though it needs to be "Ethereum" with that native tokenType aswell. But you can surely add a small validation to get that right. :P

I don't think the API is alright, the contributor confirmed that here is an issue #13 (comment)
But for now I have to do as your suggestion 👍

@RedCuckoo
Copy link
Contributor

Closing as this has been fixed. ETH is now returned as NATIVE as well as Optimism.

@aminhdev
Copy link
Author

This problem come again, for now I ETH is not returned in the result
I tried to run this code

curl --location --request POST 'https://rpc.ankr.com/multichain/<my-premium-api-key>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "ankr_getAccountBalance",
    "params": {  
        "walletAddress": "0xE935c4E5DcCB41A811e33AB5f03901E491cd9BE3",
        "blockchain": "optimism"
    },
    "id": 1
}'
`

This is response

  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "totalBalanceUsd": "0.029995444084849786",
    "totalCount": 1,
    "assets": [
      {
        "blockchain": "optimism",
        "tokenName": "USD Coin",
        "tokenSymbol": "USDC",
        "tokenDecimals": 6,
        "tokenType": "ERC20",
        "contractAddress": "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
        "holderAddress": "0xe935c4e5dccb41a811e33ab5f03901e491cd9be3",
        "balance": "0.029997",
        "balanceRawInteger": "29997",
        "balanceUsd": "0.029995444084849786",
        "tokenPrice": "0.99994813097475702",
        "thumbnail": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/optimism/assets/0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85/logo.png"
      }
    ],
    "syncStatus": {
      "timestamp": 1711698299,
      "lag": "-2m",
      "status": "synced"
    }
  }
}

The problem here is no ETH included in the response, I want to confirm that ETH is already in my account at this request time, you can check it here https://gyazo.com/d98b7d2a98ec87725b22cc6dca1827b3

@RedCuckoo
Copy link
Contributor

@aminhdev Could you double check please and send an output of the curl also? Because it returns three balances at that account from every our cluster and from rpc endpoint.

@aminhdev
Copy link
Author

aminhdev commented Apr 1, 2024

@aminhdev Could you double check please and send an output of the curl also? Because it returns three balances at that account from every our cluster and from rpc endpoint.

Sorry to disturb you here. I've created a support ticket and received a response. I will discuss it in the supported ticket instead. 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants