Skip to content

Instantly share code, notes, and snippets.

@amiller
Last active June 26, 2017 22:32
Show Gist options
  • Save amiller/f9d2609ffd12125cedc1f8b2605845e0 to your computer and use it in GitHub Desktop.
Save amiller/f9d2609ffd12125cedc1f8b2605845e0 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.0;
// This contract is used for making a new opcode via a softfork.
// It works for opcodes that just evaluate an arbitrary function,
// returning y = f(x).
//
// The idea is to create a contract that implements an arbitrary key-value
// mapping, but miners (after the softfork) enforce that the only updates to the
// contract respect the correct function.
//
// To make this easy to enforce, the contract itself enforces that the mappings
// can only be written by a transaction from a user account (but the private
// key for this account is published / well-known).
contract SoftForkNewOpcode {
// Private key (anyone can spend!):
// 9d3cd1335763d4e46a335054a27672aab7edefabdb6111729801c6a55d9350a7
address constant pk = 0x8f9704c1F3773B49D095217B4577935191Ec8050;
mapping (bytes32 => bytes32) public data;
function set(bytes32 k, bytes32 v) {
// This function can only be called by the account above
require(msg.sender == pk);
data[k] = v;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment