Skip to content

Instantly share code, notes, and snippets.

0x14d06788090769F669427B6AEA1c0240d2321f34
function validProof(bytes proof, bytes32 root, bytes32 hash) constant returns (bool) {
bytes32 el;
for (uint256 i = 32; i <= proof.length; i += 32) {
assembly {
el := mload(add(proof, i))
}
if (hash < el) {
hash = sha3(hash, el);
@plutoegg
plutoegg / NEC.sol
Last active February 11, 2018 15:01
pragma solidity ^0.4.18;
/*
Copyright 2016, Jordi Baylina
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
pragma solidity ^0.4.18;
/*
Copyright 2016, Jordi Baylina
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@plutoegg
plutoegg / efx_approve.js
Last active September 24, 2018 13:15
Trustless Developer Guide - 2
const token = 'ZRX'
efx.contract.approve(token)
@plutoegg
plutoegg / efx_lock.js
Last active September 24, 2018 13:15
Trustless Developer Guide - 3
const token = 'ZRX'
const amount = 15 // Number of tokens to lock
const forTime = 48 // Time after which unlocking does not require permission
const response = await efx.contract.lock(token, amount, forTime)
@plutoegg
plutoegg / efx_websocket.js
Created September 24, 2018 13:18
Trustless Developer Guide - 0
const BFX = require('bitfinex-api-node')
const { Order } = require('./node_modules/bitfinex-api-node/lib/models')
const bfx = new BFX({
apiKey: '',
apiSecret: '',
ws: {
autoReconnect: true,
seqAudit: false,
@plutoegg
plutoegg / efx_init.js
Last active September 24, 2018 13:22
Trustless Developer Guide - 1
const EFX = require('efx-api-node')
const web3 = new EFX.Web3(/*your web3 provider*/)
const efx = await EFX( web3 )
const exchangeConf = await efx.getConfig()
@plutoegg
plutoegg / efx_submitOrder.js
Created September 24, 2018 13:30
Trustless Developer Guide - 4
const symbol = 'ZRXETH'
const amount = -15
const price = 0.0025
const orderId = await efx.submitOrder(symbol, amount, price)
@plutoegg
plutoegg / efx_getOrders.js
Created September 24, 2018 14:31
Trustless Developer Guide - 5
// Get all open orders
const openOrders = await efx.getOrders()
// Get all historical orders
const historicalOrders = await efx.getOrderHist()