35: Receive
Receive()
contract MyContract { // Receive Ether
receive() external payable { // Do something with the received ether }
}import "./token.sol"; // A standard ERC20 token
contract MyContract {
Token token;
constructor(address _tokenAddress) {
token = Token(_tokenAddress);
}
// Receive ERC20 tokens
receive() external {
uint256 amount = msg.value;
token.transferFrom(msg.sender, address(this), amount);
}
}'recieve()' Hack - By Some Examples
Exploiting the 'recieve()' Function
Securing the 'recieve()' Function
Last updated