-
Notifications
You must be signed in to change notification settings - Fork 1
/
06_Solidify.sol
46 lines (37 loc) · 1.03 KB
/
06_Solidify.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
/**
*
* SolidifyKnowledge
*
* En este ejercicio veremos el uso de la palabra require y los eventos
*
* Más información sobre control de errores en:
*
* http://solidity.readthedocs.io/en/develop/control-structures.html#error-handling-assert-require-revert-and-exceptions
*
*
**/
pragma solidity ^0.4.0;
contract SolidifyKnowledge {
string word;
uint number;
address owner;
function SolidifyKnowledge(string _word) {
word =_word;
number = 42;
owner = msg.sender;
}
// Eventos. Sirven para escribir en el log de la transacción
event Changed (string _msg, address a);
modifier onlyOwner {
// Permite definir condiciones (como un if)
require(msg.sender == owner);
_;
}
function getWord() constant returns (string) {
return word;
}
function setWord(string w) onlyOwner {
word = w;
Changed('Variable word changed!', msg.sender);
}
}