> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://docs-sepolia.modularium.art/api/mcp` to find what you need.

# `$mod` API

`mod.js` gives a [generative artwork](/generative/guide) its token's mint data, seeded randomness, and a way to set the token's name, description and traits. Load it before your own scripts:

```html
<script src="https://sepolia.modularium.art/mod.js"></script>
```

When you upload the artwork, Modularium replaces that tag with a pinned copy, so a token always renders with the `mod.js` it was uploaded with. Its source ships in the `@modularium-art/sdk` package, at `mod/mod.js`.

## URL parameters

`mod.js` reads the mint data from the page's URL. Every token's `animation_url` is your artwork with these parameters:

| Parameter | Value |
| --- | --- |
| `tokenId` | Token number |
| `recipient` | Minting wallet address |
| `blockNumber` | Mint block number |
| `blockHash` | Mint block hash, `0x` + 64 hex digits |
| `seedSalt` | The collection's address, as `0x` + 64 hex digits |

Any parameter missing from the URL gets a random value, so a page with none is a new random token on every load.

## Mint data

```js
$mod.mint.tokenId        // token number
$mod.mint.recipient      // minting wallet address
$mod.mint.blockNumber    // mint block number
$mod.mint.blockHash      // mint block hash (hex)
$mod.mint.seedSalt       // the collection address (hex)
$mod.mint.generationData // {} for generative drops
```

## Randomness: `$mod.prng`

Seeded from a hash of `tokenId`, `blockHash` and `seedSalt`, so neighbouring tokens minted in the same block still get unrelated streams. The mint block's hash isn't known until the block is made, so nobody can choose the token they mint.

```js
$mod.prng.random()               // float in [0, 1)
$mod.prng.randomRange(min, max)  // float in [min, max); randomRange(max) = [0, max)
$mod.prng.randomInt(min, max)    // integer in [min, max); randomInt(max) = [0, max)
$mod.prng.randomChoice(array)    // random element
$mod.prng.shuffle(array)         // shuffled copy
$mod.prng.seed                   // the seed (number)
$mod.prng.seedP5(sketch)         // re-seed p5; done for you before preload()/setup()
```

## Token metadata: `$mod.token`

```js
$mod.token.setName("Ladder #7")              // optional; overrides the token name
$mod.token.setDescription("…")               // optional; overrides the token description
$mod.token.setAttribute("Palette", "warm")   // replaces an attribute with the same name
$mod.token.setAttributes({ Palette: "warm", Rungs: 12 }) // replaces all attributes
```

Attribute values can be strings, whole numbers or booleans. Other numbers are stored as strings.

## Preview: `$mod.preview`

```js
$mod.preview.capture()     // the drawing is done: snapshot the first <canvas> as the preview, now
$mod.preview.isCaptured()
```

See [Capture the preview](/generative/guide#5-capture-the-preview) for what gets captured.
