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

Token Balances #28

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Token Balances #28

wants to merge 1 commit into from

Conversation

bh2smith
Copy link
Contributor

@bh2smith bh2smith commented May 3, 2024

This is a self-hosted approach to fetching token balances for a given account address across many chains.

It retrieves balances by making (simultaneous) direct rpc calls to token.balanceOf(account) for a fixed tokenList.

Some drawbacks here are

  • [maintenance] having a fixed token list. However, there are several publicly available token lists here: https://tokenlists.org/ so we don't need to maintain our own fixed list.
  • [scalability] if the token list is too large, we will be limited by the node provider to too many simultaneous requests.

Alternative options:

There are services that offer token balances. For example

curl --request POST \
     --url https://eth-mainnet.g.alchemy.com/v2/$ALCHEMY_KEY \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '{"id": 1,"jsonrpc": "2.0","method": "alchemy_getTokenBalances","params": ["0x7f01D9b227593E033bf8d6FC86e634d27aa85568"]}'

it returned a page key and the docs are unclear on how to get the next page.

curl https://docs-demo.quiknode.pro/ \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{
    "id":67,
    "jsonrpc":"2.0",
    "method":"qn_getWalletTokenBalance",
    "params": [{
      "wallet": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
      "page": 2
    }]
  }'

cc @SurgeCode

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

Successfully merging this pull request may close these issues.

1 participant