Skip to content

Instantly share code, notes, and snippets.

View zastrin's full-sized avatar

Zastrin zastrin

View GitHub Profile
@zastrin
zastrin / Voting.sol
Last active March 10, 2018 03:41
Voting
pragma solidity ^0.4.17;
contract Voting {
// 1. Initialize a few candidates
// 2. Vote for a candidate
// 3. Lookup vote count for each candidate
bytes32[] public candidateNames;
mapping (bytes32 => uint8) public votesReceived;
address public owner;
@zastrin
zastrin / instructions
Last active March 9, 2018 03:34
Instructions
mkdir voting_dapp
cd voting_dapp
truffle unbox webpack
npm install
rm contracts/MetaCoin.sol
rm contracts/ConvertLib.sol
create contracts/Voting.sol and copy your contract code
@zastrin
zastrin / commands
Last active March 10, 2018 03:43
March 9th - Notes
In truffle console:
# To list all the available accounts
web3.eth.accounts
# To check the balance of account (in Wei)
web3.eth.getBalance('<account address>')
# To get balance in Ether
web3.fromWei(web3.eth.getBalance('<account address>'), 'ether')
@zastrin
zastrin / app.js
Created March 13, 2018 00:58
Frontend
// Import the page's CSS. Webpack will know what to do with it.
import "../stylesheets/app.css";
// Import libraries we need.
import { default as Web3} from 'web3';
import { default as contract } from 'truffle-contract'
import voting_artifacts from '../../build/contracts/Voting.json'
var Voting = contract(voting_artifacts);
@zastrin
zastrin / project.txt
Last active April 25, 2018 19:31
Boston Blockchain training project phases
Project Phases
Phase 1
Implement the ERC20 smart contract in Remix browser IDE https://remix.ethereum.org
Test the contract functions
Phase 2
- Clone the starter project
git clone https://github.com/zastrin/boston_token
npm install
@zastrin
zastrin / ERC20Token.sol
Last active October 4, 2018 21:47
Super basic token
pragma solidity ^0.4.24;
contract ERC20Token {
uint public supply = 1000000;
uint public price = 0.001 ether;
string public name = "Hackathon Token";
string public symbol = "HKT";
uint public decimals = 18;