βContract Cannot Accept Ether DoS
What is DOS ?
Example
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract King π {
address king;
uint public prize;
address public owner;
constructor() payable {
owner = msg.sender;
king = msg.sender;
prize = msg.value;
}
receive() external payable {
require(msg.value >= prize || msg.sender == owner);
// Will fail if the King is a Smart Contract and can't receive Ether
payable(king).transfer(msg.value);
king = msg.sender;
prize = msg.value;
}
}Mitigation and Best Practice:
Conclusion:
Last updated