Skip to content

Instantly share code, notes, and snippets.

View samcamwilliams's full-sized avatar

Sam Williams samcamwilliams

View GitHub Profile
const Arweave = require('arweave');
const arweave = Arweave.init({ host: 'arweave.net', protocol: 'https', port: 443 });
const fs = require('fs');
const deepHash = require('arweave/node/lib/deepHash');
const ArweaveBundles = require('arweave-bundles');
const deps = {
utils: Arweave.utils,
crypto: Arweave.crypto,
const fs = require('fs')
const Arweave = require('arweave/node')
const argv = require('yargs').argv
const arweave = Arweave.init({
host: argv.arweaveHost ? argv.arweaveHost : 'arweave.net',
port: argv.arweavePort ? argv.arweavePort : 443,
protocol: argv.arweaveProtocol ? argv.arweaveProtocol : 'https'
})
@samcamwilliams
samcamwilliams / Physical-Asset-NFT.js
Created January 8, 2021 03:22
A Verto-compatible SmartWeave contract for trading physical assets.
export function handle (state, action) {
const owner = state.owner
const input = action.input
const caller = action.caller
const contact = action.contact
if (input.function === 'transfer') {
const target = input.target
if (!target || (caller === target)) {
@samcamwilliams
samcamwilliams / CryptoVoxelsArchive.sh
Created November 21, 2020 02:52
Download the state of all land parcels in CryptoVoxels and deploy them to the Arweave's permaweb. Path to your Arweave keyhole must be changed in the `arweave deploy` line.
#!/bin/bash
mkdir -p CryptoVoxelsArchive/parcels
echo "Downloading map info..."
curl -s 'https://www.cryptovoxels.com/api/parcels.json' > CryptoVoxelsArchive/parcels.json
curl -s 'https://www.cryptovoxels.com/api/suburbs.json' > CryptoVoxelsArchive/suburbs.json
curl -s 'https://www.cryptovoxels.com/api/islands.json' > CryptoVoxelsArchive/islands.json
pragma solidity ^0.5.1;
contract EdLock {
address payable honeypot;
uint unlockTime;
uint payoutQty;
uint payoutQtySteal;
address payable[] payoutAddrs;
bool paidOut = false;
@samcamwilliams
samcamwilliams / keyboard_morse
Last active January 1, 2017 20:12
An Erlang script that uses morse code to send messages to @lelandbatey's keyboard.
#!/usr/bin/env escript
%%% USAGE: ./keyboard_morse STRING
%%% Uses morse code to send messages to a keyboard light that flashes
%%% when a web server request is made. See here[1] for details.
%%% This script could be modified to communicate with other kinds of
%%% devices by changing the emit_flash/0 function.
%%%
%%% [1] http://lelandbatey.com/posts/2016/12/Making-lights-blink-for-each-HTTP-request/