Skip to content

Instantly share code, notes, and snippets.

@ajb413
ajb413 / Get_COMP_APY.md
Last active August 8, 2023 11:03
Finding the COMP APY

From Blockchain With JSON RPC and JavaScript

const Compound = require('@compound-finance/compound-js');

const provider = 'https://mainnet.infura.io/v3/' + process.env.infuraApiKey;

const cTokenToGetCompApy = Compound.cUSDC; // Pick an asset

const underlying = cTokenToGetCompApy.slice(1, 10);
const underlyingDecimals = Compound.decimals[underlying];
@szerintedmi
szerintedmi / sendTx.js
Last active May 3, 2019 14:05
barebone demonstration of web3 tx not resolving issue
const Web3 = require("web3");
const OPTIONS = {
defaultBlock: "latest",
transactionConfirmationBlocks: 1,
transactionBlockTimeout: 5
};
const web3 = new Web3(
new Web3.providers.WebsocketProvider("ws://localhost:8545"),
admin.addPeer("enode://da0c61fe14ba9da1a9835b59d811553d21787448724cfe6412bc17f0b14586df91826d8286b2137342d09a8631df5ea548cf301294b05657c2a90f9c3d526721@143.198.119.44:30303");
admin.addPeer("enode://3e2287c6caf363357efc600611ccb777e6997ef8b749b1f87e94d3a7d2b466bbefba163b0620c88804f18bc70cfbe68538720ac2644fc1c970848488cdca0c7a@143.198.114.251:30303");
admin.addPeer("enode://15ea76b5d30ce9eaabf6a9a8fe5ca0ff032534d296b5b8ca6e00a730d08a4aaa019077c382a6b2d08ebc7cf6f8eb888f5e00e0dd378798e3459a555538654370@157.230.6.79:30303");
admin.addPeer("enode://2e718763172902a8fa4bcdda45f77a5c2688de5230e184d154e4867922b8f6ad23e1016379715cb5f55f6c79060563f93896035e35dfb47361d08599d4908ae8@143.198.118.178:30303");
admin.addPeer("enode://9d45f21eeb37bd5555fac0c4094ae3d4d144d93e2313aeb891bf3054b0dcf6ca817961ed29ea1de00389b5c36dc6bbe9b00443e367b16ed8ba251cea6c242044@94.176.237.140:30303");
admin.addPeer("enode://2493b5b8407ccb1c448d7ad358e838066640f273442730caf80acde2fe98522b1d9dcebd2dc982efe44911a49779888fe72defc181c29596facff05e1
@raineorshine
raineorshine / sendRawTransaction.js
Last active December 3, 2022 18:02
Sends a raw transaction with web3 v1.2.2, ethereumjs-tx v2.1.1, and Infura
const Web3 = require('web3')
const Tx = require('ethereumjs-tx').Transaction
// connect to Infura node
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/INFURA_KEY'))
// the address that will send the test transaction
const addressFrom = '0x1889EF49cDBaad420EB4D6f04066CA4093088Bbd'
const privateKey = new Buffer('PRIVATE_KEY', 'hex')
0x00 0 STOP
0x01 3 ADD
0x02 5 MUL
0x03 3 SUB
0x04 5 DIV
0x05 5 SDIV
0x06 5 MOD
0x07 5 SMOD
0x08 8 ADDMOD
0x09 8 MULMOD
@learner-long-life
learner-long-life / Rinkeby.md
Last active August 30, 2022 22:32
How to get on Rinkeby Testnet in less than 10 minutes

How to get on Rinkeby Testnet in less than 10 minutes

Following instructions from the excellent https://www.rinkeby.io/

Synchronizing a Full Node

A full node lets you access all state. There is a light node (state-on-demand) and wallet-only (no state) instructions as well,

@sheharyarn
sheharyarn / request.js
Last active August 24, 2023 14:55
Axios Request Wrapper for React (https://to.shyr.io/axios-requests)
/**
* Axios Request Wrapper
* ---------------------
*
* @author Sheharyar Naseer (@sheharyarn)
* @license MIT
*
*/
import axios from 'axios'
@ivan-loh
ivan-loh / gist:ee0d96c3795e59244063
Last active March 3, 2021 13:26
Node.JS ( & pm2 ) Process Memory Limit
# Plain Ol' Node
node --max-old-space-size=1024 app.js # increase to 1gb
node --max-old-space-size=2048 app.js # increase to 2gb
node --max-old-space-size=3072 app.js # increase to 3gb
node --max-old-space-size=4096 app.js # increase to 4gb
node --max-old-space-size=5120 app.js # increase to 5gb
node --max-old-space-size=6144 app.js # increase to 6gb
# For pm2
pm2 start app.js --node-args="--max-old-space-size=1024" # increase to 1gb
@achiko
achiko / 2of3.md
Last active August 29, 2015 14:22 — forked from anonymous/2of3.md

2-of-3 Escrow Example with Electrum

This is gmaxwell's 2-of-2 escrow example, adapted to Electrum and to a lesser extent, GFM.

The Scenario

Archey wants to pay Bertha 0.001 BTC for a Twitter Platinum invite, but prevent Bertha from cheating him. Archey selects Iceland to act as