-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsuccess_contract.sol
36 lines (29 loc) · 1.01 KB
/
success_contract.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
pragma solidity 0.4.25;
contract SuccessContract {
mapping(address => uint256) public balanceOf;
constructor() public {
balanceOf[msg.sender] = 10 ether;
}
function transferFrom(address from, address to, uint256 amount) public {
require(balanceOf[from] >= amount);
balanceOf[from] -= amount;
balanceOf[to] += amount;
}
function transfer(address to, uint256 amount) public {
require(balanceOf[msg.sender] >= amount);
balanceOf[msg.sender] -= amount;
balanceOf[to] += amount;
}
function sendEther(address _to) public payable {
(bool success, ) = _to.call.value(msg.value)("");
require(success, "Ether transfer failed");
}
function withdrawEther(address _from) public {
bytes4 data = bytes4(keccak256("withdraw()"));
(bool success, ) = _from.call(data);
require(success, "Ether transfer failed");
}
// it should accept any call without reverting
function() external payable {
}
}