'ERC20: insufficient allowance' (again)

I've checked this so many times, also went back to my older codes (that works), I do not understand why this is giving an allowance of zero. I've been stuck all day, what did I miss here?

const approve = await usdc.approve(contract.address, 1000); 
const numAllw = await usdc.allowance(user1.address, contract.address);
console.log(numAllow) // is zero

I know increaseAllowance can just performed both, but my returned allowance is still zero.
await usdc.connect(user1).increaseAllowance(user1.address, contract.address);

await contract.connect(user1).doStuff(1000)

contract Contract {
  function doStuff(uint amount)  public returns (bool) {
        // user send usdc
        USDC.transferFrom(msg.sender, address(this), amount);
        emit SendUSDC(msg.sender, amount);

reverted with reason string 'ERC20: insufficient allowance'

It should work so something you are doing isn’t correct, however without posting the exact code and transaction it’s hard to say what.

There approve function should return a true or false value telling you if it succeeded. Maybe the Usdc address is incorrect or different between you client side and Usdc address set in your contract?

Just checked, it returns true on approved.
Also checked usdc totalSupply calling from the contract, also returned a value. So the usdc address isn't incorrect.

This is all strange now :confused: . But thanks, it gives me some direction to debug into.

I think it is zero, cause you do not connect your account, maybe it should be

const approve = await usdc.connect(user1).approve(contract.address, 1000); 

And for the function increaseAllowance(), I think it should be

function increaseAllowance(address spender, uint256 addedValue)

So you need pass an address and amount rather than two addresses.