Skip to content

Instantly share code, notes, and snippets.



View GitHub Profile

Sending Ether Cheat Sheet


🥇 Instead of sending Ether, use the withdrawal pattern

🥈 If you really need to send Ether, use a safe wrapper like OpenZeppelin's Address.sendValue(addr, amount)

🥉 If you really need to send Ether without dependencies, use (bool success, ) ={value: amount}("")

Strernd / parseErc20Transfer.js
Created Jun 7, 2021
Parses an ERC20 Transfer from the Ethereum API.
View parseErc20Transfer.js
const converter = require("hex2dec");
const Eth = require("ethjs");
const eth = new Eth(new Eth.HttpProvider(process.env.INFURA));
async function getERC20TransferByHash(hash) {
const ethTxData = await eth.getTransactionByHash(hash);
if (ethTxData === null) throw "TX NOT FOUND";
if (
ethTxData.input.length !== 138 ||
ethTxData.input.slice(2, 10) !== "a9059cbb"
itzmeanjan /
Last active May 28, 2021
Polygon ( aka Matic Network ) Mempool Exploration
from python_graphql_client import GraphqlClient
from json import dumps
from asyncio import run
from re import compile as re_compile
from pytimeparse import parse
reg = re_compile(r'^(\d+(\.\d+)?)')
handle = None
fuadnafiz98 / transparent.vim
Last active Aug 29, 2021
vim transparent background
View transparent.vim
" for transparent background
function! AdaptColorscheme()
highlight clear CursorLine
highlight Normal ctermbg=none
highlight LineNr ctermbg=none
highlight Folded ctermbg=none
highlight NonText ctermbg=none
highlight SpecialKey ctermbg=none
highlight VertSplit ctermbg=none
highlight SignColumn ctermbg=none
cryptoscopia / dydxFlashLoanTemplate.sol
Created Oct 21, 2020
A single-file simplest possible template for a contract that obtains a flash loan from dydx, does things, and pays it back.
View dydxFlashLoanTemplate.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
// The ABI encoder is necessary, but older Solidity versions should work
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
// These definitions are taken from across multiple dydx contracts, and are
// limited to just the bare minimum necessary to make flash loans work.
library Types {
enum AssetDenomination { Wei, Par }
itzmeanjan / ChildERC20.sol
Last active Jul 6, 2021
An illustration of sending data from Ethereum root chain to Matic child chain
View ChildERC20.sol
// File: contracts/child/ChildToken/ChildERC20.sol
pragma solidity 0.6.6;
contract ChildERC20 is
gnurgeldiyev / api.js
Last active Aug 3, 2021
How to get the response time from Axios
View api.js
const axios = require('axios').default
const API_BASE_URL = ''
const API = axios.create({
* setting interceptors to be able
* to know response time of the each request
View ChainlinkExample.sol
pragma solidity ^0.6.0;
import "";
// MyContract inherits the ChainlinkClient contract to gain the
// functionality of creating Chainlink requests
contract ChainlinkExample is ChainlinkClient {
// Stores the answer from the Chainlink oracle
uint256 public currentPrice;
address public owner;
View init.vim
" Specify a directory for plugins
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'scrooloose/nerdtree'
"Plug 'tsony-tsonev/nerdtree-git-plugin'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
rekmarks / newProvider.js
Last active Apr 18, 2021
Using the New MetaMask Inpage Provider
View newProvider.js
// Running on the page, in the browser
// This API will go live in early 2020
// It will be the only API available after a 6-week deprecation period
if (!ethereum || !ethereum.isMetaMask) {
throw new Error('Please install MetaMask.')