File tree Expand file tree Collapse file tree 4 files changed +75
-0
lines changed Expand file tree Collapse file tree 4 files changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+ pragma solidity ^ 0.4.9 ;
2
+
3
+ contract Transaction {
4
+ // each contract has an ethereum address - it can be found with: address(this)
5
+
6
+ event SenderLogger (address );
7
+ event ValueLogger (uint );
8
+
9
+ address private owner;
10
+
11
+ modifier isOwner {
12
+ require (owner== msg .sender );
13
+ _;
14
+ }
15
+
16
+ modifier validValue {
17
+ require (msg .value >= 1 );
18
+ _;
19
+ }
20
+
21
+ function Transaction () {
22
+ owner = msg .sender ;
23
+ }
24
+
25
+ //payable is a modifier that can be added to any function
26
+ //payable is a reserved keyword that allows a contract to receive ether
27
+ // a contract can have exactly one unnamed function, it is default executed if contract is called w no parms
28
+ function () payable isOwner validValue {
29
+ SenderLogger (msg .sender );
30
+ ValueLogger (msg .value );
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ pragma solidity ^ 0.4.8 ;
2
+
3
+ library IntExtended {
4
+
5
+ function decrement (uint _self ) returns (uint ) {
6
+ return _self-1 ;
7
+ }
8
+
9
+ function decrementByValue (uint _self , uint _value ) returns (uint ) {
10
+ return _self- _value;
11
+ }
12
+
13
+ function increment (uint _self ) returns (uint ) {
14
+ return _self+1 ;
15
+ }
16
+
17
+ function incrementByValue (uint _self , uint _value ) returns (uint ) {
18
+ return _self+ _value;
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ pragma solidity ^ 0.4.8 ;
2
+
3
+ import "browser/library.sol " ;
4
+
5
+ contract testLibrary {
6
+ using IntExtended for uint ;
7
+
8
+ function testDecrement (uint _base ) returns (uint ) {
9
+ return IntExtended.decrement (_base);
10
+ }
11
+
12
+ function testDecrementByValue (uint _base , uint _value ) returns (uint ) {
13
+ return _base.decrementByValue (_value);
14
+ }
15
+
16
+ function testIncrement (uint _base ) returns (uint ) {
17
+ return IntExtended.increment (_base);
18
+ }
19
+
20
+ function testIncrementByValue (uint _base , uint _value ) returns (uint ) {
21
+ return _base.incrementByValue (_value);
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments