🤓Avoid using "transfer" to send ERC20s

Avoid using "transfer" on your smart contract, instead use "call".

More Info: https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/

â›” WRONG

function withdraw(uint256 amount) external {
        msg.sender.transfer(amount);
}

✅RIGHT

function withdraw(uint256 amount) external {
  (bool success, ) = msg.sender.call.value(amount)(""); // HERE's the "CALL"
  require(success, "Transfer failed."); // Confirm the transaction
}
Logic behind execution.

Last updated

Was this helpful?