WalletBalanceProvider

This contract is a balance aggregator. It helps frontends or services query multiple token balances at once, making it efficient for dashboards, portfolio trackers, or DeFi apps where users hold many assets.

Functions

  • balanceOf(address user, address token) → uint256 Returns the balance of a specific token held by a given user.

    • user: The wallet address to check.

    • token: The ERC20 token contract address.

    • Output: Token balance (uint256).


  • batchBalanceOf(address[] users, address[] tokens) → uint256[] Returns balances for multiple users and tokens in one call (bulk query).

    • users: Array of wallet addresses.

    • tokens: Array of token addresses.

    • Output: Array of balances, aligned with the (user, token) pairs queried.


  • getUserWalletBalances(address provider, address user) → (address[] tokens, uint256[] balances) Fetches all token balances for a given user from a specified provider.

    • provider: Likely a registry or liquidity provider that tracks tokens.

    • user: The wallet address whose balances are being checked.

    • Outputs:

      • tokens: Array of token addresses.

      • balances: Array of balances corresponding to those tokens.


  • receive() payable The contract can directly accept ETH transfers.

[
  {
    "inputs": [
      { "internalType": "address", "name": "user", "type": "address" },
      { "internalType": "address", "name": "token", "type": "address" }
    ],
    "name": "balanceOf",
    "outputs": [
      { "internalType": "uint256", "name": "", "type": "uint256" }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      { "internalType": "address[]", "name": "users", "type": "address[]" },
      { "internalType": "address[]", "name": "tokens", "type": "address[]" }
    ],
    "name": "batchBalanceOf",
    "outputs": [
      { "internalType": "uint256[]", "name": "", "type": "uint256[]" }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      { "internalType": "address", "name": "provider", "type": "address" },
      { "internalType": "address", "name": "user", "type": "address" }
    ],
    "name": "getUserWalletBalances",
    "outputs": [
      { "internalType": "address[]", "name": "", "type": "address[]" },
      { "internalType": "uint256[]", "name": "", "type": "uint256[]" }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  { "stateMutability": "payable", "type": "receive" }
]

Last updated

Was this helpful?