Skip to content

Instantly share code, notes, and snippets.

@axic
axic / dummymetering.wasmhex
Last active January 21, 2018 14:59
Dummy eWASM sentinel contract
0061736d0100000001170560017e006000017f60037f7f7f0060027f7f0060000002580408657468657265756d06757365476173000008657468657265756d0f67657443616c6c4461746153697a65000108657468657265756d0c63616c6c44617461436f7079000208657468657265756d0672657475726e0003030201040503010001071102066d656d6f72790200046d61696e00040a25012301017f1001210042ba022000ad7e42e40080100041004100200010024100200010030b
pragma solidity ^0.4.19;
interface ShenzhenKitties {
function transferKittie(address to, string name) external;
function kittieOwner(string name) external view returns (address);
}
contract KittieEscrow {
ShenzhenKitties constant kittieRegistry = ShenzhenKitties(0x59f710ab6e0D4bafc20B3B86dC1bcC196d5ae16F);
address public beneficiary;
pragma solidity ^0.4.19;
pragma experimental ABIEncoderV2;
contract ShenzhenKitties {
event Registered(string name, address owner);
event Transferred(string name, address from, address to);
mapping (bytes32 => address) kitties;
string[] public kittieNames;
@axic
axic / roadmap.md
Last active August 11, 2018 20:34
eWASM Roadmap 2017-2018 [Not kept up to date]
pragma solidity ^0.4.13;
library BytesTool {
function memcopy(bytes src, uint srcoffset, bytes dst, uint dstoffset, uint len) pure internal {
assembly {
src := add(src, add(32, srcoffset))
dst := add(dst, add(32, dstoffset))
// copy 32 bytes at once
for
// the Hypervisor starts an manages "containers"
class PrimeaContainer {
// the constructor is given an instance of the kernel
// https://github.com/primea/js-primea-hypervisor/blob/master/docs/kernel.md
constructor (kernel) {
this.kernel = kernel
}
// this method runs once when the container is initially created. It is given
// a message with a single port, which is a channel to its parent with the
{
let cur_block_number := number()
jumpi(system_sender, eq(caller(), 0xfffffffffffffffffffffffffffffffffffffffe))
// Sender is a regular account - Getting a block
{
let block_number := calldataload(0)
// Abort if block is in future
@axic
axic / blockhash.evmasm
Created May 5, 2017 08:07
EIP96 sample implementation in Assembly
{
// Reject incoming value transfers
jumpi(unpaid, iszero(callvalue()))
invalid
unpaid:
let cur_block_number := number()
jumpi(system_sender, eq(caller(), 0xfffffffffffffffffffffffffffffffffffffffe))
@axic
axic / hello.c
Last active May 4, 2017 14:36
Sample clang compiled webassembly
main() {
char buf[4096] = { 0 };
unsigned long long x = 1;
printf("hello %lld", x);
}
contract btcRelay {
function verifyHeader(uint hash) payable returns (uint) {
return (hash == 42) ? 1 : 0;
}
}
contract btcRelayFreeVerifyHeader {
btcRelay btcrelay;
function btcRelayFreeVerifyHeader() payable {