-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample16.sol
More file actions
31 lines (26 loc) · 782 Bytes
/
example16.sol
File metadata and controls
31 lines (26 loc) · 782 Bytes
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
pragma solidity ^0.4.8;
contract HoneyPot {
// maps addresses to a value and store it in a public variable
mapping (address => uint) public balances;
// constructor
function HoneyPot() payable public {
put();
}
// msg is an information when you call function
function put() payable public {
// where the storage of the ether value happens
balances[msg.sender] = msg.value; // msg.sender here is the address from the sender
}
function get() public {
// let addresses to withdraw the value of ether
if (!msg.sender.call.value(balances[msg.sender])()) {
revert();
}
// empty the balance off sender
balances[msg.sender] = 0;
}
// fallback function
function() public {
revert();
}
}