Skip to content

Instantly share code, notes, and snippets.

document.getElementById("get-unspents").addEventListener("click", function(event) {
getUnspentOutputs = function(callback) {
xhr("https://www.blockai.com/chain/testnet/addresses/" + address + "/unspents", function(err, res, body) {
var unspentOutputs = JSON.parse(body);
unspentOutputs.forEach(function(utxo) {
utxo.txHash = utxo.hash;
utxo.index = utxo.outputIndex;
});
callback(err, unspentOutputs);
document.getElementById("create-transaction").addEventListener("click", function(event) {
newTx = wallet.createTx(bitstoreDepositAddress, 100000, 1000, address);
newTxJSON = JSON.stringify({
inputCount: newTx.ins.length,
outputCount: newTx.outs.length,
txHash: newTx.getId()
}, null, 4);
document.getElementById("new-tx-json").innerHTML = newTxJSON;
document.getElementById("sign-and-post-transaction").addEventListener("click", function(event) {
signedTx = wallet.signWith(newTx, [address]);
signedTxHex = signedTx.toHex();
xhr({
uri: '/chain/:blockchainType/transactions/send',
method: 'POST',
json: {
transactionHex: signedTxHex
var openpublish = require("openpublish");
document.getElementById("open-publish-file").addEventListener("click", function(event) {
getUnspentOutputs(function(err, unspentOutputs) {
openpublish.register({
file: file,
uri: uri,
address: address,
unspentOutputs: unspentOutputs,
var blockcast = require("blockcast");
document.getElementById("scan-address").addEventListener("click", function(event) {
getTransaction = function(txHash, callback) {
xhr("https://www.blockai.com/chain/testnet/tx/" + txHash, function(err, res, body) {
var rawTx = JSON.parse(body);
var rawOutputs = rawTx.outputs;
var rawInputs = rawTx.inputs;
var outputs = [];
[
"/earth/me/me/kittery-point/03905",
"/earth/me/me",
"/earth/us/me",
"/earth/me/me/kittery",
"/earth/us/me/south-eliot",
"/earth/us/co",
"/earth/us/ca/huntington-beach/92647",
"/earth/us/ca/huntington-beach/92648",
"/earth/us/ca/huntington-beach/92646",
#ifndef MEMORY_MANAGER_H
#define MEMORY_MANAGER_H
#define HEAP_SIZE (10 * 1024 * 1024)
#include <stdlib.h>
typedef struct memory_manager_malloc_t {
void *ptr;
} memory_manager_malloc_t;
@williamcotton
williamcotton / ResultWriter.fsx
Last active May 17, 2024 20:32
A ResultWriter Computation Expression in F#
// Define types
type Result<'T> =
| Success of 'T
| Error of string
type LogState = { Logs: string list }
type ResultLog<'T> = Result<'T> * LogState