# User Balances

When a user purchases a bond from BondProtocol, they receive a vesting token. The underlying payout token is held by the Teller contract. Users can redeem their vesting tokens for the underlying payout token when the vesting period is complete.

The way our contracts work is to create a vesting token for each unique combination of underlying token + vesting date timestamp. All tokens vest at midnight UTC.

Our Fixed-Expiry markets create an `ERC-20` vesting token, while our Fixed-Term markets create an `ERC-1155` vesting token.

Our Teller contracts have functions which return the token address (in the case of an `ERC-20`) or token ID (in the case of an `ERC-1155`). In both cases, you must provide the address of the underlying payout token, and the vesting date timestamp.

For Fixed-Expiry markets, this is straightforward - there is only one expiry date, and as such, only one vesting token.

For Fixed-Term markets, there is a different vesting token for each day the market is open, with the vesting timestamp being the day of purchase plus the vesting term.

See below for more details.

### ERC-20 (Fixed-Expiry) Vesting Tokens

You can find the vesting token address by calling the `bondTokens(payoutTokenAddress, vestingTimestamp)` function on the `FixedExpiryTeller` contract.

As the vesting token is an `ERC-20` token, you can then call the vesting token's `balanceOf(holderAddress)` function to get the user's balance.

### ERC-1155 (Fixed-Term) Vesting Tokens

{% hint style="danger" %}
The easiest way to get the data required below is from our subgraph. However, as our Ethereum Mainnet subgraph is on [Graph Protocol's](https://thegraph.com) decentralized network, this would require you to pay query fees.

At the time of writing, other chains are available on the Graph Protocol hosted service without fees. Graph Protocol have not yet announced a timeline for migrating the other chains we support to their decentralized network.

As all tokens vest at midnight UTC, one manual alternative method of generating vesting date timestamps is, for each day your market will be open, to add the vesting term to a midnight UTC timestamp for that date.
{% endhint %}

You can find the vesting token ID by calling the `getTokenId(payoutTokenAddress, vestingTimestamp)` function on the `FixedTermTeller` contract.

As the vesting token is an `ERC-1155` token, you can then call the vesting token's `balanceOf(holderAddress, tokenId`) function to get the user's balance.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.bondprotocol.finance/developers/user-balances.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
