One of the premises of WebAssembly is to support compiling multiple languages to WebAssembly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract ERC165 { | |
function interfaceID() constant returns (uint) | |
{ | |
bytes4[] sigs = type(this).signatures; | |
uint mask = 0; | |
for (var i = 0; i < sigs.length; i++) | |
mask ^= uint(sigs[i]); | |
return mask; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* STATICCALL Proxy | |
* | |
* It expects the input: | |
* 256 bit - address | |
* 256 bit - gas | |
* 256 bit - value | |
* n bit - calldata to be proxied | |
* | |
* And returns the output: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract HelloWorld { | |
string name; | |
uint number; | |
function HelloWorld(string _name) { | |
name = _name; | |
} | |
function getName() returns (string) { | |
return name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.6; | |
contract MemcpyTest { | |
function test(string input) returns (string output) { | |
uint len = bytes(input).length; | |
output = new string(len); | |
uint _input; | |
uint _output; | |
assembly { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
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:
- Using eWASM
- SSTORE, SLOAD, CALL, etc. are callback based
- Elevated Contracts are those not residing in the state