Scaffolding Art Blocks Projects
Always Fetch the Generator Spec First
Before any art script work, fetch this MCP resource:
CODEBLOCK0
It contains the authoritative reference for: tokenData structure, hash-based PRNG patterns, FLEX dependency types (IPFS, Arweave, ONCHAIN, Dependency Registry), supported script types and library versions, HTML structure requirements, and window.$features. It also includes the step-by-step conversion guide for porting existing scripts.
Scaffolding a New Project
Use scaffold_artblocks_project to generate a ready-to-run index.html + starter art script.
Parameters
| Param | Options / Notes |
|---|
| INLINECODE4 | INLINECODE5 (vanilla), "p5js", "threejs" — required |
| INLINECODE8 |
p5.js:
"1.0.0" or
"1.9.0" (default). Three.js:
"0.124.0",
"0.160.0",
"0.167.0" (default). Ignored for
"js". |
|
includePostParams |
true — adds ONCHAIN/PostParams (PMP) stubs in
tokenData and example usage |
|
includeFlexDependencies|
true — adds IPFS and Arweave dependency stubs with usage patterns |
|
includeFeatures |
true — adds
window.$features trait assignment stub |
Note on Three.js v0.167.0: uses ES module import maps instead of a global <script> tag. This affects script type detection on-chain — see the generator spec for details.
Other supported script types
INLINECODE24 covers vanilla JS, p5.js, and Three.js. Art Blocks supports many more via the on-chain dependency registry: regl, Tone.js, Babylon.js, A-Frame, Paper.js, Zdog, Processing, and custom types. See artblocks://generator-spec for the full list and how to reference them.
Converting an Existing Script
When a user has an existing piece to convert to Art Blocks format:
- 1. Fetch
artblocks://generator-spec — it contains a detailed step-by-step conversion guide - Use
scaffold_artblocks_project with the matching scriptType to get the correct HTML shell - Walk through conversion:
Conversion checklist:
- - Replace
Math.random() with hash-based PRNG derived from INLINECODE30 - Replace hardcoded canvas dimensions with
window.innerWidth / INLINECODE32 - Ensure the initial render is deterministic from the hash alone — same hash must always produce the same initial visual output
- Interactive elements (mouse, keyboard, touch) are allowed and encouraged, but must not change the initial render. Interaction should only modify the view after the artwork has loaded deterministically.
- Remove any time-based variation (
Date.now(), setTimeout) that affects the initial render (time-based animation after load is fine) - Extract visual traits into
window.$features (optional but recommended for reveals) — features must be set synchronously before or during initial render - Verify determinism: reload the page with the same
tokenData.hash and confirm identical initial output
When to Enable Each Flag
| Flag | Enable when... |
|---|
| INLINECODE37 | Script has distinct visual categories worth exposing as traits |
| INLINECODE38 |
Script will have configurable on-chain parameters after minting (PMP) |
|
includeFlexDependencies| Script loads external assets from IPFS or Arweave |
脚手架化艺术区块项目
始终优先获取生成器规范
在进行任何艺术脚本工作之前,请先获取此MCP资源:
artblocks://generator-spec
它包含以下内容的权威参考:tokenData结构、基于哈希的PRNG模式、FLEX依赖类型(IPFS、Arweave、ONCHAIN、依赖注册表)、支持的脚本类型和库版本、HTML结构要求以及window.$features。它还包含用于移植现有脚本的逐步转换指南。
脚手架化新项目
使用scaffoldartblocksproject生成一个可直接运行的index.html + 初始艺术脚本。
参数
| 参数 | 选项/说明 |
|---|
| scriptType | js(原生)、p5js、threejs — 必填 |
| dependencyVersion |
p5.js:1.0.0 或 1.9.0(默认)。Three.js:0.124.0、0.160.0、0.167.0(默认)。js类型时忽略。 |
| includePostParams | true — 在tokenData中添加ONCHAIN/PostParams(PMP)存根及示例用法 |
| includeFlexDependencies| true — 添加IPFS和Arweave依赖存根及使用模式 |
| includeFeatures | true — 添加window.$features特征赋值存根 |
关于Three.js v0.167.0的说明:使用ES模块导入映射而非全局