# Build on the first ABX stamp

> ABX Stamps, by Art Blocks. The first stamp says thank you for six years of Art Blocks: six blocks for six years, each stamp arranged a little differently, drawn entirely on-chain from its own seed on Base. Claim one free at https://stamps.abx.io/. The art is CC0, and every contract and line of source is open, so you can build on it.

## Start here

- **No code.** Every stamp page (https://stamps.abx.io/stamps/0) has PNG and SVG downloads. Print it, frame it, make a sticker.
- **With a coding agent.** `npm i -g @artblocks/abx-cli && abx skill install`, then point your agent at this page. Build on Base Sepolia first (free test ETH), where you can claim a stamp of your own. Deploying a renderer and a collection like the reference below took about 2.2M gas, which is cents on Base.
- **If you are an agent:** read Your idea before you pitch; the idea comes from your person, not from this page. Build on testnet, from the reference contract. ABX's own overview: https://abx.io/llms.txt.

## Your idea

The best remix is one only you would make: something you care about, joined to what a stamp can do.

**If you are an agent**, find the idea with your person:

1. **Start with them, not this page.** Use what you already know about them. If that isn't enough, ask one or two open questions in one message, such as what they make or care about, and who it's for. If they'd rather you just pick, still start from them: with their OK, look at what their wallet holds and has made, or at the work in front of you.
2. **Pitch two or three ideas that join their answers to the stamps**, unlike each other, with at least one that acts, not only displays. There are no finished examples here on purpose. Every agent's first ideas are the same few (a wall holders sign, a stamp that changes with the clock, a mosaic of every stamp), so skip those unless they fit this person exactly. If an idea would suit anyone equally well, find the part only they would make.
3. **Keep pitches short:** what it is, why it's theirs, and a rough effort (an afternoon, a weekend, a project). Scope a big idea down rather than swapping it for a safe one.
4. **Let them pick, combine, or redirect**, then build it, on testnet first.

## What a stamp can do

A stamp is a soulbound, one-per-wallet record that someone showed up, and any contract can read it. ABX objects can act, not only display: a mint, transfer, burn, or setting change can call other contracts in the same transaction, and if any step reverts, the whole action rolls back. The building blocks:

- **The art is data.** Each stamp has a seed and six blocks you can read, and the generator draws the art from any seed (see Draw the art). It's CC0.
- **Each stamp records who and when.** Stamp numbers run in claim order, and `Stamped` events and the HTTP API carry who claimed and when.
- **A stamp is a key.** Gate anything on `balanceOf(holder) > 0` (holds one now) or `claimedToken(collection, holder)` (ever claimed). Stamps can't be transferred, so nobody can borrow one.
- **Holders can write to a token.** Use PostParams: `--schema 'ink:HexColor:TokenOwner'` at deploy, holders write with `abx configure-param`, and your renderer reads `tokenParam(id, key)`. `TokenOwner` follows the token, so make yours soulbound (a transfer hook that refuses transfers) if only a stamp's holder should write. To give each stamp holder one, use the holder-only mint below.
- **A token can show live chain state.** A Solidity renderer reads chain state each time the token is viewed; a JavaScript piece gets it through an augment hook (`abx set-param-hooks --augment`). Nothing is stored, so every view is current.
- **Objects can act.** A configure hook runs when a holder sets a value; a transfer hook runs on every mint, transfer, and burn and can refuse it. Either can call other contracts, for example to mint from another collection or move tokens a holder approved. See https://docs.abx.io/docs/using-abx/guides/custom-mechanics and https://docs.abx.io/docs/using-abx/guides/ecosystem-integrations.
- **Many stamps can be drawn together.** Loop `layout` over the stamps. Reads are free but capped (see Draw the art): a plain Solidity composite measured about 9M gas for 103 stamps and 80M for 500, while a stamp's own `tokenURI` is 3M to 6M, so draw about fifty in the token and page the rest.
- **The art can leave the screen.** The SVG prints at any size (its type is IBM Plex Mono, a free font), and every stamp page has a 2400 px PNG.
- **Not everything is a contract.** Events and the HTTP API (see Read a stamp) are enough for an app, a bot, or a tool, and ABX FS stores a site on chain (https://docs.abx.io/docs/using-abx/guides/utilities).

## Build it

You don't need JavaScript. The stamp is SVG computed in Solidity, and a remix can be too: a field renderer (`IAbxFieldRenderer`) that calls the stamp contracts and returns an image and traits. Marketplaces then read both straight from `tokenURI`, with nothing to host or re-render.

**Reference: Stamp Echo** (https://stamps.abx.io/remix/StampEcho.sol, MIT). Echo No. N redraws stamp No. N as a color-field poster, live from chain. It's here for the mechanics, not the look: under 100 lines, no storage, no owner, so copy it and change everything. Live on Base Sepolia: renderer `0x2f9b391E392967c54d67A758E635587ecC2Ba693` ([explorer](https://sepolia.basescan.org/address/0x2f9b391E392967c54d67A758E635587ecC2Ba693#code)), collection `0xFACfe8702EDa29e4e8aE08ca4873075DD3827F1f` ([explorer](https://sepolia.basescan.org/address/0xFACfe8702EDa29e4e8aE08ca4873075DD3827F1f)). To start from it:

```sh
export ABX_CHAIN=base-sepolia
abx scaffold solidity stamp-remix && cd stamp-remix    # a Foundry workspace with ABX's interfaces and templates
forge soldeer install                                   # fetch solady + forge-std
mkdir -p src/stamps src/examples
for f in IStamps IStampsGenerator IAnniversaryGenerator; do curl -s "https://stamps.abx.io/remix/$f.sol" -o src/stamps/$f.sol; done
curl -s "https://stamps.abx.io/remix/StampEcho.sol" -o src/examples/StampEcho.sol
curl -s "https://stamps.abx.io/remix/StampEcho.t.sol" -o test/StampEcho.t.sol
forge test --match-contract StampEcho    # forks Base Sepolia and renders real stamps; nothing is sent
abx deploy-contract --artifact out/StampEcho.sol/StampEcho.json --dry-run \
  --constructor-args $(cast abi-encode "c(address,address,address)" 0xe732e489152a2f009772f9C5258c7fC66176CAa1 0x3f27bDe8C5F82b90CA2c70c3014762B66607Cb15 0x0bfEe8A29792337Ac10EEe75Db88c0328AeB3360)
abx deploy-code --image-renderer <echo> --attributes-renderer <echo> --onchain-uri --no-seed \
  --name "Stamp Echo" --symbol ECHO --max 1000 --mint-count 6 --royalty-bps 0 --dry-run    # premints echoes 0 to 5
```

Things to know:

- Run `abx help <command>` before each command and `--dry-run` before sending; help is the source of truth. `deploy-code` defaults to a 5% royalty, 16 tokens, and a deferred mint, so set `--royalty-bps`, `--max`, and `--mint-count` on purpose.
- A field renderer must never revert, including for the collection-level call (`tokenId = type(uint256).max`). `seedOf` reverts for unclaimed ids, so wrap it in `try` the way Stamp Echo does.
- A hook is a plain external function that anyone can call, so a hook that changes state must check that `msg.sender` is your collection. The hook interfaces are in the scaffold: `abx-contracts/src/extensions/configurable-params/IAbxParamHooks.sol`.
- The addresses are constructor arguments, so moving from testnet to mainnet is a redeploy with the mainnet addresses from this page.
- **Holder-only mint.** A custom minter checks `claimedToken` or `ownerOf`, calls the collection's `mint(to)`, then records which stamp it answered with `configureTokenParam(tokenId, "stamp", bytes32(stampId))`. The minter has to be that param's writer, so it comes first. `abx predict --for <your deployer> --factory 0xEAB8a19fEada0DDba2FDE324715eBbB6234B5616` prints a salt only you can use and the collection's address; pass `--factory`, because without it predict answers for ABX's 1/1 factory, a different address. Deploy the minter with that address, then `abx deploy-code … --salt <salt> --schema 'stamp:Uint256Range:Address(<minter>)' --minter <minter> --unpaused`, and check that its dry run prints the same address. If you also wire hooks, leave out `--unpaused`, run `abx set-param-hooks`, then `abx unpause`.
- **A JavaScript piece** (`deploy-code --script`) suits live or animated work. Its marketplace image is a separate still: render it with ABX's effects runner (`abx effects` locally, `abx deploy-effects` hosted) or set one with `abx set-field --field image`. The script runtime is documented at https://docs.abx.io/docs/protocol/code-projects, and https://stamps.abx.io/remix/anniversary.js is the stamp generator as one dependency-free file.
- Docs for agents: https://docs.abx.io/llms.txt.

## Draw the art

A whole stamp is one call: `StampsRenderer.stampSvg(collection, id)` returns its SVG, and the collection's `tokenURI(id)` wraps the same SVG in metadata. To reuse the artwork itself, start from the stamp's seed (`seedOf`):

```solidity
(string memory svg, bool lucky) = IStampsGenerator(generator).art(uint256(seed), "#2c2c2a", "#FFFDF9", 2120, 1400);
```

- That call reproduces a square stamp's artwork byte for byte. Units are tenths of a pixel: 2120 × 1400 is the 212 × 140 px art area (1520 wide on a tall stamp). It returns one `<g transform="scale(0.1)">…</g>`.
- **Keep that size and scale the result.** Which block holds the squiggle, and the fills, depend on block sizes, so another size can re-roll the composition instead of resizing it.
- `layout(seed, 2120, 1400)` returns `Block[6]`, each `(x, y, w, h, fill)`, where fill is 0 Solid, 1 Hatch, 2 Dots, 3 Lines, 4 Outline, 5 Squiggle (https://stamps.abx.io/remix/IAnniversaryGenerator.sol).
- Execution gas, measured on Base Sepolia: `layout` about 21k, `art` about 0.6M, `stampSvg` about 1M, and a stamp's whole `tokenURI` 3M to 6M depending on the stamp (a Stamp Echo `tokenURI` is about 0.6M). Reads are free but capped per call: Base's public RPC allows 600M gas, publicnode 50M, and marketplaces don't publish their caps, so keep anything a marketplace reads near a stamp's own. To compose many stamps, loop `layout`, not `stampSvg`.
- The rules, in brief: three columns, each split once, make six blocks; one holds the Art Blocks squiggle, and 1 in 16 stamps print it in blue (`#0000FF`). Every choice is `keccak256(abi.encode(seed, drawIndex)) % range` in whole numbers; the details are in `AnniversaryGenerator.sol`.

## Reference

### Testnet reference (Base Sepolia, chain id 84532)

The real design, with 100+ stamps. **Claim one yourself**, one per wallet, paying the gas in test ETH, so you can try a holder-gated build with a real wallet:

```sh
cast send 0x3580b00e5594DfA58EC1325fc5Cf3B7802E560B8 "claim(address)" <your wallet> --rpc-url https://sepolia.base.org --private-key <a funded test key>
```

That's the tap ([source](https://repo.sourcify.dev/84532/0x3580b00e5594DfA58EC1325fc5Cf3B7802E560B8)). In tests, fork instead (`anvil --fork-url https://base-sepolia-rpc.publicnode.com`, or `vm.createSelectFork`) and impersonate `ownerOf(n)`.

- **Stamp collection** `0xe732e489152a2f009772f9C5258c7fC66176CAa1` ([explorer](https://sepolia.basescan.org/address/0xe732e489152a2f009772f9C5258c7fC66176CAa1), [source](https://repo.sourcify.dev/84532/0xe732e489152a2f009772f9C5258c7fC66176CAa1)). ERC-721, an ABX SeriesCode clone. Token id = stamp number. Soulbound; only the holder can burn.
- **StampsFactory** `0x54fB964D6977Bcb6ef23f536aFF77F31B682be83` ([explorer](https://sepolia.basescan.org/address/0x54fB964D6977Bcb6ef23f536aFF77F31B682be83), [source](https://repo.sourcify.dev/84532/0x54fB964D6977Bcb6ef23f536aFF77F31B682be83)). Prints stamps, one per wallet. `claimedToken(collection, holder)` returns (claimed, tokenId) and stays true after a burn. Emits `Stamped(collection, tokenId, to, seed)`. Deployed at block 63221917.
- **StampsRenderer** `0x3f27bDe8C5F82b90CA2c70c3014762B66607Cb15` ([explorer](https://sepolia.basescan.org/address/0x3f27bDe8C5F82b90CA2c70c3014762B66607Cb15), [source](https://repo.sourcify.dev/84532/0x3f27bDe8C5F82b90CA2c70c3014762B66607Cb15)). `seedOf(collection, id)` (reverts if unclaimed), `isLucky(collection, id)`, `stampSvg(collection, id)` → bytes.
- **AnniversaryGenerator** `0x0bfEe8A29792337Ac10EEe75Db88c0328AeB3360` ([explorer](https://sepolia.basescan.org/address/0x0bfEe8A29792337Ac10EEe75Db88c0328AeB3360), [source](https://repo.sourcify.dev/84532/0x0bfEe8A29792337Ac10EEe75Db88c0328AeB3360)). The artwork alone, from any seed: `art`, `layout`, `isLucky(seed)`.

### On Base (chain id 8453)

- **Stamp collection** `0x2EFfb886f87619A56a422DE63Ca963AC91DEcfFA` ([explorer](https://basescan.org/address/0x2EFfb886f87619A56a422DE63Ca963AC91DEcfFA), [source](https://repo.sourcify.dev/8453/0x2EFfb886f87619A56a422DE63Ca963AC91DEcfFA)). ERC-721, an ABX SeriesCode clone. Token id = stamp number. Soulbound; only the holder can burn.
- **StampsFactory** `0x5672Bc5454212c30DEB84aBB2bb31BC28E633BfB` ([explorer](https://basescan.org/address/0x5672Bc5454212c30DEB84aBB2bb31BC28E633BfB), [source](https://repo.sourcify.dev/8453/0x5672Bc5454212c30DEB84aBB2bb31BC28E633BfB)). Prints stamps, one per wallet. `claimedToken(collection, holder)` returns (claimed, tokenId) and stays true after a burn. Emits `Stamped(collection, tokenId, to, seed)`. Deployed at block 62286578.
- **StampsRenderer** `0x181d206DdFb58563f137B48d103AC09cfc8237eD` ([explorer](https://basescan.org/address/0x181d206DdFb58563f137B48d103AC09cfc8237eD), [source](https://repo.sourcify.dev/8453/0x181d206DdFb58563f137B48d103AC09cfc8237eD)). `seedOf(collection, id)` (reverts if unclaimed), `isLucky(collection, id)`, `stampSvg(collection, id)` → bytes.
- **AnniversaryGenerator** `0xa175eA1391371fC866a7a4C197a006442fD625AD` ([explorer](https://basescan.org/address/0xa175eA1391371fC866a7a4C197a006442fD625AD), [source](https://repo.sourcify.dev/8453/0xa175eA1391371fC866a7a4C197a006442fD625AD)). The artwork alone, from any seed: `art`, `layout`, `isLucky(seed)`.

Fixed forever: the art rules, each stamp's seed, its metadata (every field locked), and the soulbound rule. Only the off-chain links (`external_url`, `external_link`) can change.

### Read a stamp

- `tokenURI(id)` returns base64 JSON: `name`, `description`, `image` (an SVG data URI), `external_url`, and `attributes` (Distributor, Stamp, Ink, Lucky draw, Stamp number).
- Seed: `StampsRenderer.seedOf(collection, id)`, or `tokenParam(id, "seed")` on the collection. It's a bytes32; the generator takes it as a uint256.
- Every stamp: ids 0 to `nextTokenId() - 1`, or `Stamped` events from the factory's deploy block. https://mainnet.base.org caps `eth_getLogs` at 200 blocks; https://base-rpc.publicnode.com allows 50,000 blocks per call and suits forks.
- HTTP for this site's collection, CORS open and cached: `GET https://stamps.abx.io/api/stamps?page=1&per=100` lists `number`, `seed`, `lucky`, `owner`, and `claimedAt` (`per` up to 200). `GET https://stamps.abx.io/api/stamps/{number}` returns one; add `format=svg` or `format=png` for the image.

```sh
RPC=https://mainnet.base.org
cast call 0x2EFfb886f87619A56a422DE63Ca963AC91DEcfFA "nextTokenId()(uint256)" --rpc-url $RPC
cast call 0x181d206DdFb58563f137B48d103AC09cfc8237eD "stampSvg(address,uint256)(bytes)" 0x2EFfb886f87619A56a422DE63Ca963AC91DEcfFA 0 --rpc-url $RPC | cast to-ascii > stamp-0.svg
```

### Source

Identical to the deployed contracts (solc 0.8.28, optimizer 200 runs, `abx-contracts` 3.0.0), at https://stamps.abx.io/remix/{file}. The Base Sepolia factory predates one later change: the collection's CC0 `license` field.

- Interfaces: `IStamps.sol` (factory and renderer), `IStampsGenerator.sol`, `IAnniversaryGenerator.sol` (adds `layout`). ABIs: `abi.json`.
- Contracts: `StampsFactory.sol`, `StampsRenderer.sol`, `StampsArt.sol`, `AnniversaryGenerator.sol`, `StampsSoulbound.sol`, and the reference remix `StampEcho.sol` with its fork test `StampEcho.t.sol`.
- Off-chain twins that match the chain byte for byte: `anniversary.js` (the art, no dependencies), `anniversaryGenerator.ts`, and `render.ts` (the whole stamp). Test vectors: `anniversary-vectors.json`, `stamp-vectors.json`.

## Notes

- The stamp art is CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/): copy it, remix it, sell what you make, no permission needed. The contracts are LGPL-3.0; Stamp Echo is MIT.
- CC0 doesn't cover trademarks. The Art Blocks name and squiggle are Art Blocks trademarks, so don't present a remix as made or endorsed by Art Blocks. Credit is welcome, not required: "after ABX Stamps by Art Blocks", linking https://stamps.abx.io.
- Use of the site is subject to the Art Blocks User Terms (https://www.artblocks.io/user-terms.pdf) and Privacy Policy (https://www.artblocks.io/privacy-policy.pdf).
