Skip to content

Instantly share code, notes, and snippets.

@kyriediculous
kyriediculous / ERC20.sol
Last active December 24, 2017 22:31 — forked from anonymous/ERC20.sol
ERC223 with ERC20 backwards compatibility
pragma solidity ^0.4.10;
import 'browser/SafeMath.sol';
contract ERC20 {
uint256 public totalSupply;
function name() constant returns (string _name);
function symbol() constant returns (string _symbol);
function decimals() constant returns (uint8 _decimals);
function totalSupply() constant returns (uint256 _totalSupply);
pragma solidity ^0.4.10;
interface ERC20 {
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
function allowance(address owner, address spender) public view returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
pragma solidity ^0.4.10;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
pragma solidity ^0.4.10;
import 'browser/SafeMath.sol';
import 'browser/ERC20.sol';
contract StandardToken is ERC20 {
using SafeMath for uint;
string internal _name;
string internal _symbol;
pragma solidity ^0.4.10;
contract ERC223ReceivingContract {
function tokenFallback(address _from, uint _value, bytes _data) public;
}
pragma solidity ^0.4.10;
interface ERC223 {
function transfer(address to, uint value, bytes data) public;
event Transfer(address indexed from, address indexed to, uint value, bytes indexed data);
}
@kyriediculous
kyriediculous / Crowdsale.sol
Last active January 22, 2018 22:05 — forked from anonymous/Crowdsale.sol
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.19+commit.c4cbbb05.js&optimize=false&gist=
pragma solidity ^0.4.10;
import 'gist/ERC223ReceivingContract.sol';
import 'gist/SafeMath.sol';
import 'gist/StandardToken.sol';
import 'gist/Ownable.sol';
contract Crowdsale is Ownable {
using SafeMath for uint;
import Web3 from 'web3'
/*
* 1. Check for injected web3 (mist/metamask)
* 2. If metamask/mist create a new web3 instance and pass on result
* 3. Get networkId - Now we can check the user is connected to the right network to use our dApp
* 4. Get user account from metamask
* 5. Get user balance
*/
import Web3 from 'web3'
import {store} from '../store/'
let pollWeb3 = function (state) {
let web3 = window.web3
web3 = new Web3(web3.currentProvider)
setInterval(() => {
if (web3 && store.state.web3.web3Instance) {
if (web3.eth.coinbase !== store.state.web3.coinbase) {
methods: {
clickNumber (event) {
console.log(event.target.innerHTML, this.amount)
this.winEvent = null
this.pending = true
this.$store.state.contractInstance().bet(event.target.innerHTML, {
gas: 300000,
value: this.$store.state.web3.web3Instance().toWei(this.amount, 'ether'),
from: this.$store.state.web3.coinbase
}, (err, result) => {