Skip to content

Instantly share code, notes, and snippets.

View daragao's full-sized avatar

Duarte Aragão daragao

View GitHub Profile
@daragao
daragao / flow_test.go
Last active October 11, 2018 22:38
Simple flow test without using the abigen generated file (only using common transactions and the simulated blockchain)
package ionflow
import (
"bytes"
"context"
"math/big"
"regexp"
"strings"
"testing"
@daragao
daragao / nested_nodes_trie_example.go
Last active April 20, 2020 16:12
Example of a Patricia Trie with some value smaller than 32bytes wich results in nodes being nested inside each other
package main
import (
"fmt"
"log"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb/memorydb"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
@daragao
daragao / txRootExample.go
Last active July 3, 2018 15:55
Example of how a transaction root is created using the Ethereum Golang libraries
package main
import (
"context"
"fmt"
"log"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethdb"
#!/bin/bash
UP_SYMBOL=▲
DOWN_SYMBOL=▼
# BTC_SYMBOL="<fc=#FFFF00>฿</fc>"
BTC_SYMBOL="<fc=#FF9900><fn=1></fn></fc>"
#ETH_SYMBOL="<fc=#7777FF>Ξ</fc>"
ETH_SYMBOL="<fc=#7777FF><fn=1></fn></fc>"
@daragao
daragao / test.js
Last active October 11, 2018 22:39
Chat that we had today :)
const printMatrix = (matrix) => matrix.forEach((line,j) => console.log('('+j+')',line));
// USES ALGORITHM THAT I DESCRIBED WHICH WAS WRONG!!!!
const countIslandsMyAlgorithm = (matrix) => {
const checkCounterMatrix = (counterMatrix,i,j) => {
if((i-1 >= 0) && (counterMatrix[i-1][j] !== 0)) return counterMatrix[i-1][j];
if((j-1 >= 0) && (counterMatrix[i][j-1] !== 0)) return counterMatrix[i][j-1];
// this 2 cases are never considered in any of the matrices, this causes issues
if((i+1 < matrix.length) && (matrix[i+1][j] !== 0)) return counterMatrix[i+1][j] = 0;
@daragao
daragao / readDatadirLeveDB.js
Last active June 7, 2017 22:30
playing around to check how to read a levelDB
const level = require('level');
const levelup = require('levelup');
const RLP = require('rlp');
const Trie = require('merkle-patricia-tree')
const DATADIR_PATH = '../../simple_geth_launcher/data_node1';
/*
const nodeDb = level('/home/da/.ethereum/geth/nodes');
const nodeDataArr = [];
@daragao
daragao / luckyGuessGenKey.sh
Created June 7, 2017 09:53
(Useless crazy :D ) Bash script that keeps generating keys and saves the key if that Ethereum account has ether
#!/bin/bash
COUNTER=0
trap '{ echo "Hey, you pressed Ctrl-C. Loop Counter: $COUNTER Time to quit." ; exit 1; }' INT
#./go-ethereum/build/bin/geth --bootnodes enode://f4642fa65af50cfdea8fa7414a5def7bb7991478b768e296f5e4a54e8b995de102e0ceae2e826f293c481b5325f89be6d207b003382e18a8ecba66fbaf6416c0@33.4.2.1:30303 --rpc
#Libs used for keccak-256sum
#https://github.com/maandree/libkeccak.git
//self running function to encapsulate all the variables
var Test = function() {
var testBIN = '6060604052341561000c57fe5b5b60326000819055505b5b60e7806100256000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063b69ef8a8146044578063b6b55f25146067575bfe5b3415604b57fe5b60516098565b6040518082815260200191505060405180910390f35b3415606e57fe5b60826004808035906020019091905050609e565b6040518082815260200191505060405180910390f35b60005481565b60008160006000828254019250508190555060005490505b9190505600a165627a7a723058206751dd5bc72fc42f08633904726ab78c48328a747e7fa4147ad042d513e1a9480029';
var testABI = [
{
"constant": true,
0x6167a665587a1c19d23f6452fdcc1b6fd60a0264
### Keybase proof
I hereby claim:
* I am daragao on github.
* I am doart3 (https://keybase.io/doart3) on keybase.
* I have a public key ASCPzNJiX4eeyjQbTN39wEvDLLO2eZMejZGzRJkZl6c2mwo
To claim this, I am signing this object: