Feral File
operation
For Feral File generative artworks, it injects pre-defined variables then the collector click to view the software artwork in in frame. This helps artists be able to make variants to their artworks. The variables are:
blockchain
- (bitmark | ethereum | tezos)contract
- contract address if any. empty for bitmarktoken_id
- a unique id of a token in the blockchain. It is hex in bitmark and decimal in tezos and ethereumartwork_number
- the artwork number of a series starts from 1??token_id_hash
- the sha256 hash of a token ID.edition_number
- the edition number of an index starts from zero (legacy only)By the design of token contract, it requires a unique id for each tokens. However, in our exhibition structure, we have multiple series and each series would have its own artwork with a same index starts from 0. This brings duplication of token IDs to a contract if we simply use the index as token ID. To avoid confliction, we create a function to generate deterministic unique token id by combining series id and token indexes.
It is the sha256 hash of a token ID. The value of the hash is 32 bytes and represented in hex. Here is an example of the hash
which is a 64-length hex string and is prefixed with 0x
.
To provide randomness to generative artworks, we create a snippet to offer a random function based on sfc32. The function takes token_id_hash
(defined above) as the seed of the randomness. This ensures that the randomness is deterministic. If the token_id_hash
is not given, the snippet will create a random hash so we can test loacally.
We use sfc32 in our random function. sfc stands for "Small Fast Counter". It runs very fast in JS. It is part of PractRand random number testing suite.
After you load the snippet, simply call ffrand
to get a random number.
If you would like to design the randomness by yourself, please ensure the random value is deterministic by a given token_id_hash
. Otherwise, the artwork would be different by each page reloads.
With this parameters from FF, we come up with a library that can get provenance from our indexer. Thus, for software artwork developer's, they can create artwork variants by integrating this library.
Learning from fxhash, this library is designed to be a simple snippet script (library) that can be put on the top of generative artworks.
In this snippet script, we only use XHR(XMLHttpRequest). It is because the library does not require any other third-party libraries. This minimize the dependencies of artworks for artists.
Here lists supported functions
Attach the script in HEAD. And call to ffinit
on page loaded.
In your script, you are able to get these events:
Example:
To provide function tracking artwork attributes, we create a snippet to offer a $feralfile
namespace and 2 functions $feralfile.features(array_of_attributes)
to input artwork attributes and $feralfile.getFeatures()
to get saved attributes based on artwork information
After you load the snippet, simply call $feralfile.features()
to set attributes.