Skip to content

Instantly share code, notes, and snippets.

View bitgord's full-sized avatar

Michael Gord bitgord

View GitHub Profile
@bitgord
bitgord / Eth-Transactions
Last active December 3, 2016 19:14
Eth Transactions
// package.json
{
"dependencies": {
"web3": "0.17.0-alpha",
"ethereumjs-util": "4.5.0",
"ethereumjs-tx": "1.1.2"
}
}
//Goto Node Console
@bitgord
bitgord / Sign-Eth-Transactions
Created December 3, 2016 19:40
Sign-Eth-Transactions
//Set Variable for PrivateKey in TestRPC
var pKey1 = ""
//Require EthTx
var EthTx = require("ethereumjs-tx")
//Create Buffer Encoded Class
var pKey1x = new Buffer(pKey1, 'hex')
//Create Raw Transaction Data Structure
@bitgord
bitgord / Eth-Mainnet-Transactions+Intro-to-Infura
Created December 5, 2016 01:53
Ethereal Mainnet Transactions
//First you need to get an API endpoint to the Ethereum mainnet from infura.io
var endpoint = "https://mainnet.infura.io/[[insert-passcode]]"
//Require and setup new Web3
var Web3 = require("web3")
var EthTx = require("ethereumjs-tx")
//Create two accounts from TestRPC
var acct1 = ""
var acct2 = ""
@bitgord
bitgord / Intro-to-BlockCypher-Transactions
Created December 5, 2016 02:40
Introduction to Etheream transactions using Blockcypher's API
//Get token from BlockCypher when you create an account at blockcypher.com
//Create rawTx object
{ nonce: '0x13',
to: '',
gasPrice: '',
gasLimit: '',
value: '',
data: '' }
@bitgord
bitgord / Intro-to-Smart-Contracts
Last active March 21, 2017 16:01
Introduction to Smart Contracts
//Smart Contracts are a series of Ethereum Virtual Machine OP Codes
//Solidity it higher level and is compiled to EVM bytecode
// package.json
{
"dependencies": {
"web3": "0.17.0-alpha",
"solc": "^0.4.4"
}
}
@bitgord
bitgord / Escrow-Smart-Contract
Created December 5, 2016 04:13
Example of an escrow smart contract
// package.json
{
"dependencies": {
"web3": "0.17.0-alpha",
"solc": "^0.4.4"
}
}
//Create file Ecrow.sol and create 3 variables: a buyer, a seller, and an arbiter
contract Escrow {
@bitgord
bitgord / Bitcoin-payments-nodejs-bitpay
Created December 5, 2016 23:10
Bitcoin payments with nodejs and Bitpay
//First sign up for an account with BiyPay and create a new API key
//Download bitpay-node
sudo npm install bitpay-node
//Go to node console and require bitpay-node
Bitpay = require('bitpay-node')
//Create new Bitpay client
var client = new Bitpay.Client({ apiKey: '' })
@bitgord
bitgord / Quick-Geth+Solidity-Console-Setup
Last active December 8, 2016 19:48
Quick setup with Geth and Sol Console
// Run Command from Terminal
geth --rpc --rpcapi="db,eth,net,web3,personal" --rpcport "8545" --rpcaddr "127.0.0.1" --rpccorsdomain "localhost" console
// Check Sol is Configured
eth.getCompilers()
// In a New Terminal Window Run TestRPC
cd ~PATH-TO-FILE
testrpc
@bitgord
bitgord / Quick-Setup-SQLite
Last active December 9, 2016 01:00
Quick Setup of SQLite
// First you need to install the dependencies - insert this to your package.json and run npm install
"sequelize": "^3.5.1",
"sqlite3": "^3.1.4"
// Require Sequelize
// (new Sequelize dependencies can be (undefined, undefined, undefined) for quick setup
// set dialect to a 'sqlite' db
// set storage to the file you want the db to be with a .sqlite at the end
var Sequelize = require('Sequelize');
@bitgord
bitgord / Intro-Bitfinex-API-Websockets
Created December 10, 2016 21:11
Get Bitfinex API data with Websockets
// First go to http://docs.bitfinex.com and click on the websockets tab
// Scroll down and find the SSL websocket connection URL
For example: wss://api.bitfinex.com/ws
// In a new Javascript file create a variable for new websocket
var ws = new WebSocket('wss://api.bitfinex.com/ws');
// Create function to send on open
ws.onopen = function() {
ws.send(JSON.stringify({"event":"subscribe", "channel":"ticker", "pair":"BTCUSD"}));