Skip to content

Instantly share code, notes, and snippets.

View danfinlay's full-sized avatar

Dan Finlay danfinlay

View GitHub Profile
@danfinlay
danfinlay / popup.js
Created March 21, 2018 23:05
popup.js for metamask 4.3.0
This file has been truncated, but you can view the full file.
!function(){return function e(t,n,r){function i(a,s){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[a]={exports:{}};t[a][0].call(l.exports,function(e){var n=t[a][1][e];return i(n||e)},l,l.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}}()({1:[function(e,t,n){t.exports={accept:{message:"Accept"},account:{message:"Account"},accountDetails:{message:"Account Details"},accountName:{message:"Account Name"},address:{message:"Address"},addCustomToken:{message:"Add custom token"},addToken:{message:"Add Token"},addTokens:{message:"Add Tokens"},amount:{message:"Amount"},amountPlusGas:{message:"Amount + Gas"},appDescription:{message:"Ethereum Browser Extension",description:"The description of the application"},appName:{message:"MetaMask",description:"The name of the application"},approved:{message:"Approve
@danfinlay
danfinlay / sendMutableTransaction.md
Last active January 17, 2018 01:41
An idea for a new web3 method, sendMutableTransaction

New Web3 Method Proposal: sendMutableTransaction

Today, when a dapp calls eth_sendTransaction, the parameters are sent up to the signer, and the app is called back once, with the resulting transaction hash.

This is a great way to allow a dapp to track the progress of a signed transaction, assuming that transaction is static and not mutable.

Recent transaction backlogs have forced us at MetaMask to add a button on long-pending transanctions to "Retry with higher gas price", but if a dapp or service was tracking the signed transaction by hash, it has no way of discovering that this transaction was ever resubmitted successfully.

This is only a problem for apps that submit a transaction, and continue tracking that specific transaction hash until it is mined, but for dapps with that problem, one solution could be to add a new method, maybe called eth_sendMutableTransaction, which calls back not wit

@danfinlay
danfinlay / metamask-multi-signer-type.md
Created November 3, 2017 04:29
MetaMask: Multi Signer Types?

Multi Sign-Type Proposal

Intended Audience

Maintainers and influencers of cryptographically-secured peer-to-peer protocols, espeically those concerned with the user experience and thus real adoption of these secure protocols.

Context

Today MetaMask is an Ethereum account manager and blockchain API provider, and it's made Ethereum useful G

@danfinlay
danfinlay / ethjs-web3-examples.md
Last active October 19, 2017 20:04
Set of ethereum web3 examples
@danfinlay
danfinlay / insufficient-balance-eip.md
Last active October 5, 2017 20:26
Insufficient Balance on-chain error EIP

Currently, a signed transaction that sends more ether than an account has is considered an invalid transaction, and is not mined.

This can cause a dangerous situation where a user sends funds they didn't mean to, and can be completely avoided by allowing miners to process "insufficient balance" as an on-chain error.

Reproduction steps:

  • A user with balance X signs and broadcasts TX A for a max possible value Y (value + gasPrice * gasLimit) where Y < X.
  • Before that tx is mined, the user impatiently signs and broadcasts TX B, with an incremented nonce, for max possible value Z where Z < X && Z + Y > X.
  • Because each of these transactions are less than the user's current balance, they are both added to miner mempools.
  • Transaction A is valid, and is mined.
  • Transaction B has undefined behavior. Some nodes may forget it, but it may be passed among peers and remembered at any time.
@danfinlay
danfinlay / keybase-proof.md
Last active October 5, 2017 16:41
Keybase proof

Keybase proof

I hereby claim:

  • I am danfinlay on github.
  • I am danfinlay (https://keybase.io/danfinlay) on keybase.
  • I have a public key ASBiu5WsTk7PFIraS7EKc8LNanBRb45h2Wg777KyW7ImEgo

To claim this, I am signing this object:

@danfinlay
danfinlay / mallele-registrar.sol
Created August 18, 2017 17:28
Rough draft of a meme market ENS registrar system. You'd register a top-level ENS name for the parent one, and it would allocate its child names according to the desires of its token holders, thus minting new child registrar tokens.
contract MalleleRegistrar is HumanStandardToken, EnsRegistrar {
// Map subnode namehashes to child instances of MalleleRegistrar.
mapping(bytes32 => address) subMalleles;
mapping(address => bytes32) balances;
uint currentPrice = 1;
uint priceIncrease = 1;
address baseCurrencyToken;
@danfinlay
danfinlay / ens-unregistering-goal.md
Last active August 13, 2017 20:52
A wording for an ENS objective, as I propose it.

We agree that a permanent .eth registrar should incentivize the freeing-up/unregistering of some quantity of names, which should fall safely beneath the threshold of names that are actually useful. We are interested in employing mechanics such as dynamically setting values including but not limited to minimum bid size, rent prices, initial purchase fees, deposit size, specific auction mechanics, and whatever else helps us effectively reach that goal.

@danfinlay
danfinlay / restricted_token.sol
Created July 21, 2017 22:16
A sample restricted token, that respects an owner's whitelist.
contract RestrictedToken {
address owner;
mapping (address => uint) balances;
mapping (address => bool) whitelist;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
function RestrictedToken() {
balances[tx.origin] = 10000;
@danfinlay
danfinlay / different_sig_verification.js
Created July 20, 2017 00:20
Another approach to verifying an eth.sign call. I need a test suite on this.
var ethUtil = require('ethereumjs-util')
var address = '0x1dba1131000664b884a1ba238464159892252d3a'
var msg = 'https://www.reddit.com/r/ethereum/comments/6obofq/a_modified_version_of_a_common_multisig_had_a/'
var claimed = '0xe7bf6c80979b6633dc9bdc7ae556f40ceb43eee2ba8b2a7deaf9b838dd8b21d46858b62b0b01b257f7194de03366f09aa89115717f8860b4620d8a6c92cbeec71c'
const msgHash = ethUtil.hashPersonalMessage(new Buffer(msg))
const sigParams = ethUtil.fromRpcSig(claimed)
const publicKey = ethUtil.ecrecover(msgHash, sigParams.v, sigParams.r, sigParams.s)