Skip to content

Instantly share code, notes, and snippets.

// contract 1
// convenience nameserver
// name -> address
// address -> name
// [name, newOwnerAddress (optional)]
// only one name allowed per address
// newOwnerAddress will only be applicable if the name is already claimed
@wemeetagain
wemeetagain / gist:9457099
Last active May 6, 2019 16:02
topic-grouped lists of addresses with linked id contracts
// convenience nameserver
// name -> address
// address -> name
// [name, newOwnerAddress (optional)]
// only one name allowed per address
// newOwnerAddress will only be applicable if the name is already claimed
// if the name is invalid, stop
if tx.data[0] < 100:
@wemeetagain
wemeetagain / gist:9677553
Created March 21, 2014 01:10
Sample Crowdfunded Employment Contract
// [AMT] - Withdraw AMT from contract
// tracks 'employee' withdrawal time, amount, and contract balance starting at storage[500]
if tx.value < 100 * block.basefee:
stop
if tx.sender == CONTRACT_CREATOR:
// if a withdrawal amount is set, attempt withdrawl
if tx.data[0] > 0:
WITHDRAWAL_LOG_INDEX = contract.storage[499] + 500
LAST_WITHDRAWAL_TIME = contract.storage[WITHDRAWAL_LOG_INDEX]
@wemeetagain
wemeetagain / gist:10010529
Created April 6, 2014 19:33
naive eth-mail
if tx.sender == CONTRACTCREATOR:
if tx.data[0] == 1:
suicide(CONRACTCREATOR)
else:
NEXTINDEX = contract.storage[999]
contract.storage[1000 + NEXTINDEX] = tx.data[0]
contract.storage[999] = NEXTINDEX + 1
@wemeetagain
wemeetagain / gist:10010830
Created April 6, 2014 20:01
naive message board
// data[0] = topic
// data[1] = message
if tx.data[0]:
NEXTINDEX = contract.storage[sha3(tx.data[0])]
contract.storage[sha3(tx.data[0]) + 1 + NEXTINDEX] = tx.data[1]
contract.storage[sha3(tx.data[0])] = NEXTINDEX + 1
@wemeetagain
wemeetagain / gist:10010923
Created April 6, 2014 20:08
basic friend list
if tx.sender != CONTRACTCREATOR:
stop
if tx.data[0] == 0:
contract.storage[1000+tx.value[1]] = tx.value[2]
elif tx.data[0] == 1:
suicide(CONTRACTCREATOR)
Verifying myself: My Bitcoin username is +wemeetagain. https://onename.io/wemeetagain
@wemeetagain
wemeetagain / multi-addr-identity.lll
Created August 6, 2014 04:42
Multi-address Identity Contract
;; multi-addr identity with address voting
;;
;; addresses have 4 commands (transaction types):
;; - vote_add(address,category,permission,lifespan)
;; - tx.data[0]==0
;; - This initiates a vote for `address` to be added to the member list.
;; This only works on addresses with a stored state of none(0) or
;; adding(1). If the vote total for `address` reaches 50% of voting
;; members, `address` is added to the member list. The category,
;; permission, lifespan args are optional once vote has been started.
@wemeetagain
wemeetagain / export-layers-to-pdf.py
Created April 16, 2018 18:04
GIMP plugin - Export Layers to PDF
#!/usr/bin/env python
#
# Author: helour
# Copyright: 2013-2015 helour
# Based on the cr33dog's script Export Layers as PNG (http://registry.gimp.org/node/18440)
# License: GPL v3+
#
# Version: 0.7.1
#
# GIMP plugin to export layers as a multiple pages PDF file
@wemeetagain
wemeetagain / bn_vs_number.js
Last active February 11, 2019 01:44
BN vs number benchmark
const Benchmark = require('benchmark')
const BN = require('bn.js')
const suite = new Benchmark.Suite
let num_a, num_b
let bn_a, bn_b
const randInt = () => Math.floor(Math.random() * 2**24)