Skip to main content

balanceOf

Contract: JBTokenStore​‌

Interface: IJBTokenStore

The total balance of tokens a holder has for a specified project, including claimed and unclaimed tokens.

Definition

function balanceOf(address _holder, uint256 _projectId)
external
view
override
returns (uint256 balance) { ... }
  • Arguments:
    • _holder is the token holder to get a balance for.
    • _projectId is the project to get the _holders balance of.
  • The view function can be accessed externally by anyone.
  • The view function does not alter state on the blockchain.
  • The function overrides a function definition from the IJBTokenStore interface.
  • The function returns the project token balance of the _holder.

Body

  1. Get a reference to the holder's unclaimed balance for the project.

    // Get a reference to the holder's unclaimed balance for the project.
    balance = unclaimedBalanceOf[_holder][_projectId];

    Internal references:

  2. Get a reference to the project's current token.

    // Get a reference to the project's current token.
    IJBToken _token = tokenOf[_projectId];

    Internal references:

  3. If the project has a current token, add the holder's balance to the total.

    // If the project has a current token, add the holder's balance to the total.
    if (_token != IJBToken(address(0))) balance = balance + _token.balanceOf(_holder, _projectId);

    External references: