> For the complete documentation index, see [llms.txt](https://docs.tokensfarm.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tokensfarm.com/for-developers/integrate-tokensfarm/getters-of-tokensfarm-contract.md).

# Getters of TokensFarm Contract

### Get info from relevant contract public fields

#### The staked ERC-20 token's address

```solidity
IERC20 public tokenStaked;
```

#### Total amount of tokens deposited to a farm

```solidity
 uint256 public totalDeposits;
```

#### Total amount of tokens that were paid out as rewards

```solidity
uint256 public paidOut;
```

#### The current total rewards amount

```solidity
uint256 public totalRewards;
```

#### The amount of tokens rewarded per second

```solidity
uint256 public rewardPerSecond;
```

#### The farm's start and end times

```solidity
uint256 public startTime;
uint256 public endTime;
```

#### The early withdrawal penalty

```solidity
EarlyWithdrawPenalty public penalty;
```

#### The fee rates in percentages %

```solidity
uint256 public stakeFeePercent;
uint256 public rewardFeePercent;
uint256 public flatFeeAmount;
```

#### The number of farm participants

```solidity
uint256 public noOfUsers;
```

#### The addresses of all farm participants and `mapping` of users to get the `index`

```solidity
address[] public participants;
mapping(address => uint256) public id;
```

## Getters

### Get the Address of a Staked Token&#x20;

```
IERC20 public tokenStaked;
```

### Get the Amount of Deposited ERC-20 Tokens via `stakeId`

```solidity
function deposited(address _user, uint256 stakeId)
```

| Parameters | Type      | Description                             |
| ---------- | --------- | --------------------------------------- |
| `user`     | `address` | The `user` address whose data you fetch |
| `stakeId`  | `uint256` | The `stakeId` of the particular stake   |

returns:

<table><thead><tr><th width="242">Parameters</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>stake.amount</code></td><td><code>uint256</code></td><td>The resulting number will be the ERC-20 amount that was deposited in the requested stake.</td></tr></tbody></table>

### Get pending reward amount

```solidity
function pending(address _user, uint256 stakeId)
```

<table><thead><tr><th width="207.33333333333331">Parameters</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>user</td><td><code>address</code></td><td>The <code>user</code> address whose data you fetch</td></tr><tr><td>stakeId</td><td><code>uint256</code></td><td>The <code>stakeId</code> of the particular stake</td></tr></tbody></table>

returns:

<table><thead><tr><th width="242">Parameters</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>rewardAmount</td><td><code>uint256</code></td><td>The amount of pending ERC-20 rewards</td></tr></tbody></table>

### How many time a user staked

To get the number of user stakes from a TokensFarm contract, you must call `getNumberOfUserStakes` on the `TokensFarm` smart contract.

```solidity
function getNumberOfUserStakes(address user)
```

| Parameters | Type      | Description                             |
| ---------- | --------- | --------------------------------------- |
| user       | `address` | The `user` address whose data you fetch |

returns:

<table><thead><tr><th width="242">Parameters</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>stakeInfo[user].length</td><td><code>uint256</code></td><td>The resulting number will represent how many times the user has staked.</td></tr></tbody></table>

### Get deposit timestamp

```solidity
function depositTimestamp(address _user, uint256 stakeId)
```

<table><thead><tr><th width="262.35455543358944">Parameters</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>user</td><td><code>address</code></td><td>The <code>user</code> address whose data you fetch</td></tr><tr><td>stakeId</td><td><code>uint256</code></td><td>The <code>stakeId</code> of the particular stake</td></tr></tbody></table>

returns:

<table><thead><tr><th width="242">Parameters</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>timestamp</td><td><code>uint256</code></td><td>The timestamp of the deposit</td></tr></tbody></table>

### Get withdraw timestamp

```solidity
function withdrawTimestamp(address _user, uint256 stakeId)
```

<table><thead><tr><th width="262.35455543358944">Parameters</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>user</td><td><code>address</code></td><td>The <code>user</code> address whose data you fetch</td></tr><tr><td>stakeId</td><td><code>uint256</code></td><td>The <code>stakeId</code> of the particular stake</td></tr></tbody></table>

returns:

<table><thead><tr><th width="242">Parameters</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>timestamp</td><td><code>uint256</code></td><td>The timestamp of the withdraw</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.tokensfarm.com/for-developers/integrate-tokensfarm/getters-of-tokensfarm-contract.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
