Skip to content

Instantly share code, notes, and snippets.

tonyofbyteball

Block or report user

Report or block tonyofbyteball

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View oscript2.md

Changes in Oscript 2.0

Functions

$f = ($x) => {
	 $a = var['a'];
	 $x * $a
};

// one-line syntax for functions that have only one expression
View gist:11d5083174cabdbfc8a9fd4a98aa6de3
const path = require('path')
// eslint-disable-next-line no-unused-vars
const { Testkit, Utils } = require('aa-testkit')
const { Network } = Testkit({
TESTDATA_DIR: path.join(__dirname, '../testdata'),
})
describe('Check 2 wallets', function () {
this.timeout(120 * 1000)
@tonyofbyteball
tonyofbyteball / gist:ca071b74babdb368c0435fdff94f6858
Created Apr 20, 2020
Uniswap-like market maker with single-token contributions
View gist:ca071b74babdb368c0435fdff94f6858
{
init: `{
$asset = 'n9y3VomFeWFeZZ2PcSEcmyBb/bI7kzZduBJigNetnkY=';
$mm_asset = var['mm_asset'];
}`,
messages: {
cases: [
{ // define share asset
if: `{ trigger.data.define AND !$mm_asset }`,
messages: [
@tonyofbyteball
tonyofbyteball / draw-winner-selection-algo.js
Last active Jan 6, 2019
Provably fair algorithm of selecting the winner based on bitcoin hash
View draw-winner-selection-algo.js
// bitcoin_hash is the hash (in hex) of the latest Bitcoin block
// arrPoints is array of points of all addresses ordered by address [{address: "...", points: 1234}, ...]
// rows1 is array of balances of all addresses ordered by address [{address: "...", balance: 1234}, ...]
// sum is the sum of all points
// 1. winner by points
let hash = crypto.createHash('sha256').update(bitcoin_hash).digest('hex');
let number = new BigNumber(hash, 16);
let random = (number.div(new BigNumber(2).pow(256))).times(sum);
You can’t perform that action at this time.