Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stargate: no pagination available for Bank/TotalSupply

See original GitHub issue

I am trying to paginate my call to TotalSupply in stargate’s Bank module but it returns the same response whether I pass pagination params or not:

Image 2022-02-16 at 5 43 00 PM

In this screenshot I’m showing what I’ve done to create my own BankExtension, since stargate’s own one does not relay pagination details to the underlying call. I’ve had success creating my own extensions before, and I’ve verified that passing a pagination key in this way works when calling Staking/ValidatorDelegations, so it seems that this is purely an issue on the RPC node itself. The response is always the same (maxed out at 100) whether I pass pagination details or not.

The reason I think it’s on the RPC side is that stargate’s method of calling these endpoints is exactly the same:


ValidatorDelegations(request) {
    const data = exports.QueryValidatorDelegationsRequest.encode(request).finish();
    const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "ValidatorDelegations", data);
    return promise.then((data) => exports.QueryValidatorDelegationsResponse.decode(new minimal_1.default.Reader(data)));


TotalSupply(request) {
    const data = exports.QueryTotalSupplyRequest.encode(request).finish();
    const promise = this.rpc.request("", "TotalSupply", data);
    return promise.then((data) => exports.QueryTotalSupplyResponse.decode(new minimal_1.default.Reader(data)));

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

JGJPcommented, Mar 9, 2022

The problem was purely client side, but unfortunately Stargate doesn’t support specifying any pagination params, here’s my custom solution:

import { QueryClient } from "@cosmjs/stargate"
import { Tendermint34Client } from "@cosmjs/tendermint-rpc"
import { QueryClientImpl as BankQueryClientImpl } from "cosmjs-types/cosmos/bank/v1beta1/query"

const setupCustomBankExtension = base => {
    const queryService = new BankQueryClientImpl({
        request: (service, method, data) => {
            const path = `/${service}/${method}`
            return base.queryUnverified(path, data)
    return {
        customBank: {
            totalSupply: async paginationKey => {
                return await queryService.TotalSupply({
                    pagination: {
                        countTotal: false,
                        key: paginationKey,
                        offset: Long.fromNumber(0, true),
                        limit: Long.fromNumber(100, true),
                        reverse: false,
                    } as PageRequest,

const tmClient = QueryClient.withExtensions(
    await Tendermint34Client.connect(rpcEndpoint),

const paginationKey = new Uint8Array()
const { supply, pagination } = await tmClient.customBank.totalSupply(paginationKey)

Please thumbs up this or something so people know to use this

JGJPcommented, Mar 15, 2022

It looks like I didn’t form the pagination object correctly

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using AWS CLI pagination options
Use pagination options to optimize the output of AWS Command Line ... The --no-paginate option disables following pagination tokens on the client side....
Read more >
Pagination - Django REST framework
REST framework includes support for customizable pagination styles. This allows you to modify how large result sets are split into individual pages of...
Read more >
Pagination | Docs | Twitter Developer Platform
Not all API endpoints support or require pagination, but it is often used when ... available and can be used as the pagination_token...
Read more >
Control pagination - Microsoft Support
To prevent "Page not found" woes, we're removing links we know about. ... When you set pagination options, you can control where automatic...
Read more >
Pagination - Django documentation
Give Paginator a list of objects, plus the number of items you'd like to ... as Django's QuerySet to use a more efficient...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found