Skip to content

Instantly share code, notes, and snippets.

View ssadler's full-sized avatar
🤍

Scott Sadler ssadler

🤍
  • utxocontracts.com
  • London, UK
View GitHub Profile
#!/usr/bin/bash
# This script makes the neccesary transactions to migrate
# coin between 2 assetchains on the same -ac_cc id
set -x
set -e
source=TXSCL
target=TXSCL000
@ssadler
ssadler / komodo_cross_chain_migrate.py
Created June 20, 2018 12:15
komodo_cross_chain_migrate.py
import sys
import subprocess
import json
# create an output with some funds to send across chain
# komodo-cli -ac_name=TXSCL sendtoaddress $inputaddress 2
inputaddress = "RFw7byY4xZpZCrtkMk3nFuuG1NTs9rSGgQ"
amount = 1.9
@ssadler
ssadler / txchanges.md
Last active June 2, 2017 09:40
Transaction changes in 1.0

Output amount is now a string

BigchainDB transactions may have multiple inputs and outputs, and each output has an amount, which is the integral number of the asset being transferred. In prior versions of BigchainDB, the amount was encoded as a number, which on the face of it is the obvious way to encode an integer. However, as usual the devil is in the details; JSON, the encoding of choice for BigchainDB transactions, encodes all numbers including integers as floating point. This isn't a problem for the majority of circumstances where numbers are small, however in some environments and for some use cases*, the number may lose precision.

In order to safeguard against this, amounts are now encoded as strings, and it is recommended to use a decimal math library (such as big.js) when dealing with large numbers in Javascript. Additionally, numbers are capped at 9e18 to stay comfortably within the boundary of a 64 bit signed integer.

* Try this in the Chrome developer c

@ssadler
ssadler / session.txt
Last active June 1, 2017 16:03
Session buffer (abridged) of running BigchainDB CREATE transaction benchmark.
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-1013-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
0 packages can be updated.
@ssadler
ssadler / test_unspents.py
Created April 21, 2017 11:55
Quick benchmark of time to get unspent transactions
import sys
from bigchaindb.core import Bigchain
from bigchaindb.models import Transaction, Block
from bigchaindb.common.crypto import generate_key_pair
import time
test_size = int(sys.argv[1])
I hereby authorise the spending of output #1 in the following transaction.
{
"asset": {
"id": "e7bf69060ec9c9f814f82455166717044dc8c42decb246144c6825faad59c219"
},
"id": "280a0ba9208298c6e3c76e4b6c3ea5d40bf28a03de4e4a7279ad0d1eb26fde32",
"inputs": [
{
"fulfillment": null,
"fulfills": {
@ssadler
ssadler / all.js
Created January 9, 2017 12:19
ghcjs ccjs minifaction fails
This file has been truncated, but you can view the full file.
var h$currentThread = null;
var h$stack = null;
var h$sp = 0;
var h$initStatic = [];
var h$staticThunks = {};
var h$staticThunksArr = [];
var h$regs = [];
var h$r1 = 0;
var h$r2 = 0;
var h$r3 = 0;
@ssadler
ssadler / object.js
Created January 25, 2016 22:43
purescript export class
"use strict";
// I would like to export a class from Purescript like below.
class MyObjectFromPurescript {
constructor(n) {
this.n = n
}
getN() {
return this.n;
@ssadler
ssadler / wat.js
Last active August 29, 2015 14:06
var nodes = document.querySelectorAll(".js-setLabelWidth");
var elementWidths = [];
var widths = nodes.map(function(node) {
var width = getComputedStyle(node)["width"];
return parseInt(width, 10);
});
var maxWidth = (widths.reduce(Math.max, 0) + 1) / 16;
myReadPixels:: Int -> Int -> Int -> Int -> IO [Pixel]
myReadPixels x y w h = do
let arraySize = w * h * 4
array <- mallocForeignPtrArray arraySize :: IO (ForeignPtr Word8)
let pos = Position (fromIntegral x) (fromIntegral y)
withForeignPtr array $ \ptr -> do
-- fromIntegral is needed because Position and Size store GLints not Ints
readPixels pos
(Size (fromIntegral w) (fromIntegral h))
(PixelData RGBA UnsignedByte ptr)