-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsample-contracts.sol
47 lines (37 loc) · 944 Bytes
/
sample-contracts.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
37
38
39
40
41
42
43
44
45
46
47
pragma solidity ^0.4.0;
contract StateHolder {
address public owner;
uint public openNumber;
string public openString;
string public myString;
modifier onlyOwner {
if (msg.sender != owner)
throw;
_;
}
function StateHolder() {
owner = msg.sender;
}
function changeOpenNumber(uint _newNumber) {
openNumber = _newNumber;
}
function changeOpenString(string _newString) {
openString = _newString;
}
function changeMyString(string _newString) onlyOwner {
myString = _newString;
}
}
contract Token {
mapping (address => uint) public balances;
function Token() {
balances[msg.sender] = 1000000;
}
function transfer(address _to, uint _amount) {
if (balances[msg.sender] < _amount) {
throw;
}
balances[msg.sender] -= _amount;
balances[_to] += _amount;
}
}