'SafeERC20: low-level call failed' when trying to stake LP tokens

I think I have my token and staking set up all right, but when trying to call the stakeLP function, I’m getting the error - ‘SafeERC20: low-level call failed’. Everything else is works seemingly okay.

:computer: Environment
I’m using Remix on Ropsten testnet. The LP is from Uniswap.

I saw some other posts with a similar problem and most of them didn’t just have the tokens minted.
It is unclear to me if I have to generate the tokens beforehand and transfer them to token or staking contract address? Either way, I tried that.

:1234: Code to reproduce
This is the contract for the token - https://ropsten.etherscan.io/address/0x4ef753F74899EA2b0C46b6CA3a064BDA022C0507

This is for the staking

1 Like

Hi, welcome!

Have you called LPToken.approve(staking_contract, amount) before calling stakeLP()

1 Like

I would have to add it to the stakeLP function in the contract and deploy a new one? Because currently there is no such function to be called.

1 Like

No, is this your LP token: UniswapV2Pair | 0x13cC66Fd090097569176b572C387CfBE12cED2C9 , you can call approve in the etherscan.

1 Like

Tried it, still getting the same error. Probably doing something wrong. When approving and calling the staking function, do I have to type the amount with 18 zeroes? I currently have 77 uni-v2 tokens

1 Like

Emmm, I think you pass the wrong parameters, it should be

LPToken.approve(staking_contract, amount)

that is you should pass staking contract address, it should be 0x43eaBe1021AB48B83E3FfC994BdfC648aa26Ca50 rather than your own account address

1 Like

Yes thank you, I got it working, but only with small amounts. When trying to do the same with all of the LP tokens, I get the same error. If I have 77 uni tokens, the amount should be 77 with 18 zeroes, no? Or could I approve the max amount somehow?

1 Like


If you only want to approve a specific amount, for example you want to approve 77 UNI, so it should be

approve(to, 77*10**UNI_DECIMALS) => approve(to, 77*10**18)

Yeah, if you trust in the contract totally, you can approve a maximum amount,

approve(to, 2**256-1);
1 Like


One more slightly unrelated question. I’m doing this for a school project and I’d need the interface to look decent. Is there a some kind source code or a preset for a front end staking interface? I’ve seen many of them look really similar, but haven’t really found what they’re based on

1 Like

Emmm, maybe you can have a look at hardhat-react or Truffle Boxes or https://medium.com/ethworks/introducing-usedapp-framework-for-rapid-dapp-development-4959361f242a

I only used this Truffle Boxes React before.

1 Like

Thanks a lot for your help!