Skip to content

Instantly share code, notes, and snippets.

@tim-br
tim-br / gist:80e243efaa034599c2fd9d79bde47367
Last active August 2, 2018 19:31
Generating a raw transaction using ethers.js
var ethers = require('ethers');
var Wallet = ethers.Wallet;
var utils = ethers.utils;
var privateKey = '<privatekey>'
var wallet = new ethers.Wallet(privateKey);
var transaction = {
// needs to be greater than the nonce of the previous tx
// from this wallet
// can skip values
// requires ethereumjs-util and ethers, 3rd party npm packages.
/*
Ran on macbook with these results:
10000 ran with 0 errors.
real 0m28.769s
user 0m28.301s
sys 0m0.246s
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' localhost:8545
contract TestEvent{
string greeting;
event TeEv(string input);
function TestEvent(string _greeting){
greeting = _greeting;
}
function get_greeting() constant returns(string){
TeEv("in get_greeting function");
(use 'clojure.core.async)
(def input-chan (chan))
(def our-pub (pub input-chan :msg-type))
(>!! input-chan {:msg-type :greeting :text "hello"})
(def output-chan (chan))
@tim-br
tim-br / Class 17 result CSS desde 0.markdown
Created November 22, 2015 06:27
Class 17 result CSS desde 0
@tim-br
tim-br / shadows.rkt
Created September 28, 2015 03:22
scheme stuff
#lang racket
(define (atom? item)
(not (pair? item)))
(define (numbered? aexp)
(cond [(atom? aexp) (number? aexp)]
[else
(and (numbered? (car aexp))
(numbered? (car (cdr (cdr aexp)))))]))
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Simple markers</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0;
data MyVector a = XY a a deriving (Show)
xcord :: (Num a) => MyVector a -> a
xcord (XY a _) = a
ycord :: (Num a) => MyVector a -> a
ycord (XY _ a) = a
subVect :: (Num a) => MyVector a -> MyVector a -> MyVector a
subVect (XY x1 y1) (XY x2 y2) = XY (x1 - x2) (y1 - y2)
function arrayOfLight(x){
res = []
for(i = 0; i <= x; i++){
res.push(i);
}
return res;
}