Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

hack3r-0m

🎯
Focusing
View GitHub Profile
@benjyz
benjyz / tradingbrokerspec.md
Last active Jan 30, 2021
trading broker spec
View tradingbrokerspec.md

trading broker spec

proposal version 0.01 this is a rough spec for what a client-side trading infrastructure expects from an interface. There should be a client-side wrapper matching the hosts API. we ignore funding requests here (deposit/withdraw)

Wrapper API

private

View diff-branch.sh
function diff-branch() {
if [ -z $1 ]; then
echo please provide an branch
read WORKBRANCH
else
WORKBRANCH=$1
fi
if [ -z $2 ]; then
STABLEBRANCH='master'
View ercxxx_distribution.py
import json
import os
from collections import defaultdict
from json import JSONDecodeError
from pprint import pprint
from typing import Dict, Union, List
import requests
from bs4 import BeautifulSoup
@rekmarks
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.')
}
/*********************************************************/
@itzmeanjan
itzmeanjan / catch.py
Last active May 28, 2021
Polygon ( aka Matic Network ) Mempool Exploration
View catch.py
#!/usr/bin/python3
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
@xceric
xceric / .gitattributes
Last active Jun 16, 2021
Git attributes for Typescript
View .gitattributes
# See this article for reference: https://help.github.com/articles/dealing-with-line-endings/
# Refreshing repo after line ending change:
# https://help.github.com/articles/dealing-with-line-endings/#refreshing-a-repository-after-changing-line-endings
# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto
#
# The above will handle all files NOT found below
@itzmeanjan
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
ERC20,
IChildToken,
AccessControlMixin,
NativeMetaTransaction,
ChainConstants,
@rhlsthrm
rhlsthrm / ReentrancyToken.sol
Created Oct 9, 2018
Fake ERC20 token that recreates reentrancy attack
View ReentrancyToken.sol
pragma solidity ^0.4.23;
import "./HumanStandardToken.sol";
import "../../LedgerChannel.sol";
contract ReentrancyToken is HumanStandardToken {
LedgerChannel ledgerChannel;
uint256 constant MAX_REENTRIES = 5;
uint256 numReentries = 0;
@tjade273
tjade273 / Database.sol
Last active Sep 24, 2021
Example of separated storage and logic
View Database.sol
contract Database{
mapping(uint => uint) public _data;
mapping(address => bool) _owners;
function Database(address[] owners){ //Called once at creation, pass in initial owners
for(uint i; i<owners.length; i++){
_owners[owners[i]]=true;
}
}
@chriseth
chriseth / async.md
Last active Oct 21, 2021
Async Solidity Contracts
View async.md

Having seen @pirapira's sketch of Bamboo ( https://github.com/pirapira/bamboo/ ), which proposed to add better control about the "smart contract program flow", even across calls, I thought that this should certainly be added to Solidity, and actually, it might even be possible now to a certain degree using inline assembly.

The problem is that with many functions in a contract, it is not always clear which can be called at which stage in the contract's lifetime. Certain smart contracts would be easier to understand if written as follows: