forked from Communication-Systems-Group/solidity-examples
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathexample7.sol
More file actions
29 lines (23 loc) · 644 Bytes
/
example7.sol
File metadata and controls
29 lines (23 loc) · 644 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
pragma solidity >0.4.10;
//the very seventh example
contract Example7 {
address owner;
mapping (address => uint) accounts;
constructor() public {
owner = msg.sender;
}
function mint(address recipient, uint value) public {
if(msg.sender == owner) {
accounts[recipient] += value;
}
}
function transfer(address to, uint value) public{
if(accounts[msg.sender] >= value) {
accounts[msg.sender] -= value;
accounts[to] += value;
}
}
function balance(address addr) public view returns (uint) {
return accounts[addr];
}
}