Search…
⌃K
Links
💻

Code

Artist requirements

The gm.studio platform supports artwork code created in Processing (the java app) or Javascript (including p5js).

Javascript

Artists should provide a script adhering to the following spec:
  • A single minified js file.
  • We recommend p5.js, but we can also support any non-WebGL based libraries.
  • Your script should contain a standalone function that reads parameters from window.params and draws the artwork in a canvas in the current window.
  • The window params type is described in the code block below.
  • Your script should write the attributes to window.metadata
  • Upon completion your script should set document.complete = true
// window.params type
type ScriptParams = {
seed: string; // a 0x prefixed 256bit seed for the artwork generation
tokenId: number; // the id of the token in the collection
res?: number; // the resolution of the render (width)
}
​
// this will be available on window.params
// for example, access the seed:
doRender(window.params.seed);
​
window.metadata = {
palette: "Olive",
size: "Huge",
...
};
​
...
​
// once rendering is finished
document.complete = true;
Notes:
  • All metadata values should be output as String types.
  • You should tell us the aspect ratio of the output so that we can display the pieces optimally in our gallery.
  • The currently supported version of p5 is 1.4.0

Processing

Artists can also submit Processing code. In order for your script to inter-operate with GMStudio's rendering stack, you are required to include the following code:
// === GMStudio Arguments ===
String outDir;
String seed;
int tokenId;
int res;
// === GMStudio Arguments ===
​
void setup() {
// Initialise GMStudio Arguments //
outDir = args[0];
seed = args[1];
tokenId = int(args[2]);
res = args[3];
​
// ... artist's code here ... //
}
​
void exit() {
// Save rendered image
save(outDir + "/out.png");
​
// Save traits to disk
writeTraits();
​
// let processing carry with it's regular exit routine
super.exit();
}
​
// An example function for storing the NFT traits
void writeTraits() {
JSONObject traits = new JSONObject();
traits.setString("Palette", "Chrome");
saveJSONObject(traits, outDir + "/metadata.json");
}

Code archival

The official on-chain code repository for the gm.studio was deployed to 0x8229e9bc30cb02c2d9af25022bc146a302c48c47. This repository is used to store the code for all on-chain collections and acts as a central database thereof.

Storing in contract bytecode

This step is usually performed by the studio team
  • generate a gzipped tarball of all files
    • tar -czf archive.tar.gz sketch.min.js desc.json
  • get the blob's hex string e.g. by echo "0x"$(hexdump archive.tar.gz -v -e '/1 "%02X"')
  • store blob using repo.store(blob)
    • an event containing the storage address will be emitted during the transaction

Code verification

Please make sure that the stored code matches the one used for rendering the tokens.
The code can be either fetched directly from the contract using the repo.getBlob(collectionAddress) or more conveniently using the tool under gmstudio.art/repo:
  • Connect a wallet (needed to get a connection to the blockchain)
  • Make sure to select the correct collection address
  • Click Download Blob to download the code archive
  • Unpack the archive
Please verify that the stored script is correct e.g. by rerendering the genesis token using the downloaded code.
You can fetch the seed for a given token directly from the collection contract on etherscan:

Code signature

If the stored code is correct, you can proceed to sign your code (this step is optional but we highly encourage to do so).
  • Navigate to gmstudio.art/repo​
  • Connect the wallet that you want to use to sign your code. The wallet will be associated with your code.
  • Make sure to select the correct address of your collection. See also contracts​
  • Click Sign
  • Metamask will pop up and prompt you to sign something - please do so.
    • Even though some of the characters might seem weird, this is totally fine because we are signing the raw binary hash of the repository entry while Metamask tries to interpret it as a string.
  • Please communicate the output appearing below the buttons to the studio team.
// __ __ __
// | \ | \ \
// ______ ______ ____ _______ _| ▓▓_ __ __ ____| ▓▓\▓▓ ______
// / \| \ \ / \ ▓▓ \ | \ | \/ ▓▓ \/ \
// | ▓▓▓▓▓▓\ ▓▓▓▓▓▓\▓▓▓▓\ | ▓▓▓▓▓▓▓\▓▓▓▓▓▓ | ▓▓ | ▓▓ ▓▓▓▓▓▓▓ ▓▓ ▓▓▓▓▓▓\
// | ▓▓ | ▓▓ ▓▓ | ▓▓ | ▓▓ \▓▓ \ | ▓▓ __| ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓ ▓▓ | ▓▓
// | ▓▓__| ▓▓ ▓▓ | ▓▓ | ▓▓__ _\▓▓▓▓▓▓\ | ▓▓| \ ▓▓__/ ▓▓ ▓▓__| ▓▓ ▓▓ ▓▓__/ ▓▓
// \▓▓ ▓▓ ▓▓ | ▓▓ | ▓▓ \ | ▓▓ \▓▓ ▓▓\▓▓ ▓▓\▓▓ ▓▓ ▓▓\▓▓ ▓▓
// _\▓▓▓▓▓▓▓\▓▓ \▓▓ \▓▓\▓▓ \▓▓▓▓▓▓▓ \▓▓▓▓ \▓▓▓▓▓▓ \▓▓▓▓▓▓▓\▓▓ \▓▓▓▓▓▓
// | \__| ▓▓
// \▓▓ ▓▓
// \▓▓▓▓▓▓
//