I am trying to deposit kovan DAI to my smart contract by using transferFrom of the ERC20 function, but I get an Dai/insufficient-allowance.

So I tried approving it explicitly and then trying to transfer… The approval works but this the transferFrom doesn't.

Please help me. I just started with ERC 20.

Thanks in advance!

The code:

 function appDai(uint _amount) public {
    daitoken.approve(msg.sender, _amount);

function depDai(uint _amount) public {
    require(daitoken.balanceOf(msg.sender) >= _amount);
    daitoken.transferFrom(msg.sender, address(this), _amount);
    emit Deposit(msg.sender, _amount);

and I also tried approved and increasaAllowance methods too

function incDai(uint _amount) public {
    daitoken.increaseAllowance(address(this), _amount);

function incDaiSend(uint _amount) public {
    daitoken.increaseAllowance(msg.sender, _amount);

1 Answer 1


You have to approve the DAI transfer NOT in you smart contract, but in the DAI's contract by the owner of the DAIs; otherwise, it is your contract trying to approve itself an amount of DAIs belonging to another user.

You can go to the DAI's smart contract in Kovan and do the approval there from the user who wants to send DAIs to your Uniswap contract.

  • Thanks a lot!!! So everytime I need to call the DAI's functions's approve method for my custom smart contracts address before depositing. Got it. Thank you once again Feb 23, 2021 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.