Skip to content

no-send

Forbids the use of send and transfer for sending value, in favor of using call with value.

Examples of incorrect code for this rule:

contract Example {
address payable owner;
function withdrawWithSend(uint amount) public {
owner.send(amount);
}
function withdrawWithTransfer(uint amount) public {
owner.transfer(amount);
}
}

Examples of correct code for this rule:

contract Example {
address payable owner;
function withdraw(uint amount) public {
owner.call{ value: amount }("");
}
function withdrawToken(IERC20 token, uint amount) public {
token.transfer(owner, amount);
}
}