# cDAI.mint(\_amount) showing error 'Dai/insufficient-allowance'

**URL:** <https://forum.openzeppelin.com/t/cdai-mint-amount-showing-error-dai-insufficient-allowance/15014>\
**Category:** Smart Contracts\
**Tags:** erc20\
**Created:** [September 3, 2021, 4:26pm UTC](https://forum.openzeppelin.com/t/cdai-mint-amount-showing-error-dai-insufficient-allowance/15014 "2021-09-03T16:26:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yashmadhwal](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/yashmadhwal/32/8692_2.png) [@yashmadhwal](https://forum.openzeppelin.com/u/yashmadhwal)\
**Post date:** [September 3, 2021, 4:26pm UTC](https://forum.openzeppelin.com/t/cdai-mint-amount-showing-error-dai-insufficient-allowance/15014/1 "2021-09-03T16:26:02Z")

</div>

I have the following code in solidity:

```auto
pragma solidity ^0.8;

contract A{

    constructor() {
        dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
        cDai = cTokenInterface(0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643);
        owner = msg.sender;
    }

    IERC20 public dai;
    cTokenInterface public cDai;
    address public owner;

    uint public investedDai;

    function deposit(uint _amount) external {
            dai.transferFrom(msg.sender, address(this) , _amount);
            dai.approve(address(cDai),_amount);
            cDai.mint(_amount);
        }
}

```

I am facing a problem when calling the `deposit` function with parameters when testing the smart contracts. Additional information, I have forked mainnet and using the DAI whale account to make transactions.

This contract is working perfectly on RemixIDE when connected to Kovan testnet, i.e., using the tokens (DAI and cDAI) addresses on the Kovan testnet. On deploying the contract on the Kovan testnet, the contract address should be approved on the DAI contract by calling the `approve(address_of_the_contract_A, allowedAmount)` function before calling `deposit(_amount)` on contract A.

On testing the contract (after deploying and approving the smart contract's address), an error is thrown `Error: VM Exception while processing transaction: reverted with reason string 'Dai/insufficient-allowance'`. There is some error that I am not able to resolve. although in the test script, I am trying to mint, i.e. `cDAI.mint(amount)`, else I am getting the error `Error: Transaction reverted without a reason string`.

Anyleads will be helpful. I am using Hardhat.
