Skip to content

Instantly share code, notes, and snippets.

View gregorynicholas's full-sized avatar

gregory nicholas gregorynicholas

View GitHub Profile
gregorynicholas /
Created October 17, 2021 20:08 — forked from mjackson/
Notes on handling redirects in React Router v6, including a detailed explanation of how this improves on what we used to do in v4 and v5

Redirects in React Router v6

An important part of "routing" is handling redirects. Redirects usually happen when you want to preserve an old link and send all the traffic bound for that destination to some new URL so you don't end up with broken links.

The way we recommend handling redirects has changed in React Router v6. This document explains why.


In React Router v4/5 (they have the same API, you can read about why we had to bump the major version here) we had a <Redirect> component that you could use to tell the router when to automatically redirect to another URL. You might have used it like this:

gregorynicholas / wallets_fee_neo3.json
Created September 17, 2021 00:07 — forked from pitersky/wallets_fee_neo3.json
"className": "ARKCoin",
"txWebUrl": "",
"feeData": {
"fee": "10000000"
"explorers": [
"className": "ArkExplorer",
gregorynicholas / whitepapers.tsv
Created September 17, 2021 00:03 — forked from blockchainvc/whitepapers.tsv
WHITEPAPERS: Smart Contract Protocols
Name Link Whitepaper title
Achain (previously thinkyoung) Achain Blockchain Whitepaper: build to be boundless
Aergo (by blocko) multiple
Aion Aion: enabling the decentralized Internet
Ark A Platform for Consumer Adoption
Avalanche Snowflake to Avalanche: a novel metastable consensus protocol family for cryptocurrencies
Blink Proof-of-stake distrbuted consensus protocol
Byteball A Decentralized System for Storage and Transfer of Value
Cardano Ouroboros: A provably secure proof-of-stake blockchain protocol
Celer Network Celer Network: Bring Internet Scale to Every Blockchai
gregorynicholas / deploy.js
Created November 8, 2020 18:23 — forked from ajb413/deploy.js
A Node.js script for deploying a smart contract to the locally hosted Ethereum instance.
const fs = require('fs');
const Web3 = require('web3');
const web3 = new Web3('http://localhost:8545');
const bytecode = fs.readFileSync('./build/FirstContract.bin');
const abi = JSON.parse(fs.readFileSync('./build/FirstContract.abi'));
(async function () {
const ganacheAccounts = await web3.eth.getAccounts();
const myWalletAddress = ganacheAccounts[0];
gregorynicholas / getCompApy.js
Created November 8, 2020 18:21
Get COMP APY for USDT. Uses Node.js with Compound.js. Be sure to fill in your Infura project ID at the top. See comments for run instructions.
const Compound = require('@compound-finance/compound-js');
const provider = '<YOUR INFURA API KEY HERE>';
const cTokenToGetCompApy = Compound.cUSDT;
const underlying = cTokenToGetCompApy.slice(1, 10);
const underlyingDecimals = Compound.decimals[underlying];
const cTokenDecimals = 8; // always 8
const comptroller = Compound.util.getAddress(Compound.Comptroller);
const opf = Compound.util.getAddress(Compound.PriceFeed);
gregorynicholas / getCompAccrued.js
Created November 8, 2020 18:19 — forked from ajb413/getCompAccrued.js
Get COMP accrued for an account on mainnet using Compound.js (
const Compound = require('@compound-finance/compound-js');
const provider = '' + process.env.infuraApiKey;
// mainnet
const CompoundLens = Compound.util.getAddress(Compound.CompoundLens);
const LensAbi = Compound.util.getAbi(Compound.CompoundLens);
const COMP = Compound.util.getAddress(Compound.COMP);
const Comptroller = Compound.util.getAddress(Compound.Comptroller);
const me = '0xa0df350d2637096571F7A701CBc1C5fdE30dF76A';
gregorynicholas / minte-usdc.js
Created November 8, 2020 18:16 — forked from ajb413/minte-usdc.js
Local host fork of mainnet, "steal" some test USDC from a whale (cUSDC contract).
// First run Ganache locally with `cUsdc` address unlocked
const Web3 = require('web3');
const web3 = new Web3('');
const usdcAbi = [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"authorizer","type":"address"},{"indexed":true,"internalType":"bytes32","name":"nonce","type":"bytes32"}],"name":"AuthorizationCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"authorizer","type":"address"},{"indexed":true,"internalType":"bytes32","name":"nonce","type":"bytes32"}],"name":"AuthorizationUsed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_account","type":"address"}],"name":"Blacklist
gregorynicholas /
Created November 8, 2020 18:15 — forked from ajb413/
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
  2. Lens address is posted here
  3. Here is the definition
gregorynicholas /
Created November 8, 2020 18:14 — forked from ajb413/
Finding the COMP APY