APIs used:
  • Get token balances for address  

Overview

GoldRush's most popular endpoint, , has been a staple since GoldRush’s beginning and represents a core goal of simplifying the build and go-to-market process for developers. GoldRush provides a Unified API, which allows access to data from multiple blockchains in a single, cohesive interface. The Unified API makes it easy for developers to access data from various blockchains without working with numerous, inconsistent APIs or having to self-hosting a blockchain node.

On the other hand, an RPC (Remote Procedure Call) provider is a service or software that allows applications to access blockchain data directly through a Web3 hosted service like Infura, NodeReal, ChainStack, amongst others providers or through self-hosting a blockchain node.

This article compares the difference between GoldRush’s balances endpoint and those from Web3 RPCs, highlighting some key differences between the two to give an overview for developers.

info
GoldRush vs. RPC Providers - Read/Write capabilityOne important caveat is that the GoldRush Unified API is a read-only service and you still need a RPC provider to write to the blockchain.

GoldRush vs. RPC Providers

GoldRush’s balances endpoint, now on its third version, returns all the token balances (ERC20, ERC721 and ERC1155) for an address on any of 70+ supported blockchains. The Unified API approach allows for easy data retrieval across chains and standardizes each endpoint’s response in a rich, granular fashion.

RPCs provide access to the blockchain using a specific set of commands and methods the blockchain network has exposed. A balances endpoint from an RPC provider will typically return a specific balance or list of balances dependent on the user’s query, with little to no additional information.

There are several key differences between a Unified API and an RPC provider:

GoldRushRPC Provider
Data sourcesA Unified API typically provides access to data from various sources.An RPC provider typically allows applications to communicate with a specific service or application.
Data typesA Unified API may provide access to a wide range of data types, including structured, unstructured, and real-time data.An RPC provider may only provide access to specific data or functionality. In some cases, RPC providers don’t provide access to historical data because they don’t run or have access to archive nodes.
Data securityA Unified API like GoldRush’s can offer additional security measures. In our case, the data powering our API is cryptographically secured by the GoldRush Network Operators.An RPC provider may rely on the security measures of the underlying protocol or the applications or services it connects.

Comparing Balances Endpoints Head-to-Head

GoldRush’s Approach

GoldRush’s balances endpoint crawls the blockchain to find all token balances held by a Web3 wallet. Even tokens with zero balances are returned because the endpoint is formulated in a bank account style, where tokens are treated as accounts and it's possible that this wallet may have had this token in the past. This paints the most comprehensive picture of a user’s on-chain assets. Further, this endpoint can return ERC20 tokens and NFTs due to a “supported interfaces” field, which allows us to differentiate between token standards. Other data providers require developers to make separate calls for different types of tokens. On this point, GoldRush also combines native gas token balances in the response, which again requires separate RPCs because most of them are not ERC20.

Using the balances endpoint requires a free API key, selecting a blockchain from the sidebar, and inputting a valid wallet address. To return NFTs, set nft = true. To query the same wallet address on a different blockchain, a developer can change a single chain parameter, inputting either a chain_id or chain-name.

GoldRush Balances Example:

JavaScript
{
    "address": "0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de",
    "updated_at": "2023-01-04T21:38:40.008242796Z",
    "next_update_at": "2023-01-04T21:43:40.008242866Z",
    "quote_currency": "USD",
    "chain_id": 1,
    "items": [{
        "contract_decimals": 18,
        "contract_name": "Frontier Token"
        "contract_ticker_symbol": "FRONT",
        "contract_address": "0xf8c3527cc04340b208c854e985240c02f7b7793f",
        "supports_erc": [
            "erc20"
        ],
        "logo_url": "<https://logos.covalenthq.com/tokens/1/0xf8c3527cc04340b208c854e985240c02f7b7793f.png>",
        "last_transferred_at": "2022-09-27T15:29:11Z",
        "native_token": false,
        "type": "cryptocurrency",
        "balance": "4843997835959514312853",
        "balance_24h": "4843997835959514312853",
        "quote_rate": 0.180927,
        "quote_rate_24h": 0.18116738,
        "quote": 876.41,
        "quote_24h": 877.5744,
        "nft_data": NULL
    }]
}

In this sample response, metadata is returned as well as a token balance in the requested wallet. This includes the token name, ticker symbol, logo, contract decimals, and other helpful information. Also, notice the quote rate and historical balance 24 hours ago. Including this in the response means there’s no need to ping an archive node, which is often more expensive to run and manage.

RPC Provider Approach

RPC providers have their own set of token balance endpoints. However, they don’t serve formatted endpoints as GoldRush does. The most significant difference when fetching token balances is that where GoldRush returns all the token balances for an address (with the user only needing to specify the wallet address), RPC providers require the user to specify the address and a list of tokens to check that wallet for. So, for instance, if I suspect a large wallet is holding hundreds if not thousands, of tokens, I would need to specify the contract addresses for each of those tokens to create a comprehensive wallet display. Additionally, I don’t know which tokens the wallet is holding beforehand. That list changes from wallet to wallet. Developers can use a static list with the top commonly used tokens but risk missing many niche tokens. GoldRush maintains an index per wallet, so developers don’t need to know beforehand what tokens a wallet contains. The additional step of writing a script and specifying token contract addresses is eliminated with GoldRush’s balances endpoint.

