Transfer function not changing custom token(ERC20) balance after successful transfer from transfer function ?

The transaction is successfully performed but the amount of custom token in my wallet does not change after the transaction is completed. Why is that ?

function insertPartcipantsInJackpot(address tokenAddress,uint256 counter,address payable participant) override external 
        console.log("Over here 1");
        require(IERC20(tokenAddress).balanceOf(address(this)) >= _jackPots[counter]._entryFee,
         "Not Sufficent Funds");

        console.log("Over here 2");
        require(_jackPots[counter]._endTime > _dateTime._now(),
        "This Participant Cannot Enter This Jackpot, Because The Event has already started");

        console.log("Over here 3");
        //deduct that amount,sent to owner account or can be done to contract itself

        _jackPots[counter]._prizePool += _jackPots[counter]._entryFee;
        //put that entry fee in that pool



1 Answer 1


Ok, Whilst in progress with a project I was doing, The transfer function cannot be used for this. So instead use transferFrom function that is provided by ERC20. But to use it, You first need to give ownership to spend your custom tokens then you can successfully use the transferFrom function. It is essential to give ownership to the spender either a (smart contract or a wallet), If you dont then it'll display a message of this sort insufficient allowance warning before the transaction and It'll eventually fail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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