Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user

Solidity: Safe way to withdraw from ccontract

Source Link
M M
  • 57
  • 7

Solidity: Safe way to withdraw from c

I have a contract that accepts ETH and turns it into WETH and keeps it. I have written a function to withdraw this tokens from contract. Is this function safe?

    modifier onlyUsers {
        require(_users[msg.sender] || msg.sender == _owner, "Not Allowed");
        _;
     }

    function withdrawTokensFromContract(address _token, uint256 _amount) public onlyUsers returns (bool) {
        uint256 balance = getTokenBalance(_token);
        require(balance >= _amount, 'Amount exceeds Balance');
        IBEP20(_token).transfer(msg.sender, _amount);
    }