Created
April 14, 2019 23:19
-
-
Save viannaandreBR/58f41f030974d890a85d5efa75f2b1a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.4.0; | |
| contract GuardaLoteria { | |
| address dono; | |
| struct Sorteio { | |
| uint data; | |
| uint numeroSorteado; | |
| address remetente; | |
| } | |
| Sorteio[] sorteios; | |
| constructor(uint numeroInicial) public { | |
| dono = msg.sender; | |
| set(numeroInicial); | |
| } | |
| function set(uint enviado) public { | |
| sorteios.push(Sorteio({ | |
| data: now, | |
| numeroSorteado: enviado, | |
| remetente: msg.sender | |
| })); | |
| } | |
| function get() public view returns ( | |
| address _donoDoContrato, | |
| uint _ultimoSorteado, | |
| uint _ultimaData, | |
| address _ultimoRemetente, | |
| uint _numeroDeSorteios | |
| ) { | |
| Sorteio memory ultimo = sorteios[sorteios.length-1]; | |
| return ( | |
| dono, | |
| ultimo.numeroSorteado, | |
| ultimo.data, | |
| ultimo.remetente, | |
| sorteios.length | |
| ); | |
| } | |
| function kill () public { | |
| require (msg.sender == dono); | |
| selfdestruct(dono); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment