LogoLogo
AppAbout
  • 🙂Meet TokensFarm
  • Overview
    • 💻Our Products
    • ⚙️Features
    • 🚀Launch a Farm for Your Project
    • 🔏Using Gnosis Safe
  • For Developers
    • TokensFarmSDK
      • Getters
      • Setters
      • Parameters
      • ISDK.sol
      • Deposit
      • Withdraw
    • Integrate TokensFarm
      • Requesting Farm Data
      • Get Farm Address and Full Details
      • Monitoring a Farm's Status
      • Deposit into a farm
      • Withdraw from a farm
      • TokensFarm Contract Interface
      • How to integrate TokensFarmSDK
      • How to Embed TokensFarm
      • Getters of TokensFarm Contract
    • PerpetualTokensFarmSDK
      • Getters
      • Setters
      • Parameters
      • ISDK.sol
      • Deposit
      • Withdraw
    • PerpetualTokensFarm
      • Getters
      • Setters
      • Parameters
      • Deposit
      • Withdraw
  • About
    • 🔉Social Media
    • 🏢About DcentraLab
    • ❓FAQ
    • 📜Tokensfarm Audits
    • 📞Support
    • ⚖️Legal
Powered by GitBook
On this page

Was this helpful?

  1. For Developers
  2. Integrate TokensFarm

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

PreviousMonitoring a Farm's StatusNextWithdraw from a farm

Last updated 3 years ago

Was this helpful?