Skip to content

Instantly share code, notes, and snippets.

@promentol
promentol / advancedlottery.sol
Created February 10, 2018 22:09
An Advance Lottery with advance number generator
//THIS CONTRACT IS CONSUMING A LOT OF GAS
//THIS CONTRACT IS ONLY FOR DEMONSTRATING HOW RANDOM NUMBER CAN BE GENERATED
//DO NOT USE THIS FOR PRODUCTION
pragma solidity ^0.4.8;
contract Lottery {
mapping (uint8 => address[]) playersByNumber ;
@promentol
promentol / lottery.sol
Last active April 12, 2019 12:20
SimpleLottery
//THIS SMART CONTRACT IS CONSUMING A LOT OF GAS
//THIS IS DEMONSTRATION OF RANDOM NUMBER GENERATOR
//DO NOT USE IT FOR PRODUCTION
pragma solidity ^0.4.8;
contract Lottery {
mapping (uint8 => address[]) playersByNumber ;
@promentol
promentol / messageboard.sol
Created February 10, 2018 13:47
MessageBoard Solidity contract
pragma solidity ^0.4.18;
//Contract is just like classes
contract MessageBoard {
//Defining User structure. address is a variable type from solidity
struct User {
address _address;
string name;
bool isValue;
}
@promentol
promentol / index.html
Last active February 10, 2018 13:47
Simple Dapp interacting with web3.js
<!DOCTYPE html>
<html>
<head>
<title>Hello World DApp</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' rel='stylesheet' type='text/css'>
</head>
<body class="container">
<h1>A Simple Message Board</h1>
<div id="login-area">
@promentol
promentol / dependencyInjection.js
Created February 5, 2018 08:06
Code Refactoring for making more testable
var Meal = mongoose.model()
class MealService{
changeCalories(id, calories){
Meal.update(id, {
$set: {calories}
})
}
}