# Deposit into a farm

### Deposit

To deposit into a TokensFarm contract, you must call `deposit` on the `TokensFarm` smart contract.

Notice that it is possible to deposit multiple times.

{% hint style="info" %}
First, make sure to `approve` spend on the ERC20 token that you wish to farm
{% endhint %}

```solidity
function deposit(uint256 _amount)
```

| Parameters | Type      | Description                                             |
| ---------- | --------- | ------------------------------------------------------- |
| Amount     | `uint256` | The amount that the user wishes to deposit to the farm. |

#### Example script for deposit in JS

```javascript
const hre = require("hardhat");
async function main(){    
        const tokensFarmContract = await hre.ethers.getContractAt(
        tokensFarmArtifact.abi,
        "the contracts address here"
        );
        const erc20TokenContract = await hre.ethers.getContractAt(
        erc2-TokenArtifact.abi,
        "the contracts address here"
        );
        let amountToDeposit = 5000;
        //First approve to tokensFarm contract to spend the tokens
        await erc20TokenContract.approve(amountToDeposit);
        //Call deposit function    
        await tokensFarmFactory.deposit(amountToDeposit);
}
```
