Skip to content

Instantly share code, notes, and snippets.

{
"nonce": "0x000000000000006601",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x655741534d2074657374206e6574776f726b2030",
"gasLimit": "0x8000000",
"difficulty": "0x100000",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0",
"alloc": { }
@axic
axic / creatorcontract.md
Last active August 30, 2016 19:51
Creator Contract abstraction

This is a follow up to ethereum/EIPs#86 with the intent of moving more logic to contract abstractions.

Motivation

Replace the special CREATE opcode and the special case of external transactions, which cause a contract to be deployed, with a contract.

Abstract

The creator contract (at address TBD) takes bytecode to be deployed as the input and returns 20 bytes output consisting of the 160-bit contract address.

;; Contract: A
(module
(import $callDataCopy "ethereum" "callDataCopy" (param i32 i32 i32))
(import $storageStore "ethereum" "storageStore" (param i32 i32))
(import $getCallValue "ethereum" "getCallValue" (param i32))
(import $return "ethereum" "return" (param i32))
(memory 1 1)
(export "memory" memory)
(export "main" $main)
(func $main
@axic
axic / 640.c
Created September 10, 2016 20:55
#include <stdio.h>
#include "secp256k1.h"
int main(int argc, char *argv[]) {
// Convert the mnemonic to seed
const char *mnemonic = "radar blur cabbage chef fix engine embark joy scheme fiction master release";
if (!mnemonic_check(mnemonic))
printf("Invalid mnemonic!");
@axic
axic / sha256.sol
Created September 18, 2016 14:42
Fake SHA256 in Solidity
contract SHA256 {
/* SHA-224 and SHA-256 constants for 64 rounds. These words represent
* the first 32 bits of the fractional parts of the cube
* roots of the first 64 prime numbers. */
uint[64] rounds;
function SHA256() {
rounds[0] = 0x428a2f98;
rounds[1] = 0x71374491;
@axic
axic / concept.md
Last active October 13, 2016 10:03
Metered Ethereum State

Metered Ethereum State

Based on the idea of @wanderer, the goal is to have as many processes metered deterministically as possible. Currently (Ethereum Homestead), a lot of processes aren't metered and therefore correct, or incorrect, guesses are made at how much any of these should cost. (See the gas cost table.)

Assume:

  1. Using eWASM
  2. SSTORE, SLOAD, CALL, etc. are callback based
  3. Elevated Contracts are those not residing in the state
@axic
axic / eip150forkcheck.sol
Last active October 15, 2016 00:39
EIP150 fork check in Solidity
contract EIP150ForkCheck {
bool public active = false;
bool public executed = false;
uint public constant fork_block = 42; // FIXME
function update() {
if (block.number < fork_block) {
return;
}
@axic
axic / BytecodeDeployer.sol
Created October 22, 2016 21:04
Deploy bytecode using Solidity
pragma solidity ^0.4.2;
contract BytecodeDeployer {
function test() returns (address) {
return createFromBytecode(0, hex"60006000f3");
}
function createFromBytecode(uint value, bytes bytecode) returns (address result) {
assembly {
let size := mload(bytecode)
result := create(value, add(bytecode, 32), size)
}
@axic
axic / Pathing.md
Last active November 17, 2016 21:40

Representing relative paths

In any system where variable length paths can be used to traverse objects the can be a need to reference

  • self
  • peers
  • parent(s)
  • child(ren)

Proposal is to use an array to represent paths:

  • self is an empty array: []
contract HelloWorld {
string name;
uint number;
function HelloWorld(string _name) {
name = _name;
}
function getName() returns (string) {
return name;