Skip to content

Instantly share code, notes, and snippets.

@AlwaysBCoding
AlwaysBCoding / decypher.js
Last active March 7, 2018 21:47
Ethereum Ðapp Development - Video 11 | Contract Inheritance
// Config
global.config = {
rpc: {
host: "localhost",
port: "8545"
}
}
// Load Libraries
global.solc = require("solc")
@AlwaysBCoding
AlwaysBCoding / CoinFlipOracle.sol
Created February 19, 2017 03:47
Ethereum Ðapp Development - Video 12 | Oracles and Oraclize
pragma solidity ^0.4.0;//please import oraclizeAPI_pre0.4.sol when solidity < 0.4.0
contract OraclizeI {
address public cbAddress;
function query(uint _timestamp, string _datasource, string _arg) payable returns (bytes32 _id);
function query_withGasLimit(uint _timestamp, string _datasource, string _arg, uint _gaslimit) payable returns (bytes32 _id);
function query2(uint _timestamp, string _datasource, string _arg1, string _arg2) payable returns (bytes32 _id);
function query2_withGasLimit(uint _timestamp, string _datasource, string _arg1, string _arg2, uint _gaslimit) payable returns (bytes32 _id);
function getPrice(string _datasource) returns (uint _dsprice);
function getPrice(string _datasource, uint gaslimit) returns (uint _dsprice);
@AlwaysBCoding
AlwaysBCoding / decypher.js
Created February 19, 2017 21:46
Ethereum Ðapp Development - Video 13 | Ethereum Name Service (ENS)
// Config
global.config = {
rpc: {
host: "localhost",
port: "8545"
}
}
// Load Libraries
global.solc = require("solc")
@AlwaysBCoding
AlwaysBCoding / crowdfund.sol
Created February 25, 2017 03:51
Ethereum Ðapp Development - Video 15 | The Block Gas Limit
contract CrowdFund {
address public beneficiary;
uint256 public goal;
uint256 public deadline;
struct Funder {
address addr;
uint256 contribution;
}
@AlwaysBCoding
AlwaysBCoding / crowdfund.sol
Created February 25, 2017 22:34
Ethereum Ðapp Development - Video 16 | Avoiding Loops with Mappings
contract CrowdFund {
address public beneficiary;
uint256 public goal;
uint256 public deadline;
mapping (address => uint256) funders;
address[] funderAddresses;
function CrowdFund(address _beneficiary, uint256 _goal, uint256 _duration) {
beneficiary = _beneficiary;
@AlwaysBCoding
AlwaysBCoding / crowdfund.sol
Last active February 26, 2017 19:09
Ethereum Ðapp Development - Video 17 | Contract Events
contract CrowdFund {
address public beneficiary;
uint256 public goal;
uint256 public deadline;
mapping (address => uint256) funders;
address[] funderAddresses;
event NewContribution(address indexed _from, uint256 _value);
@AlwaysBCoding
AlwaysBCoding / script.js
Created March 3, 2017 03:28
Ethereum Ðapp Development - Video 18 | Signing Arbitrary Messages
// Private Key
var pKey = "..."
var pKeyx = new Buffer(pKey, "hex")
// Shared Message
var message = "..."
var messageHash = web3.sha3(message)
var messageHashx = new Buffer(messageHash.replace("0x", ""), "hex")
// Signed Hash
@AlwaysBCoding
AlwaysBCoding / index.html
Created March 13, 2017 19:35
Ethereum Ðapp Development - Video 19 | Implementing an Authentication Scheme
<h1>Example Text</h1>
<script>
var message = "DecypherTV";
var userEthereumClient;
window.addEventListener("load", function() {
userEthereumClient = window.web3;
})
@AlwaysBCoding
AlwaysBCoding / decyphercoin.sol
Created March 28, 2017 23:55
Ethereum Ðapp Development - Video 20 | The ERC20 Token Standard
contract DecypherCoin {
// ERC20 State
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowances;
uint256 public totalSupply;
// Human State
string public name;
uint8 public decimals;
@AlwaysBCoding
AlwaysBCoding / install.txt
Created April 12, 2017 13:02
Ethereum Ðapp Development - Video 21 | Installing Geth
// Running on Ubuntu 16.04 (64-bit)
// Do this first
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
// Install Geth
sudo apt-get install ethereum
// Install Solc