Further, the response from an RPC endpoint will often not contain additional data about the tokens in a wallet, such as the contract decimals that each token needs to be divided by to calculate their true balance. Balances are returned in their raw form, which then must be adjusted. Still, each token contract might have different decimals, meaning that a developer can’t make a blanket calculation to determine them all. As seen above, GoldRush’s balances endpoint returns all the additional token data in the same endpoint response, which means no additional endpoints are required to build a standard wallet interface.

RPC Balances Example:

JavaScript
{
  address: '0x00000000219ab540356cbb839cbe05303d7705fa',
  tokenBalances: [
    {
      contractAddress: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
      tokenBalance: '4929853276',
      error: null
    }
  ]
}

In this sample response, only the token balance for the token contract and wallet address specified is returned.

Comparison

To get the same data from RPC providers thatGoldRush returns with one endpoint, a developer would need to follow these steps:

GoldRushRPC Provider
Step 1: Input wallet address and select networkStep 1: Install the software and create a file
Step 2: Click RUNStep 2: Write a script for specific tokens to fetch
Step 3: Input wallet address
Step 4: Run the code
Step 5: Save the response into a constant/variable
Step 6: Write additional code using a separate endpoint to get metadata for each token (required for token names and contract decimals)
Step 7: Input the saved response
Step 8: Run the code

Now, what about NFTs? Here are the additional steps a developer would need to do:

Step 3: Set nft = trueStep 9: Install additional software
Step 4: Click RUNStep 10: Create a new project
Step 11: Create a new script to fetch NFTs
Step 12: Input the wallet address and list of token contracts
Step 13: Run the code

In total, using GoldRush’s balances endpoint takes between 2-4 steps, whereas using an RPC provider takes between 8-13. Further, the time cost of each step is vastly different for developers, whereas GoldRush doesn’t require writing any complex code in order to fetch the data. Another key difference is the number of calls. For example, a wallet holding 20 tokens would require a developer to make 20 separate calls with an RPC provider, whereas with GoldRush, no matter the size of the wallet, it’s one API call.

Use Cases

The primary use case for token balance data is to create Web3 wallets such as Rainbow, Coinbase, etc. To understand the difference the GoldRush API makes in building these applications, click here to read more.

Secondary use cases include:

  • Auditing: Developers can use token balance data to check users’ ownership on the blockchain and to ensure that a transaction was completed correctly.

  • Token Gating: Applications or companies may require users or guests to hold a particular wallet asset to access their services. The balances endpoint can be used to check.

  • dApp Interaction: Developers can use token balance data to create new decentralized applications (dApps) to interact with user assets, such as games, social networks, virtual marketplaces etc.

  • Taxation: Developers can use token balance data to help individuals or companies comply with cryptocurrency tax laws.

  • Experimentation: Understanding and experimenting with data is sometimes the best way to learn.

GoldRush as a Complement to RPC Providers

For developers, there are benefits to using GoldRush in tandem with RPC providers. An RPC provider allows developers to interact directly with the blockchain, giving them complete control over the transactions they send and the data they receive. A Unified API like GoldRush’s, on the other hand, provides a higher-level interface that abstracts away many of the complexities of working directly with the blockchain. By using both an RPC provider and a Unified API, a developer can take advantage of the flexibility of the former while also benefitting from the latter's convenience.

For this reason, GoldRush has already established partnerships with RPC providers like Nodereal and will continue to make the Unified API accessible through other infrastructure partners.

Scaling

A Unified API can also help a developer to interact with blockchains in a more scalable way. The API can handle the load of multiple requests and handle the underlying infrastructure. It can also handle the caching of the data and rate limiting. A RESTful API like GoldRush’s can cache the responses of frequently-requested data, which can help reduce the number of requests to the blockchain and improve the application's performance. This can be especially useful for read-heavy applications, where the same data may be requested multiple times. This way, the developer can focus on the application logic rather than the scalability of the infrastructure. Unless an application displays just a few tokens on a few blockchains, a service like GoldRush’s is necessary for a project to scale up.

Premium API

At the end of 2022, GoldRush launched its first-ever Premium tier. This tier was explicitly created to give users higher rate limits on our popular endpoints, starting with the balances endpoint. It launched exclusively with balances supported on Ethereum, providing 50 RPS to Premium users. We then launched support for BSC and Polygon, meaning we can now support 50 RPS to Premium users querying Binance and Polygon wallet data. Click here to learn more about our plans and pricing. Note that GoldRush’s balances endpoint is seemingly more expensive than those from RPC providers, but it reflects the efficiency of the endpoint where 1 API call can be worth 1 to 1000+ RPC calls dependent on the size of the wallet and how many individual tokens a developer has to query for.

Conclusion

In conclusion, GoldRush's balances endpoint offers a more comprehensive and convenient way for developers to access token balances on various blockchains through a cohesive interface. It returns all the token balances (ERC20, ERC721 and ERC1155) for an address on any supported blockchain, which is above and beyond what traditional RPC providers can offer. Additionally, GoldRush's API provides additional data formatting and security measures to protect the data it accesses. The article highlights the critical differences between GoldRush's approach and RPC providers, making it clear that GoldRush's API offers a more efficient and scalable solution for developers looking to access blockchain data.