Skip to content

Instantly share code, notes, and snippets.

View fxfactorial's full-sized avatar
🎯
Focusing

@edgararout fxfactorial

🎯
Focusing
View GitHub Profile
@fxfactorial
fxfactorial / cgo.md
Created August 26, 2021 21:07 — forked from zchee/cgo.md
cgo convert list

See also, http://libraryofalexandria.io/cgo/

Using Go cgo

cgo has a lot of trap.
but Not "C" pkg also directory in $GOROOT/src. IDE's(vim) Goto command not works.

So, Here collect materials.

@fxfactorial
fxfactorial / decode_example.js
Created August 15, 2021 00:29 — forked from miguelmota/decode_example.js
JavaScript decode RLP encoded Ethereum transaction (raw transaction) examples
// RLP encoded transaction
const rawTxHex = '0xed8205fc843b9aca00825208944592d8f8d7b001e72cb26a73e4fa1806a51ac79d88016345785d8a000080808080'
// using rlp package to decode values
const rlp = require('rlp')
const decoded = rlp.decode(rawTxHex)
console.log(decoded)
/*
[ <Buffer 05 fc>,
<Buffer 3b 9a ca 00>,
@fxfactorial
fxfactorial / eth-benchmark.py
Created July 16, 2021 02:30 — forked from easeev/eth-benchmark.py
Ethereum node query performance benchmark
import timeit
import threading
import asyncio
import contextlib
import requests
from aiohttp import ClientSession
from web3.providers.base import JSONBaseProvider
from web3.providers import HTTPProvider
@fxfactorial
fxfactorial / faucet.js
Created July 4, 2021 00:58
suck faucets
const puppeteer = require('puppeteer');
const spawn = require('@expo/spawn-async');
const v4 = require('uuid').v4;
const UserAgent = require('user-agents');
const faucet = 'https://explorer.certik.foundation/faucet';
const address_query = 'input[name=address]';
const button_click = 'form button[type=submit]';
type Point struct {
GasPriceX *big.Int
EthProfitY *big.Int
}
func (b *Bot) MaxProfitPossible(p1, p2 Point) *big.Int {
rise := new(big.Int).Sub(p2.EthProfitY, p1.EthProfitY)
run := new(big.Int).Sub(p2.GasPriceX, p1.GasPriceX)
slope := new(big.Float).Quo(
new(big.Float).SetInt(rise),
@fxfactorial
fxfactorial / GethBEHAVE.md
Created May 6, 2021 16:50 — forked from yorickdowne/GethBEHAVE.md
Pruning Geth 1.10.x

Overview

Geth (Go-Ethereum) as of March 2021 takes about 350 GiB of space on a fast/snap sync, and then grows by ~ 10 GiB/week. This will fill a 1TB SSD in ~6 months, to the point where space usage should be brought down again with an offline prune.

Happily, Geth 1.10.x introduces "snapshot offline prune", which brings it back down to about its original size. It takes roughly 4 hours to prune the Geth DB, and this has to be done while Geth is not running.

Caveat that while several folx have used offline pruning successfully, there is risk associated with it. The two failure modes we have seen already are:

     153: cumulative: 12469376 gas: 21000 contract: 0x0000000000000000000000000000000000000000 status: 1 tx: 0xfbbf56fd9eb3fb2e1d05f0a0f19a0ccfaeb84df1fed01273ec5ee3b0c1acb011 logs: [] bloom: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 state:           
@fxfactorial
fxfactorial / comp_earned.md
Created February 14, 2021 16:20 — forked from ajb413/comp_earned.md
How do I retrieve the "COMP earned" value from the Compound protocol? Get the amount of accrued COMP token for an address using the Ethereum blockchain.

How do I retrieve the "COMP earned" value?

With a Smart Contract or JSON RPC

Get the value of COMP earned for an address that uses the Compound protocol. This can be done using the Lens contract with JSON RPC or another Smart Contract. If you do an eth_call with JSON RPC, it is free (no gas costs).

  1. Use the getCompBalanceMetadataExt method in the Lens contract https://etherscan.io/address/0xd513d22422a3062Bd342Ae374b4b9c20E0a9a074#code
  2. Lens address is posted here https://github.com/compound-finance/compound-protocol/blob/master/networks/mainnet.json#L11
  3. Here is the definition https://github.com/compound-finance/compound-protocol/blob/master/contracts/Lens/CompoundLens.sol#L278
@fxfactorial
fxfactorial / debug-lib.sol
Last active February 9, 2021 15:47
some helpers ot use with require(false, D.str_concat(D.to_ascii_....)
pragma solidity ^0.8.1;
library D {
function str_concat(string memory _a, string memory _b)
internal
pure
returns (string memory _concatenatedString)
{
return str_concat(_a, _b, "", "", "", "", "", "");
}