Skip to content

Instantly share code, notes, and snippets.

@axic
axic / safer_ethereum_address.js
Created March 11, 2016 21:06
ERC: Safer Ethereum Address Format - Generator tool
var ethUtil = require('ethereumjs-util')
var fixtures = [
{
name: 'ethbase-1 ',
alphabet: 'abcdefghjklmnopqrstvwxyz',
magic: [ ]
},
{
name: 'ethbase-2 ',
@axic
axic / README.md
Created February 10, 2017 01:37
WebAssembly kickstart guide

WebAssembly kickstart guide

Rolling your own compiler

One of the premises of WebAssembly is to support compiling multiple languages to WebAssembly.

C/C++

Building

@axic
axic / HandshakeKeys.md
Created January 9, 2019 23:40
Handshake - Keys and Addresses

Handshake - Keys and Addresses

DISCLAIMER: There is no warranty for any of the below be correct, up to date, or valid in any form. This is not a specification, only the braindump of some code digging. In fact it is very likely all of this is incorrect and useless. DO NOT PUT TOKENS INTO ADDRESSES GENERATED USING THE INFORMATION BELOW.

From their website:

Decentralized certificate authority and naming

An experimental peer-to-peer root DNS.

Handshake aims to "airdrop" a large quantity of the tokens to developers (backed by Github and Freenode profiles) or well known people (backed by PGP WoT).

@axic
axic / stringaskey.sol
Last active July 10, 2019 00:10
How to use string as a key in a mapping in Solidity aka. how to store short strings cheape
//
// In Solidity, a mapping is like a hashmap and works with `string` like this:
// mapping (string => uint) a;
//
// However it doesn't support accessors where string is a key:
// mapping (string => uint) public a;
//
// "Internal compiler error: Accessors for mapping with dynamically-sized keys not yet implemented."
//
// An accessor returns uint when called as `a(string)`.
@axic
axic / README.md
Last active June 1, 2019 21:24
Eth 2 Phase Crossover EE

"Crossover" EE

The "crossover" execution environment aka Eth1-esque abstraction over Phase2

The current proposals for Eth 2 Phase 2 revolve around a purely stateless architecture, where the only stored information is the state root of each "execution environment" on a shard. This is in stark contrast to the stateful mode of operation on Eth1.

This model expects higher level abstractions to be built atop this simple system. Here follows one proposal to achieve a familiar environment as a higher level abstraction.

/*
* QIMalloc - Quick, incremental malloc.
*
* This is a dummy malloc implementation, without the option to free memory space.
*/
static int __malloc_ptr = 0;
static int __malloc_end = 0;
void *malloc(size_t size) {
@axic
axic / ERC20SafeTransfer.sol
Last active January 26, 2019 03:05
Safe transfer workaround for not fully ERC20 compatible tokens.
/*
* WARNING: Proof of concept. Do not use in production. No warranty.
*
* Safe transfer workaround for not fully ERC20 compatible tokens.
* Well, ERC20 had a lot of revision, who I am to say something is not compatible :)
*
* Read the following for more explanation: https://github.com/ethereum/solidity/issues/4116
*
* In short:
* The final ERC20 standard (IIRC) requires the transfer function to return a boolean. Some tokens do not return anything
@axic
axic / roadmap.md
Last active August 11, 2018 20:34
eWASM Roadmap 2017-2018 [Not kept up to date]
eWASM and Backwards Compatibility
=================================
High Level
----------
Pros:
- ease transition: legacy EVM compatible with eWASM
Cons:
@axic
axic / contracthelper.sol
Created April 16, 2018 12:35
Check if a Solidity contract function is running as part of a constuctor
/*
* This is a helper to check if a Solidity contract function is running as part of a constructor.
*/
library ContractHelper {
function runningInConstructor() internal view returns (bool ret) {
assembly {
ret := iszero(iszero(extcodesize(address)))
}
}
}