I'm paying 0.38 gas fees in this function. There's something wrong with it?

function claim() external {
    require(allowed[msg.sender] == true, 'This address is not allowed to perform withdrawns');
    require(BUSD.balanceOf(address(this)) > block.timestamp - moment[msg.sender] * allowance[msg.sender], 'Not enough balance');
    uint amount = moment[msg.sender] * allowance[msg.sender];
    BUSD.transferFrom(address(this), msg.sender, amount);
    allowance[msg.sender] = 0;
    emit claimed(msg.sender, amount);

1 Answer 1


EVM gives such high fees when function is supposed to fail. In this case the culprit is transferFrom(). I don't think you should to use BUSD.transferFrom() here. You want to send msg.sender the amount calculated from the contract's address. Since contract will be the BUSD contract caller in this case, you should use:

BUSD.transfer(msg.sender, amount);

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.