Deposit into a farm

Once you have the farm's address, you may now use the farm's contract to participate and earn rewards.

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.

First, make sure to approve spend on the ERC20 token that you wish to farm

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

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);
}

Last updated