Skip to content

feat: contract identicons + SIP draft - #5

Open
friedger wants to merge 1 commit into
feat/demo-noopsfrom
feat/contract-identicon
Open

feat: contract identicons + SIP draft#5
friedger wants to merge 1 commit into
feat/demo-noopsfrom
feat/contract-identicon

Conversation

@friedger

Copy link
Copy Markdown
Member

Stacked on #4. Contract identicons to build user trust: wallets and explorers that implement this spec show the same icon for the same contract source, making known code recognizable at a glance.

SIP draft

sips/sip-xxx-contract-identicons.md — full specification. Pins:

  • Canonical form = output of clarinet fmt (default settings).
  • Hash = SHA-512/256 over UTF-8 bytes (matches Clarity's own sha512/256 so a contract can self-declare its hash on-chain).
  • Renderer = minidenticons with default options, seeded with lowercase hex.

Includes sections on canonicalization assumptions in browser contexts, related work (blockies / jdenticon / sourcify), backwards compatibility (none — off-chain convention), and the optional on-chain self-declaration pattern.

Forum discussion: https://forum.stacks.org/t/identicon-for-contracts/18637

Reference implementation

  • src/utils/contractIdenticon.ts: fetch /v2/contracts/source/{addr}/{name}sha512_256 from @noble/hashes/sha2minidenticonSvg.
  • src/components/ContractIdenticon.tsx: async SVG component with loading fallback + a11y label.
  • Wired into WalletCard.tsx, replacing the generic Wallet lucide icon with the per-contract identicon.

Deps

  • Adds minidenticons (~3 KB).
  • Re-adds @noble/hashes@^2 as a direct dep — the sha2 subpath isn't available via the 1.x version Stacks libs pull in transitively.

Test plan

  • pnpm run build
  • pnpm run dev boots
  • Manual: wallet selector shows distinct icons per wallet; identical contracts (e.g. two deployments of the same standard wallet) show identical icons
  • Network split: mainnet/testnet deployments of the same source render the same icon

🤖 Generated with Claude Code

Add a deterministic visual identifier for deployed Clarity contracts
so users can recognize known code at a glance across wallets,
explorers, and apps.

Pipeline:
  fetch source from /v2/contracts/source
    -> sha512/256 over utf-8 bytes
    -> lowercase hex hash as seed
    -> minidenticonSvg (5x5 symmetric grid)

Draft SIP at sips/sip-xxx-contract-identicons.md pins the canonical
form (output of `clarinet fmt`), hash function, and renderer so the
same source produces the same icon everywhere.

Reference implementation:
- src/utils/contractIdenticon.ts — fetch/hash/render pipeline
- src/components/ContractIdenticon.tsx — async SVG component
- wired into src/components/wallet-selector/WalletCard.tsx,
  replacing the generic Wallet lucide icon with the per-contract
  identicon

Adds minidenticons, re-adds @noble/hashes@2 as a direct dep (sha2
subpath wasn't available transitively from the 1.x that Stacks libs
pull in).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant