Skip to content

Instantly share code, notes, and snippets.

contract Precompile {
function foo (bytes) returns (bytes32);
}
contract Testcontract {
bytes32 last;
event Debug(string message, bytes32 res);
Precompile prec = Precompile(0x0000000000000000000000000000000000000002);
import { Architect, Config, Methods, Network, Neat } from 'neataptic'
import Parallel from 'paralleljs'
Config.warnings = false
const trainingSet = [
{ input: [0, 0], output: [0] },
{ input: [0, 1], output: [1] },
{ input: [1, 0], output: [1] },
{ input: [1, 1], output: [0] },
@D-Nice
D-Nice / erc20.sol
Created July 6, 2017 16:12
underhanded ICO submission
pragma solidity ^0.4.0;
contract ERC20 {
function totalSupply() constant returns (uint totalSupply);
function balanceOf(address _owner) constant returns (uint balance);
function transfer(address _to, uint _value) returns (bool success);
function transferFrom(address _from, address _to, uint _value) returns (bool success);
function approve(address _spender, uint _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint remaining);
event Transfer(address indexed _from, address indexed _to, uint _value);
/*
Kraken-based ETH/XBT price ticker
This contract keeps in storage an updated ETH/XBT price,
which is updated every ~60 seconds.
*/
pragma solidity ^0.4.0;
import "oraclizeLib.sol";
@D-Nice
D-Nice / api
Created June 1, 2017 00:29 — forked from anonymous/api
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.11+commit.68ef5810.js&optimize=false&gist=
// <ORACLIZE_API>
/*
Copyright (c) 2015-2016 Oraclize SRL
Copyright (c) 2016 Oraclize LTD
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
contract stringArrayToBytes {
string[] x = ["qs2333332222222222222222222222222233333311", "q2", "q3", "5025",
"anotherquery", "oisjgsodjgdsogjsdgsdgsdgsdoigjsdiogjsodigjsdoigjsdog",
"777777777", "88888888", "99999", "TEN"];
function convert(string[] x, uint from, uint to) internal returns (bytes) {
bytes memory z;
uint zlen = 0;
for (var i = from; i <= to; i++) {
bytes memory y = bytes(x[i]);
@D-Nice
D-Nice / hexStringToBytes32.sol
Created December 25, 2016 20:41
Solidity inline assembly code for converting a hex string into the same bytes32
/* Converts a hexadecimal string, whose bytes equivalent length
can be up to 32 bytes (at least only tested and meant for up to 32 bytes)
into a bytes32 type.
EXAMPLE I/O
I: "a0c3689df9ce9c3aee5c1ba34dd1649098e2a10f6b2b337bf26695318cc0b958"
O: bytes32: 0xa0c3689df9ce9c3aee5c1ba34dd1649098e2a10f6b2b337bf26695318cc0b958
Currently assumes the 0x prefix is omitted from the string.
pragma solidity ^0.4.0;
contract SHA1 {
uint8[4] shift = [3, 8, 14, 16];
uint constant leftAlign = 16**56;
uint constant prep = 16**55; //allow extra bits as requested in spec
uint constant h0 = 1732584193 * prep; //0x67452301
uint constant h1 = 4023233417 * prep; //0xEFCDAB89
@D-Nice
D-Nice / tlsn-notarization-file-format.md
Created November 9, 2016 21:45 — forked from AdamISZ/tlsn-notarization-file-format.md
TLSNotary notarization file format

Data format: binary. Default file extension: '.tlsn'

Contents

Field description (size in bytes) code in Python version
Header (29) 'tlsnotary notarization file\n\n'
@D-Nice
D-Nice / BigInt.sol
Created September 29, 2016 23:39 — forked from axic/BigInt.sol
Big number library in Solidity (for modexp)
//
// Big number library in Solidity for the purpose of implementing modexp.
//
// Should have a similar API to https://github.com/ethereum/EIPs/issues/101
//
// Internally bignumbers are represented as an uint array of 128 bit values.
//
// NOTE: it assumes usage with "small" (<256bit) exponents (such as in RSA)
//