Skip to content

Instantly share code, notes, and snippets.

View gakonst's full-sized avatar

Georgios Konstantopoulos gakonst

View GitHub Profile
@GNSPS
GNSPS / ProxyFactory.sol
Last active December 11, 2024 21:58
Improved `delegatecall` proxy contract factory (Solidity) [v0.0.5]
/***
* Shoutouts:
*
* Bytecode origin https://www.reddit.com/r/ethereum/comments/6ic49q/any_assembly_programmers_willing_to_write_a/dj5ceuw/
* Modified version of Vitalik's https://www.reddit.com/r/ethereum/comments/6c1jui/delegatecall_forwarders_how_to_save_5098_on/
* Credits to Jorge Izquierdo (@izqui) for coming up with this design here: https://gist.github.com/izqui/7f904443e6d19c1ab52ec7f5ad46b3a8
* Credits to Stefan George (@Georgi87) for inspiration for many of the improvements from Gnosis Safe: https://github.com/gnosis/gnosis-safe-contracts
*
* This version has many improvements over the original @izqui's library like using REVERT instead of THROWing on failed calls.
* It also implements the awesome design pattern for initializing code as seen in Gnosis Safe Factory: https://github.com/gnosis/gnosis-safe-contracts/blob/master/contracts/ProxyFactory.sol
@markblundeberg
markblundeberg / atomic-size-attack.md
Created February 16, 2018 05:14
Advisory: secret size attack on cross-chain hash lock smart contracts

Advisory: secret size attack on cross-chain hash lock smart contracts

Dr. Mark B Lundeberg, 2018 Feb 15 bitcoincash:qqy9myvyt7qffgye5a2mn2vn8ry95qm6asy40ptgx2

This security advisory notes a vulnerability in the common construction of cross-chain smart contracts (contracts between distinct cryptocurrencies) through hash locking. I focus on the primary use case in [atomic

## [It would be nice to import a library, another contract's interface, or a
## parent to inherit from]
## but that's not supported. Yes, inheritance is dangerous, but code reuse can
## be very beneficial as
## well. I believe adoption will be held back by this.
## [Declare a positive number] Why change the type from `uint256`? `num` is
## less descriptive, ie. it could include irrational numbers for all I know.
## Also, will 4-byte identifiers be compatible with solidity?
## ie. `bytes4(keccak256('uint256'))` or `bytes4(keccak256('num'))` ? Or is
@amir-arad
amir-arad / vorpal.d.ts
Created February 9, 2018 08:34
WIP type descriptors for vorpal
// Type definitions for vorpal 1.12.0
// Project: https://github.com/dthree/vorpal
// Definitions by: Jim Buck <http://github.com/jimmyboh>, Amir Arad <[email protected]>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="inquirer" />
/// <reference types="minimist" />
declare module "vorpal" {
import {ParsedArgs} from 'minimist';
[package]
name = "bigint"
version = "0.1.0"
authors = ["Anon"]
[dependencies]
ramp = "0.3.11"
lazy_static = "1.0.0"
extern crate ramp;
use ramp::Int;
#[derive(PartialEq, Clone, Debug)]
struct Point {
x: Int,
y: Int,
}
@HarryR
HarryR / schnorr.py
Last active October 22, 2024 05:38
Implementation of Schnorr signatures over secp256k1 - warning, this is vulnerable to the Related Key Attack...
from __future__ import print_function
from random import randint
from hashlib import sha256
from py_ecc.secp256k1.secp256k1 import add, multiply, inv, N, P, G
bytes_to_int = lambda x: reduce(lambda o, b: (o << 8) + ord(b), [0] + list(x))
rands = lambda: randint(1, N - 1)
sbmul = lambda s: multiply(G, s)
hashs = lambda *x: bytes_to_int(sha256('.'.join(['%X' for _ in range(0, len(x))]) % x).digest()) % N
hashp = lambda *x: hashs(*[item for sublist in x for item in sublist])

Answers to Deep Questions about Solidity

The following list of questions was taken from https://www.reddit.com/r/ethereum/comments/72reba/do_you_have_deep_questions_about_solidity_or_the/

An updated summary on the different ways one could have two contracts interact (DELEGATECALL, STATICCALL, libraries, all that stuff) with clear pros/cons for each (gas cost, whether it requires EVM assembly directives, etc)

Question by /u/drcode

I won't talk about low-level opcodes here because of the brevity of the answer. In general, there are four ways functions can be called in Solidity:

@gititGoro
gititGoro / Recipe.md
Last active September 15, 2023 07:32
Environmental setup for Ethereum Dev as of 14 June 2017

Setting up a private ethereum blockchain for development and pointing your wallet at it

Ethereum tutorials all advise downloading the Mist wallet and beginning dev. The only problem is that the testnet and real blockchain are huge and take hours to download. What follows is a recipe for quickly setting up a small blockchain and pre-mining it with some test ethereum

The following is done in Linux but will work in MacOS and should have equivalent command line options in Windows. Where I don't give detailed instructions, it's because a quick google search will fill in the blanks.

Install geth https://github.com/ethereum/go-ethereum/wiki/geth

install Mist https://github.com/ethereum/mist/releases