Skip to content

Conversation

@iuwqyir
Copy link
Contributor

@iuwqyir iuwqyir commented Jan 17, 2025

TL;DR

Added a new API endpoint to fetch token balances by type (ERC20, ERC721, ERC1155) for a given address.

What changed?

  • Added /balances/:owner/:type endpoint to retrieve token balances
  • Created materialized views in ClickHouse to track token balances from transfer events
  • Implemented balance querying with support for pagination and filtering
  • Added support for hiding zero balances
  • Introduced token balance data structures and query filters

How to test?

  1. Start the API server
  2. Query the endpoint: /balances/{address}/{token_type}
    • token_type: "erc20", "erc721", or "erc1155"
    • Optional query params:
      • hide_zero_balances: true/false
      • token_address: specific token contract
      • page and limit: for pagination
      • sort_by and sort_order: for sorting

Why make this change?

To provide a convenient way to fetch token balances for addresses across different token standards, enabling better wallet integration and portfolio tracking capabilities.

Copy link
Contributor Author

iuwqyir commented Jan 17, 2025

@iuwqyir iuwqyir marked this pull request as ready for review January 17, 2025 14:11
@iuwqyir iuwqyir force-pushed the 01-16-use_inserts_instead_of_lightweight_deletes_to_remove_reorged_data branch from 642b121 to ef06e1d Compare January 20, 2025 13:57
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from 19f06cb to 9e41ec1 Compare January 20, 2025 13:57
@iuwqyir iuwqyir force-pushed the 01-16-use_inserts_instead_of_lightweight_deletes_to_remove_reorged_data branch from ef06e1d to f2005cc Compare January 21, 2025 00:38
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from 9e41ec1 to 095b23c Compare January 21, 2025 00:38
@iuwqyir iuwqyir force-pushed the 01-16-use_inserts_instead_of_lightweight_deletes_to_remove_reorged_data branch from f2005cc to ee306d4 Compare January 21, 2025 15:23
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from 095b23c to 6012e99 Compare January 21, 2025 15:23
@iuwqyir iuwqyir force-pushed the 01-16-use_inserts_instead_of_lightweight_deletes_to_remove_reorged_data branch from ee306d4 to da1b7ce Compare January 21, 2025 23:07
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from 6012e99 to 0027fe0 Compare January 21, 2025 23:08
@iuwqyir iuwqyir force-pushed the 01-16-use_inserts_instead_of_lightweight_deletes_to_remove_reorged_data branch from da1b7ce to 269a2fd Compare January 21, 2025 23:26
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from 0027fe0 to 0746373 Compare January 21, 2025 23:26
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from 0746373 to 78f89a6 Compare February 5, 2025 14:40
@iuwqyir iuwqyir changed the base branch from 01-16-use_inserts_instead_of_lightweight_deletes_to_remove_reorged_data to 02-05-handle_sigterm February 5, 2025 14:40
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from 78f89a6 to 2794038 Compare February 5, 2025 14:45
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from 2794038 to bebc12d Compare February 6, 2025 09:14
@iuwqyir iuwqyir force-pushed the 02-05-handle_sigterm branch from 709e2ec to 5ca2e8c Compare February 6, 2025 10:41
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from bebc12d to 2879e27 Compare February 6, 2025 10:42
@iuwqyir iuwqyir force-pushed the 02-05-handle_sigterm branch from 5ca2e8c to a851003 Compare February 6, 2025 11:59
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from 2879e27 to f565593 Compare February 6, 2025 11:59
@iuwqyir iuwqyir force-pushed the 02-05-handle_sigterm branch from a851003 to 91c6a6f Compare February 6, 2025 12:17
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from f565593 to 643ca0f Compare February 6, 2025 12:17
@iuwqyir iuwqyir force-pushed the 02-05-handle_sigterm branch from 91c6a6f to a4e99ae Compare February 6, 2025 12:34
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from 643ca0f to defc6e7 Compare February 6, 2025 12:35
@iuwqyir iuwqyir changed the base branch from 02-05-handle_sigterm to graphite-base/136 February 6, 2025 14:25
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from defc6e7 to 8ba80e1 Compare February 6, 2025 14:26
@iuwqyir iuwqyir changed the base branch from graphite-base/136 to main February 6, 2025 14:26
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from 8ba80e1 to 416b7c3 Compare February 6, 2025 14:26
@iuwqyir iuwqyir force-pushed the 01-17-create_an_endpoint_to_query_token_balances branch from 416b7c3 to 38f40ce Compare February 6, 2025 14:34
@iuwqyir iuwqyir merged commit 2a342e3 into main Feb 6, 2025
5 checks passed
@iuwqyir iuwqyir deleted the 01-17-create_an_endpoint_to_query_token_balances branch February 6, 2025 14:36
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.

3 participants