This file contains hidden or 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
// where map(x, function(y, i, z){ z === x; return y }) === x | |
// and i is the index/key, and z is the first argument to map | |
// e.g. utilsFromMap(function(array, fn){ array.map(fn) }); | |
// e.g. utilsFromMap(React.Children.map); | |
function utilsFromMap(map){ | |
var utils = {}; | |
// herein fn is a function, | |
// X is the thing to be passed to map as the first argument | |
// and there other parameters are specific to the function |
This file contains hidden or 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
web3.eth.filter("pending").watch(function() { | |
if (eth.mining) return; | |
console.log(new Date() + "-- Transactions detected, so starting mining."); | |
miner.start(1); | |
}); | |
web3.eth.filter('latest', function(error, result) { | |
console.log(new Date() + "-- Got latest, so stopping mining"); | |
miner.stop(); | |
if (txpool.status.pending > 0) { |
This file contains hidden or 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
if (!String.prototype.repeat) { | |
// polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat | |
String.prototype.repeat = function(count) { | |
'use strict'; | |
if (this == null) { | |
throw new TypeError('can\'t convert ' + this + ' to object'); | |
} | |
var str = '' + this; | |
count = +count; | |
if (count != count) { |
This file contains hidden or 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
const Rx = require('rx'); | |
module.exports = { | |
rxify: function (web3) { | |
// List synchronous functions masquerading as values. | |
var syncGetters = { | |
db: [], | |
eth: [ "accounts", "blockNumber", "coinbase", "gasPrice", "hashrate", | |
"mining", "protocolVersion", "syncing" ], | |
net: [ "listening", "peerCount" ], |
This file contains hidden or 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
module.exports = { | |
promisify: function (web3) { | |
// Pipes values from a Web3 callback. | |
var callbackToResolve = function (resolve, reject) { | |
return function (error, value) { | |
if (error) { | |
reject(error); | |
} else { | |
resolve(value); | |
} |
-
Get started • • BigchainDB
-
Kadena: Scalable Blockchain | Smarter Contracts
-
kadena-io/pact: The Pact Smart Contract Language
Suppose we wish to model a UTXO system on the EVM. We need to represent UTXO tokens such that all value is preserved when tokens are spent. Note: For this example, we are not concerned about the security of the system and are satisfied with giving authorities the power to create tokens (e.g. as in a plasma system).
Consider the following object:
{
owner: <address>,
value: <uint>,