Register and show off your project at Ethereum QuickPitch and win $10,000. Apply now

Contents

qn_getWalletTokenBalance RPC method

The API credit value for this method is 4 . To learn more about API credits and each method's value, visit the API Credits page.

Supports ERC-20 compliant contracts (on Ethereum mainnet).

Headers:

  1. x-qn-api-version — (Integer - optional) Provide an optional request header specifying the QuickNode API version you're targeting. Using this header is recommended as it will become mandatory (required) in the future. Current API version is 1.

Parameters:

  1. Object — Custom Object with the following fields:

    wallet — (String) The wallet address to check for ERC-20 tokens.

    contracts — (Array of Strings - optional) List of ERC-20 contract addresses to filter wallet balance results on. You may include up to 100 contract addresses per request.

Returns:

  1. Object — Custom Response Object, or null if no tokens are found:

    owner — The wallet address we checked for tokens.

    assets — An array of objects representing tokens with the following shape:

    address — The address of the ERC-20 token contract.

    amount — The balance of the token within the owner's wallet.

    chain — The chain where the contract was deployed.

    decimals — The number of decimal places supported by the token contract.

    name — The name of the token.

    network — The network where the contract was deployed.

    symbol — The symbol of the token.

Code Examples:

const ethers = require("ethers");
(async () => {
  const provider = new ethers.providers.JsonRpcProvider("http://sample-endpoint-name.network.quiknode.pro/token-goes-here/");
  provider.connection.headers = { "x-qn-api-version": 1 };
  const heads = await provider.send("qn_getWalletTokenBalance", {
    wallet: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
  });
  console.log(heads);
})();
Ready to get started? Create a free account