ART0x1

Learn / GFX Modules.

Introduction

ART0x1 Artworks can be futher modified, extended and animated in the browser, via separate smart contracts called GFX Modules. These interact with the core ART0x1 program at runtime through a simple interface, capable of overriding preset attributes of the artwork as well as injecting JavaScript code into the assembled piece.

Anyone with an Ethereum address may deploy GFX Modules and register them on ART0x1 for collectors to run on their token(s). An optional price, for running a GFX Module on a token for the first time, may also be set by the creator to be automatically forwarded to them (minus a 2% fee) as part of the same transaction.

Running GFX Modules

Registered GFX Modules are queried from Ethereum and listed on the Extend page. To activate a GFX Module on an ART0x1 token, collectors can click the "Run GFX Module" button, select their token id and enter any required inputs as per instructions before confirming the transaction.

A token's active GFX Modules can be overridden or de-activated at anytime.

Developing GFX Modules

Interface

A GFX Module smart contract needs to implement the following runGfxModule function, which will be called from the main ART0x1 program whilst assembling the artwork if a GFX module is activated on a token.

interface IGfxModule { function runGfxModule( bytes[12] memory _instructions, uint _prn, uint _uint, string memory _string ) external view returns (ART0x1Types.TokenGfx memory gfx, string memory script); }

Function Parameters

The following variables are made available to the GFX Module for open-ended, creative interpretation and usage:

ParamTypeDescription
_instructionsBytes ArrayThe token's instructions.
_prnUint 256The token's pseudorandom number.
_uintUint 256Defined by user when activating a GFX Module.
_stringStringDefined by user when activating a GFX Module.

The HypercastleZones GFX Module, for example, uses the _uint parameter to get Terraforms tokenIDs from users in order to retrieve the corresponding color palettes from the Terraforms smart contract.

Return Values

Having performed any desired computation on the Ethereum World Computer in the GFX Module smart contract, the function then returns a gfx struct back to ART0x1 that overrides preset graphic attributes of the artwork, as well as a script string that gets injected into the assembled html piece.

struct TokenGfx { // defaults: string[3] colors; // ["#f4f4f4", "#161616", "#161616"] string fontName; // "IBM Plex Mono" string fontFilename; // "IBMPlexMono-Regular.woff2" string fontSize; // "12px" }

Since the returned struct will override the existing struct in the main ART0x1 program, the GFX Module needs to set all attributes to either their new desired values or back to their preset values.

gfx.colors

An array of three hex color strings. First string is the background color of the artwork, second and third string are the color of ASCII characters contained in the first and second ART0x1 array respectively.

gfx.fontName

The name of the font to be used for all ASCII characters in the artwork. Must be a monospace font.

gfx.fontFilename

The name of the font file to be retrieved from ethfs via IFileStore.getFile() and inlined into the assembled html document using the data URI scheme. If fontName is set to a web safe monospace font, this can be set to an empty string.

gfx.fontSize

The pixel size of the font to be used for all ASCII characters in the artwork. This is configurable to account for different font metrics.

script

A string containing the JavaScript script to be embedded into a script tag in the assembled html piece. Ideally minified and compressed.

Registering GFX Modules

Once a GFX Module smart contract has been deployed, it can be registered with ART0x1 via its listGfxModule function which takes the following parameters:

ParamTypeDescription
_nameStringName of GFX Module to be displayed in token metadata.
_moduleAddressAddressAddress of the deployed GFX Module smart contract.
_priceUint 256Price of running GFX Module on a token for the first time.

When a collector activates a GFX Module, the price amount (minus a 2% fee) will be automatically forwarded to the address that listed the GFX Module within the same transaction.

Testing GFX Modules

It is highly recommended to register and test GFX Modules on the Sepolia testnet deployment before registering them on mainnet.

Table of Contents