feat: contract identicons + SIP draft - #5
Open
friedger wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:clarinet fmt(default settings).sha512/256so a contract can self-declare its hash on-chain).minidenticonswith 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_256from@noble/hashes/sha2→minidenticonSvg.src/components/ContractIdenticon.tsx: async SVG component with loading fallback + a11y label.WalletCard.tsx, replacing the genericWalletlucide icon with the per-contract identicon.Deps
minidenticons(~3 KB).@noble/hashes@^2as a direct dep — thesha2subpath isn't available via the 1.x version Stacks libs pull in transitively.Test plan
pnpm run buildpnpm run devboots🤖 Generated with Claude Code