Created
July 2, 2018 23:09
-
-
Save andersoncarubelli/45f86cb321d497e4ec87cf0ebf79d44f to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
This file contains 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.24; | |
contract CertificadoConclusaoDeCurso { | |
address public aluno; | |
string public emailAluno; | |
address public professor; | |
address public instituicao; | |
string public nomeCurso; | |
bool public certificadoValido = false; | |
constructor(address _aluno, string _emailAluno, address _professor, string _nomeCurso, address _instituicao, bool _certificadoValido) public { | |
aluno = _aluno; | |
emailAluno = _emailAluno; | |
professor = _professor; | |
instituicao = _instituicao; | |
nomeCurso = _nomeCurso; | |
certificadoValido = _certificadoValido; | |
} | |
function defineProfessorAutorizado(address professorAutorizado) public { | |
require(msg.sender == instituicao, 'Somente a instituicao pode definir o professor que validar o certificado'); | |
professor = professorAutorizado; | |
} | |
function validarCertificado() public { | |
require(msg.sender == professor, 'Somente o professor pode validar o certificado'); | |
// check if the address is not set); | |
// obrigado stackoverflow ;) | |
require(professor != address(0), 'É necessario definir um professor para validar o certificado'); | |
certificadoValido = true; | |
} | |
function invalidarCertificado() public { | |
require(msg.sender == professor, 'Somente o professor pode validar o certificado'); | |
// check if the address is not set); | |
// obrigado stackoverflow ;) | |
require(professor != address(0), 'É necessario definir um professor para invalidar o certificado'); | |
certificadoValido = false; | |
} | |
function alterarEmailAluno(string novoEmail) public { | |
require(msg.sender == aluno, 'Somente o aluno pode alterar o email'); | |
emailAluno = novoEmail; | |
} | |
function alterarNomeCurso(string novoNomeCurso) public { | |
require(msg.sender == instituicao, 'Somente a instituicao pode alterar os dados do curso'); | |
nomeCurso = novoNomeCurso; | |
} | |
} |
This file contains 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.24; | |
contract ContratoQualquer { | |
string public valor; | |
function alterarValor(string novoValor) public { | |
valor = novoValor; | |
} | |
} |
This file contains 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.18; | |
contract EscrituraImovel { | |
string public matriculaImovel; | |
address public proprietario; | |
mapping ( address => bool ) public testemunhas; | |
constructor(string _matriculaImovel) public { | |
matriculaImovel = _matriculaImovel; | |
proprietario = msg.sender; | |
} | |
function transferir(address novoProprietario) public { | |
require(msg.sender == proprietario, 'Somente o proprietario pode transferir o imovel'); | |
proprietario = novoProprietario; | |
} | |
function assinar() public { | |
testemunhas[msg.sender] = true; | |
} | |
} |
This file contains 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.24; | |
contract FigurinhaDaCopa { | |
string public nomeJogador = "Ronaldo gorducho"; | |
uint public numeroCamisa = 10; | |
string public selecao = "Brasil"; | |
address public dono; | |
constructor(string _nomeJogador, uint _numeroCamisa, string _selecao) public { | |
nomeJogador = _nomeJogador; | |
numeroCamisa = _numeroCamisa; | |
selecao = _selecao; | |
dono = msg.sender; | |
} | |
modifier somenteDono() { | |
require(msg.sender == dono, 'Somente o dono da figurinha pode alterar o novo dono'); | |
_; | |
} | |
function alterarDono(address novoDono) public somenteDono returns(address) { | |
dono = novoDono; | |
return dono; | |
} | |
} |
This file contains 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.24; | |
import './WonderlandCoin.sol'; | |
contract WonderlandICO { | |
WonderlandCoin public token; | |
string moeda = "Wonderland Coin"; | |
address beneficiario; | |
uint public preco = 2; | |
uint public qtdTokens = 1000000000000; | |
constructor() public { | |
beneficiario = msg.sender; | |
token = new WonderlandCoin(qtdTokens); | |
token.transferir(msg.sender, 300000000000); | |
} | |
function comprar() payable public { | |
require(msg.value > 0, 'para comprar um token ´é preciso enviar ether'); | |
uint qtdTotalToken = msg.value * preco; | |
token.transferir(msg.sender, qtdTotalToken); | |
beneficiario.transfer(msg.value); | |
} | |
} |
This file contains 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.24; | |
contract WonderlandCoin { | |
string nome = 'Wonderland Coin'; | |
string sigla = 'WLC'; | |
mapping (address => uint) public saldos; | |
constructor(uint valor) public{ | |
saldos[msg.sender] += valor; | |
} | |
modifier verificaSaldo(uint valor) { | |
require(saldos[msg.sender] >= valor, 'o saldo do sender deve ser maior ou igual ao valor transferido'); | |
_; | |
} | |
function transferir(address recebedor, uint valor) public verificaSaldo(valor) { | |
saldos[msg.sender] -= valor; | |
saldos[recebedor] += valor; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment