Categories
Aesthetics Art Crypto Ethereum Projects

Democratic Palette

palette-spots

Democratic Palette, 2016, Ethereum Contract and HTML/JavaScript/CSS.

A palette of twelve colours that anyone can set on the Ethereum blockchain. Every vote for every colour is tracked and the top twelve make up the palette.

palette-vote

palette-representations

palette-squares

palette-stripes

The images above show various different visual applications of the palette and the use of the GUI to vote for a colour (the GUI appears if you click in the window displaying the canvas).

Note that the above images are from test runs. The current palette on the live Ethereum blockchain looks like this, ready for people to vote on:

live-palette

You can download the interface code here, it’s in the dapps/democratic-palette directory.

To use it you’ll need an Ethereum node running locally, and to vote for colours you’ll need some Ether.

Categories
Art Ethereum Projects

Blank Canvas

Blank Canvas 1

Blank Canvas 2

Blank Canvas 3

Blank Canvas 4

Blank Canvas, 2016, Ethereum Contract and HTML/JavaScript/CSS.

A blank canvas that anyone can set the colour of on the Ethereum blockchain.

The images above show use of the GUI to change the colour (the GUI appears if you click in the window displaying the canvas).

You can download the interface code here, it’s in the dapps/blank-canvas directory.

To use it you’ll need an Ethereum node running locally, and to change the colour you’ll need some Ether.

Categories
Art Crypto Ethereum Projects Uncategorized

“Hot Cold” on Homestead

cold-hot-live

Here’s “Hot Cold” live on the Ethereum “Homestead” network.

“Hot Cold” calls back to Art & Language’s 1960s Conceptual Art involving abstract aesthetic properties. It looks (and is implemented to be) twice as complex as “Is Art“, but it’s still really only one bit of information.

You can run the user interface locally in a web browser with an Ethereum node such as geth. Once geth is running, the user interface can get the contract’s state from the blochchain and, if you have Ether for gas, modify it. If someone else changes the contract’s state, you’ll see this updated.

If you want to change the contract’s status without using the user interface, you can do so using the contract’s address and ABI in EtherWallet.

The address:

0x53cd5d6bebff1eef892c191875e4d963875f50d7

The ABI:

[{"constant":true,"inputs":[],"name":"cold","outputs":[{"name":"","type
":"bytes4"}],"type":"function"},{"constant":false,"inputs":[],"name":"swap","out
puts":[],"type":"function"},{"constant":true,"inputs":[],"name":"hot","outputs":
[{"name":"","type":"bytes4"}],"type":"function"},{"inputs":[],"type":"constructo
r"},{"anonymous":false,"inputs":[{"indexed":false,"name":"hot","type":"bytes4"},
{"indexed":false,"name":"cold","type":"bytes4"}],"name":"Swap","type":"event"}]
Categories
Art Crypto Ethereum Projects Uncategorized

“Is Art” On Homestead

is1

Ethereum has been live for several months now and has progressed to the point where the network has been declared stable.

So I’m deploying my contract artworks to the Ethereum blockchain. First up is “Is Art“.

“Is Art” is an Ethereum contract that can be instructed to nominate itself as art (or not). Whoever toggles the contract’s state as art sets it unimpeded until the next person sends a transaction to change it. A more rational system should be used – bidding, voting, a prediction market. The Duchampian aesthetic transubstantiation of artistic nomination is long played out. It is an art historical found object, as basic as a contract with a single bit of state. Brought together, the art historical and the contemporarily technological (or their audiences) can mutually animate and interrogate each other.

You can run the user interface locally in a web browser with an Ethereum node such as geth. Once geth is running, the user interface can get the contract’s state from the blochchain and, if you have Ether for gas, modify it. If someone else changes the contract’s state, you’ll see this updated.

If you want to change the contract’s status without using the user interface, you can do so using the contract’s address and ABI in EtherWallet.

The address:

0xa95301a50551dfe16e180dec3fe0044e94d36f8c

The ABI:

[{"constant":true,"inputs":[],"name":"is_art","outputs":[{"name":"","ty
pe":"bytes6"}],"type":"function"},{"constant":false,"inputs":[],"name":"toggle",
"outputs":[],"type":"function"},{"inputs":[],"type":"constructor"},{"anonymous":
false,"inputs":[{"indexed":false,"name":"is_art","type":"bytes6"}],"name":"Statu
s","type":"event"}]

For instructions on how to do this, see the “Contracts” pane in EtherWallet.

Categories
Ethereum Projects Uncategorized

Ethereum: Truffle + Meteor

Meteor is the recommended development framework for Ethereum dApps. Truffle is Consensys’ development  system for Ethereum dApps. We cannot currently add a Meteor build phase to Truffle, but we can integrate them easily enough with a script.

Install Meteor, Truffle and testrpc:

curl https://install.meteor.com/ | sh
sudo npm install -g truffle
sudo npm install -g ethereumjs-testrpc

Then create a file called truffle-meteor-build, in ~/bin or somewhere else easily accessible and paste the following into it:

#!/bin/bash

# By Rob Myers <rob@robmyers.org>
# CC0 2016
# To the extent possible under law, the person who associated CC0 with this
# work has waived all copyright and related or neighboring rights to this work.

# We copy the .meteor/ dir from app/ into the specified environment's build/ dir
# then call meteor-build-client in there, building into a meteor/ directory
# next to build/ .

if [ "${1}" = "-h" ] || [ "${1}" = "--help" ]
then
    echo "Usage: truffle-meteor-build [environment]"
    echo "       Copies the .meteor directory from app into the truffle build,"
    echo "       then calls meteor-build-client."
    echo "ARGS:  [environment] - The truffle environment to use (default developmpment)."
    echo "       Make sure you have npm install -g meteor-build-client"
    echo "       and meteor init in the truffle app/ directory."
fi

environment="${1:-development}"
base_dir="$(pwd)"

if [ ! -f "${base_dir}/truffle.json" ]
then
    echo "Please call from within the top level of a Truffle project."
    exit 1
fi

app_dir="${base_dir}/app"
dot_metoer_dir="${app_dir}/.meteor"
environment_dir="${base_dir}/environments/${environment}"
truffle_build_dir="${environment_dir}/build"
meteor_build_dir="${environment_dir}/meteor"

if [ ! -d "${environment_dir}" ]
then
    echo "Cannot find directory for environment ${environment}."
    exit 1
fi

pushd "${base_dir}" > /dev/null
echo "Truffle: building ${environment} in ${truffle_build_dir}"
truffle build "${environment}"
cp -r "${app_dir}/.meteor" "${truffle_build_dir}"
pushd "${truffle_build_dir}" > /dev/null
echo "Meteor: building client in ${meteor_build_dir}"
meteor-build-client "${meteor_build_dir}" -p ''
popd > /dev/null
popd > /dev/null

And make it executable:

chmod +x truffle-meteor build

In one shell window start testrpc:

testrpc

In another shell window create the Truffle/Meteor project:

mkdir truffle-meteor
truffle init
cd truffle-meteor
cd app
rm -rf *
meteor create .
meteor add ethereum:elements

This will create files called app.html, app.js, and app.css . You can rename them to whatever you like. Open truffle-meteor/truffle.json in a text editor and make sure the filenames match those in app/, that the Javascript file has the requisite post-processing commands to add Truffle and the Contract code and that there are no post-process commands for the HTML files.

The results should look similar to this:

{
  "build": {
    "is-art.html": {
      "files": [
        "is-art.html"
      ],
      "post-process": []
    },
    "is-art.js": {
      "files": [
      "is-art.js"
      ],
      "post-process": [
        "bootstrap",
        "frontend-dependencies"
      ]
    },
    "app.css": [
      "is-art.css"
    ],
    "images/": "images/"
  },
  "deploy": [
    "IsArt"
  ],
  "rpc": {
    "host": "localhost",
    "port": 8545
  }
}

Edit the contract, HTML, CSS and JavaScript as needed.

Deploy the contract:

truffle deploy

Then build the meteor project:

truffle-meteor-build

You can now open the Meteor client in a web browser:

chromium environments/development/meteor/index.html

As you continue to develop the project you can reload the Meteor client in the web browser to see your changes. Make sure you keep testrpc running – if you stop and restart it you’ll need to deploy the contracts again.

Categories
Art Ethereum Projects

Ethereum – Art Market

Here is a contract that allows you to register as the owner of a digital artwork contained in a particular file (identified by its cryptographic hash value) at a particular URL. The use of a URL is inspired by the excellent Monegraph, which launched shortly after I started working on Ethereum contracts for art. Monegraph uses the existing NameCoin system, which can be implemented in Ethereum as a two line contract.

This contract is longer than that as it’s recording and managing more information. It also allows you to offer the artwork for sale (in exchange for Ether, Ethereum’s built-in currency), either to a specific individual or generally, or to transfer it to a specific individual without charging them within the contract.

{
 (def 'next-record 0x10)
 (def 'RECORD-SIZE 64)
 ;; Next record position
 ;; This starts one cell above the maximum value of RipeMD
 [[next-record]] 0x10000000000000000000000000000000000000000

 (return
   0x0
   (lll
     {
      ;; Action
      ;; 0 - first cell in message
      [action] (calldataload 0)
      (when (= @action "register")
        {
         ;;TODO: Check correct message length
         ;;TODO: Check digest in range
         ;; Artwork digest
         [digest] (calldataload 32)
         ;; If already registered, don't continue
         (when @@ @digest
           (return "Arwork already registered."))
         ;; Get storage for new record
         [storage] @@next-record
         ;; Store digest
         [[@storage]] @digest
         ;; Artist account
         [storage] (+ @storage 1)
         [[@storage]] (caller)
         ;; Artist resale percentage
         [storage] (+ @storage 1)
         [[@storage]] (calldataload 64)
         ;; Artist is the current owner
         [storage] (+ @storage 1)
         [[@storage]] (caller)
         ;; Skip purchaser and price
         [storage] (+ @storage 3)
         ;; Copy over the url and description
         ;; 96 is 32 x 3 = 3rd cell in message
         [source] 96
         (for [i] 6    (< @i 64)    [i] (+ @i 1)
              {
               [[@storage]] (calldataload @source)
               [storage] (+ @storage 1)
               [source] (+ @source 32)
               })
         ;; Store digest-to-record link
         [[@digest]] @@next-record
         ;; Increment next record position
         [[next-record]] (+ @@next-record RECORD-SIZE)
         })
      (when (= @action "offer")
        {
         ;;TODO: Check correct message length
         ;;TODO: Check digest in range
         ;; Get artwork record storage for digest or stop
         ;; 32 = second cell in message
         [storage] @@(calldataload 32)
         (when (not @storage)
           (return "Artwork not registered."))
         ;; If the caller is the owner
         (when (= @@ (+ @storage 3) (caller))
           {
            ;; Offer subject
            [[(+ @storage 4)]] (calldataload 64)
            ;; Offer price
            [[(+ @storage 5)]] (calldataload 96)
            })
         })
      (when (= @action "accept")
        {
         ;;TODO: Check correct message length
         ;;TODO: Check digest in range
         ;;TODO: Error messages for bad price or buyer
         ;; Get artwork record storage for digest or stop
         ;; 32 = second cell in message
         [storage] @@(calldataload 32)
         (when (not @storage)
           (return "Artwork not registered."))
         [buyer] @@(+ @storage 4)
         [price] @@(+ @storage 5)
         ;; If the caller is the buyer and it's the correct payment
         ;; Or there's no buyer and it's the correct nonzero payment
         (when (|| (&& (= @buyer (caller))
                       (= @price (callvalue)))
                   (&& (= @buyer 0)
                       (> @price 0)))
           {
            ;; For payment
            ;; Ethereum doesn't allow fractional amounts
            ;; Warn users about making prices divisible
            [hundredth] (/ @price 100)
            [arr] @@(+ @storage 2)
            ;; Pay artist
            (call (- (gas) 250) @@(+ @storage 1) (* @hundredth @arr) 0 0 0 0)
            ;; Pay owner
            (call (- (gas) 250) @@(+ @storage 3) (* @hundredth (- 100 @arr)) 0 0 0 0)
            ;; Transfer ownership
            [[(+ @storage 3)]] (caller)
            ;; Clear offer subject and price
            [[(+ @storage 4)]] 0
            [[(+ @storage 5)]] 0
            })
         })
      }
     0x0))}

Here’s the top and the bottom of the main UI (implemented in HTML and JavaScript for the AlethZero Ethereum client).

registry1
registry3
You can enter a URL and get the cryptographic hash for it.

registry2
If the artwork has already been registered, this will show its details.

registry5
Or if not you can register it.

registry4
Once you’ve registered an artwork you are the artist of it and you also own it. You can offer any artwork you own for sale.

registry6
And you can accept a sale offer, paying the specified amount of Ether.

registry7
The UI warns you how much Ether you are about to spend.

registry8
And when you buy an artwork it lets you know when the transfer is complete.

registry9
It’s a market in allographic digital art. In contrast to the existing art market it is entirely public and transparent. And in contrast to many jurisdictions it implements the controversial “Artist’s Resale Right” in a voluntary way (in a way similar to that suggested in “The Social Lives of Artistic Property“). If it’s prohibitively difficult to experiment in the existing art market, we can make new markets for new kinds of art. Like this one.

Categories
Aesthetics Art Art Computing Ethereum Projects

Ethereum – Art Is…

Here is a contract that allows anyone to define what art is. It contains a single set of twelve statements about art. They are encoded as hexadecimal values which are interpreted as sentences in a simple subset of International Art English and displayed by the UI.

{
 ;; Constant values
 ;; Price base (wei), doubled for each definition up to DEFS-COUNT
 (def 'PRICE-BASE 10)
 ;; Add to the index to get the price base exponent
 (def 'PRICE-FACTOR-ADD 10)
 ;; Number of definitions
 (def 'DEFS-COUNT 12)
 ;; Range of values for definitions
 (def 'DEF-MIN 0x1)
 (def 'DEF-MAX 0x0F0F0F0F)

 ;; Storage locations
 (def 'artist 0x10)
 (def 'defs-base 0x100)
 (def 'theorists-base 0x200)

 ;; State
 ;; Contract owner/payee
 [[artist]] (caller)

 (return
   0x0
   (lll
     {
     [action] (calldataload 0)
      (when (= @action "set")
        {
         [index] (calldataload 32)
         [definition] (calldataload 64)
         [price] (exp PRICE-BASE (+ @index 1 PRICE-FACTOR-ADD))
         ;; If the index is in range and the caller paid enough to set it
         (when (&& (>= @definition DEF-MIN)
                   (<= @definition DEF-MAX)
                   (< @index DEFS-COUNT)
                   (= (callvalue) @price))
           {
            ;; Update definition
            [[(+ defs-base @index)]] @definition
            [[(+ theorists-base @index)]] (caller)
            (- (gas) 100) @@artist @price 0 0 0 0
            })
         })
      }
     0x0))
 }

The contract is in lll rather than Serpent this time.

Here’s what the UI looks like.
art_is1
And here’s what it looks like when a statement is being edited.
is_art2
The contract allows the statements to be edited but it costs progressively more to do so: the first costs 10 Wei, the third costs 1000 and so on. This ensures that art theorists place a value on their definition, thereby indicating how confident in and/or serious about their definition they are. The higher the value, the less likely it is to be changed by someone else. This combines art theory with behavioral economics.

Categories
Art Ethereum Projects

Ethereum – This Contract Is Art

Here is a contract that can assert that it is art.

init:
    contract.storage[1000] = "may be"

code:
    if msg.data[0] == "toggle":
        if contract.storage[1000] == "is":
            contract.storage[1000] = "is not"
        else:
            contract.storage[1000] = "is"

It toggles its status as art when sent a message instructing it to do so.

Here’s what the UI for the contract looks like:

is1

Here it is while the artistic state of the contract is being toggled:

is2

And here it is after being toggled:
is3
Anyone can change the contract from not being art to being art (and vice versa). We’ll look at a more advanced contract that uses behavioural economics to address this next.

Categories
Art Art Computing Ethereum Projects

Ethereum – Hot Cold UI

One of the example contracts from “Identity, Ownership and Authenticity” was a conceptual art homage called hot_cold.se . Here’s an updated version:

init:
    contract.storage[1000] = "hot"
    contract.storage[1001] = "cold"

code:
    // Swap
    temp = contract.storage[1000]
    contract.storage[1000] = contract.storage[1001]
    contract.storage[1001] = temp

When it receives a message, it swaps the strings “hot” and “cold” in its memory.

We can access the contract’s memory in AlethZero using JavaScript and build an HTML UI for the contract. Here’s part of the code:

// The hot_cold contract
var contract = "0x84ea345a8c5ca28abee46681ff3a7cee526bb4e4";

// Update the spans with the data from the contact
var fetch = function() {
  document.getElementById("_1000").innerText = eth.storageAt(contract, 1000).bin();
  document.getElementById("_1001").innerText = eth.storageAt(contract, 1001).bin();
};

It fetches the values from the contract’s memory and assigns them to HTML elements. Like so:

hot-cold

Further JavaScript allows you to update the contract’s state (first warning you that doing so costs Ether in the form of Gas for the transaction):

gas

Once the transaction goes through, the JavaScript code is notified of a change to the contract’s state and updates the UI:

cold-hot

There’s only one version of the properties, so if someone else updates the contract you’ll see the results in your UI. And vice versa.

You can find the code in the repository for this series:

https://gitorious.org/robmyers/artworld-ethereum/

hot_cold.se is in the contracts directory, and hot_cold.html in the ui directory.