-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimpleStorageTransfer.sol
42 lines (34 loc) · 997 Bytes
/
SimpleStorageTransfer.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
contract SimpleStorageTransfer {
uint public storedData1;
uint public storedData2;
event Change(string message, uint val1,uint val2);
function SimpleStorage(uint initVal1,uint initVal2) {
Change("initialized", initVal1,initVal2);
storedData1= initVal1;
storedData2= initVal2;
}
function set(uint x,uint y) {
Change("set", x,y);
storedData1 = x;
storedData2 = y;
}
function getA() constant returns (uint retVal) {
return storedData1;
}
function getB() constant returns (uint retVal) {
return storedData2;
}
function transfer(uint src, uint dest,uint unit) {
Change("transfer", src,dest);
if( src==1 && storedData1>= unit)
{
storedData1=storedData1-unit;
storedData2=storedData2+unit;
}
else if(storedData2>=unit)
{
storedData2=storedData2-unit;
storedData1=storedData1+unit;
}
}
}