Account sharing and Open Graph cards
Account sharing turns an address into a small server-rendered summary for social links. It combines current chain data with optional program provenance, then publishes matching page metadata and a 1200 by 630 PNG card. This page extends account and asset exploration and relates to account details and assets, tokens, and staking.
Share-card model
The share-card model separates data assembly from image layout. A server request returns one of an account card, a program card, or a not-found card; a separate error result means that the data could not be trusted.
Account card data
An account card describes a non-executable account with its address, SOL balance, data size, owner when the owner is not the system program, and recent activity. Activity uses a small signature sample, so the count can be marked as a floor when the sample reaches its limit. A failed activity lookup leaves those fields absent and marks the card incomplete instead of presenting partial data as final.
The account card is cluster-aware. When no cluster is supplied, the data layer uses Mainnet Beta. The selected server cluster controls both the chain lookup and the provenance sources used for program cards.
References: app/…/account-share-data.ts• L5-27 app/…/get-account-share-data.ts• L47-75 app/…/get-account-share-data.ts• L88-115 app/…/constants.ts• L1-8
Program provenance data
A program card adds a readable name, loader-dependent facts, and three provenance markers. Provenance means evidence about how a program is described or published, not a general safety rating. The markers cover an uploaded IDL, a published security.txt, and a verified build.
The marker state is yes, no, or unknown. unknown means that the check failed or cannot be resolved, so the card does not turn missing evidence into a negative claim. Names prefer a known program label, then an IDL name, then a shortened address. Build verification compares a registry record with the current on-chain program hash. It accepts the program authority or a trusted signer under the registry rules, and it can accept a frozen program without an upgrade authority. A missing registry or unavailable hash remains unknown.
The data assembly also adapts to the program loader. Upgradeable programs provide their authority, deploy slot, size, and current hash through program data. Legacy ELF programs use their own bytes for size and hash and are immutable. Other loaders expose only the facts that can be known without making an unsupported claim.
References: app/…/account-share-data.ts• L29-69 app/…/get-account-share-data.ts• L118-153 app/…/get-account-share-data.ts• L158-240 app/…/get-program-provenance.ts• L23-65 app/…/get-program-provenance.ts• L114-137
Missing account data
When the chain has no account record, the share path still returns a useful not-found card. A short history check distinguishes an address with transaction history from one with no known use, while an unavailable history check remains unknown; none of these states claims that an account was closed.
The route treats a missing card differently from a data failure. This lets the image route render a clear absence message while returning an upstream error when the account data itself could not be loaded.
References: app/…/account-share-data.ts• L71-76 app/…/get-account-share-data.ts• L42-43 app/…/get-account-share-data.ts• L243-291 app/…/BaseAccountImage.tsx• L49-67
Open Graph routes
Account sharing has two linked public surfaces: the address page carries metadata, and the account image route renders the preview image. URL helpers build both surfaces from the same address and cluster rules so a social client sees the same network in the page and image.
Account page metadata
The address page publishes the canonical page URL, the account image URL, image dimensions, and page text. Mainnet omits the cluster query; supported non-mainnet clusters appear in both the page URL and image URL. Twitter reuses the same image URL and requests a large image card.
Custom clusters do not use the server image route because the server cannot safely use a visitor-owned RPC endpoint. They receive text metadata instead of a server-generated account image.
References: app/…/open-graph.ts• L6-26 app/…/page.tsx• L16-47
Account image route
/og/account/[address] validates the address and accepts only the canonical cluster query. It resolves the share data, loads the visual assets, renders a PNG, and returns cache headers that match the certainty of the data. A complete resolved card has a longer cache life; not-found and incomplete cards use a short cache so later chain or provenance changes can appear.
The route keeps validation, data failure, and render failure distinct. Invalid input returns a client error, a failed data result returns a bad-upstream response, and a rendering failure returns a server error. This prevents a missing record or a temporary lookup problem from being mistaken for a successful resolved card.
References: app/…/route.tsx• L26-63 app/…/route.tsx• L65-89 app/…/route.spec.ts• L37-116
Image composition
The account image is a fixed social card built from already formatted share data. It keeps the address visible in every meaningful state and changes the body and footer to match the account, program, or not-found meaning.
Account and program cards
An account card shows the Explorer identity, balance, shortened address, activity summary, data size, and executable state. A program card shows its name and address, provenance markers, upgrade authority when known, last deployed slot, and program size when available. A program loader can make some facts unavailable, so the card omits them rather than guessing.
The three program markers use neutral text for unknown, positive text for confirmed evidence, and alert text only for a confirmed negative build result. This keeps visual emphasis aligned with the strength of the underlying evidence.
References: app/…/BaseAccountImage.tsx• L75-119 app/…/BaseAccountImage.tsx• L189-237 app/…/BaseAccountImage.tsx• L240-310 app/…/BaseAccountImage.tsx• L373-411
Not-found and fallback cards
A not-found card uses an amber state pill and explains whether the address has history, has never been used, or could not be checked. If no card data reaches the renderer, the image uses a neutral Explorer message that points the viewer to the account details page instead of showing an empty preview.
References: app/…/BaseAccountImage.tsx• L49-67 app/…/BaseAccountImage.tsx• L434-479
Reusable visual helpers
Shared helpers keep local assets and rendering contracts stable across server-side Open Graph images. The account feature exposes its data loader, glow loader, and base image through a server-only entry point, while image dimensions and fonts are shared by the wider Open Graph system.
Fonts and image dimensions
The image route uses Rubik for general text and Roboto Mono for address-like values. The font loader reads the requested local weights, caches each file per server instance, and clears a failed read so a later request can retry. IMAGE_SIZE gives metadata and rendered images one 1200 by 630 contract.
References: app/…/fonts.ts• L4-29 app/…/fonts.ts• L35-68 app/…/image-size.ts• L1-13 app/…/route.tsx• L8-14
Glow and marker assets
Account cards use a green raster glow for resolved data and an amber raster glow for not-found data. The glow loader converts local PNG files to data URIs because the image renderer cannot resolve relative URLs, then shares one cached load across requests. Marker icons provide the small filled symbols for build, IDL, and security evidence without depending on a browser icon system.
References: app/…/og-glows.ts• L6-22 app/…/og-glows.ts• L29-57 app/…/BaseAccountImage.tsx• L69-77 app/…/marker-icons.tsx• L1-9 app/…/marker-icons.tsx• L27-31
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the cluster query emitted by open-graph.ts identical to the query accepted by the account image route. A metadata URL that the route rejects breaks social unfurls.
- Keep
AccountShareDatastates aligned with the image variants and cache policy. Not-found and incomplete cards must not receive the long resolved cache lifetime. - Keep provenance
unknownseparate fromno. A failed IDL, security, or registry lookup must not become a negative marker. - Keep verified-build checks tied to the current on-chain bytes and the selected cluster registry. A stale or foreign hash must not produce a positive marker.
- Keep immutable-program checks tied to either a frozen registry entry or a trusted signer. An absent authority alone must not verify a mutable program.
- Keep the server image path out of custom-cluster metadata. The server must not fetch from a caller-controlled RPC endpoint.
- Keep image dimensions, font weights, and local glow assets valid for the Satori image renderer. A visual asset failure affects the whole PNG response.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Activity or provenance lookup fails | The card can show incomplete or unknown facts | Mark the card incomplete and use the short cache; keep unknown markers neutral |
| The registry hash does not match current program bytes | A stale build could appear verified | Compare the current hash with a valid authority or trusted-signer record |
| A mutable program has no authority but matches a registry entry | An unverifiable build could appear verified | Require the authority or a trusted signer; allow no-authority verification only for frozen programs |
| A custom cluster reaches the account image route | The server could be directed to an untrusted RPC host | Reject custom clusters before server-side image data assembly |
| Metadata and image URLs use different cluster rules | A preview can describe a different network from its page | Build both URLs through the shared address Open Graph helpers |
| A not-found result is cached as resolved | A later account creation remains hidden from social clients | Use the short cache for not-found cards |
| A glow or font cannot load | The image renderer cannot produce the intended PNG | Use retryable cached asset loaders and return a render error when loading still fails |
Key files
| File | Why to read it |
|---|---|
| app/…/get-account-share-data.ts | Defines the account, program, and not-found data assembly path. |
| app/…/get-program-provenance.ts | Defines provenance signals and verified-build evidence states. |
| app/…/account-share-data.ts | Defines the small data contract consumed by the image. |
| app/…/open-graph.ts | Defines canonical account page and image URLs. |
| app/…/page.tsx | Connects address-page metadata to account sharing. |
| app/…/route.tsx | Defines route validation, rendering, and cache behavior. |
| app/…/BaseAccountImage.tsx | Defines the visible account, program, and not-found card layouts. |
| app/…/og-glows.ts | Loads and caches account-state background assets. |
| app/…/fonts.ts | Provides local fonts for generated Open Graph images. |
| app/…/image-size.ts | Defines the shared Open Graph image dimensions. |