Skip to content

Instantly share code, notes, and snippets.

Santiago Palladino spalladino

Block or report user

Report or block spalladino

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@spalladino
spalladino / setup-relayer.md
Last active Aug 23, 2019
Manual script for setting up a GSN relayer
View setup-relayer.md

Manual setup for a GSN relayer

Install nginx and certbot

sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install nginx software-properties-common certbot python-certbot-nginx
@spalladino
spalladino / AdminUpgradeabilityProxy.abi.json
Created May 20, 2019
ABI for ZeppelinOS AdminUpgradeabilityProxy as of zos-lib@2.3.0
View AdminUpgradeabilityProxy.abi.json
[
{
"constant": false,
"inputs": [
{
"name": "newImplementation",
"type": "address"
}
],
"name": "upgradeTo",
@spalladino
spalladino / RepoPackage.sol
Created Sep 25, 2018
Sample package 2.0 contract
View RepoPackage.sol
contract RepoPackage {
event NewVersion(uint256 versionId, uint16[3] semanticVersion);
struct Version {
uint16[3] semanticVersion;
address contractAddress;
bytes contentURI;
}
mapping (bytes32 => Version) versions;
@spalladino
spalladino / test-deployment.js
Created Sep 18, 2018
Tests contract deployment via web3 using manually signed transactions
View test-deployment.js
const Tx = require('ethereumjs-tx');
const Web3 = require('web3')
const web3 = new Web3(new Web3.providers.HttpProvider(url));
function getCodeFromTxHash(hash, source) {
web3.eth.getTransactionReceipt(hash, function (err, receipt) {
if (err) {
console.error(source, "ERROR on getting tx receipt from hash", err);
}
@spalladino
spalladino / zos-initializers.md
Last active Jul 25, 2018
Summary of experiments on initializer contracts
View zos-initializers.md

Proxy contract initialization

This gist contains a summary of the experiments around initialization of proxy contracts, comparing the current approach with new ones we have been working on. We used a sample ERC20 and an ERC721 contracts for testing. Most of these tests can be found in the labs repo. Credit for most approaches listed here goes to @frangio.

Initializer functions

Initializer functions is the current approach used for zOS. All contracts must be modified to have an initializer function, which is invoked right after creating the proxy. It must also be decorated with an isInitializer modifier to ensure it can be called only once.

Note that this modification, while is currently done manually, could be automated by using a tool.

View AdminUpgradeabilityProxy.abi.json
[
{
"inputs": [
{
"name": "_implementation",
"type": "address"
}
],
"payable": false,
"stateMutability": "nonpayable",
@spalladino
spalladino / count-repos.py
Last active Jan 2, 2018
Estimate number of repositories that match a code search
View count-repos.py
from http.client import HTTPSConnection
from base64 import b64encode
from json import loads
from sys import exit, argv, stderr
from time import sleep
import urllib3
# Settings
PRINT_REPOS = True
@spalladino
spalladino / hash.py
Created Oct 21, 2017
Solution for Coursera Cryptography 1 course Week 3 programming assignment
View hash.py
from hashlib import sha256
from sys import argv
with open(argv[1], "rb") as f:
blocks = []
block = f.read(1024)
while block:
blocks.append(block)
block = f.read(1024)
@spalladino
spalladino / web3.js
Created Oct 16, 2017
Detect whether a web3 connection is available
View web3.js
// Adapted from https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#partly_sunny-web3---ethereum-browser-environment-check
window.addEventListener('load', function() {
// Checking if Web3 has been injected by the browser (Mist/MetaMask)
if (typeof web3 !== 'undefined') {
// Use Mist/MetaMask's provider
window.web3 = new Web3(web3.currentProvider);
} else {
// fallback - use your fallback strategy (local node / hosted node + in-dapp id mgmt / fail)
window.web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
@spalladino
spalladino / monitor.js
Created Oct 15, 2017
Configure ngrok with nodemon for local development
View monitor.js
#!/usr/bin/env node
if (process.env.NODE_ENV === 'production') {
throw new Error("Do not use nodemon in production, run bin/www.js directly instead");
}
const nodemon = require('nodemon');
const ngrok = require('ngrok');
// We start an ngrok tunnel to ensure it stays the same for the entire process
You can’t perform that action at this time.