Feed account is only as fresh as its submitter keeps it. This guide shows how to keep one current with the SDK: subscribe, request rounds, submit them, and scale to many sources. Reading a feed needs no subscription; producing one does.
1. Subscribe
The snippets on this page usesdk from Initialize. Skip this step if the wallet already has a subscription, for example from the backend quickstart: a second subscribe fails.
maxPriceUsdc is a safety bound: the transaction aborts if the on-chain price is higher than you approved.
2. Derive sourceId
Source identity is deterministic. No separate creation transaction is sent.
sourceId is the keccak256 hash of the canonical apiConfig. The Solana Feed account is keyed by (sourceId, signaturesRequired, submitter), and the first successful submit creates it if it does not exist.
For numeric values that move between fetches, use tolerance mode.
3. Request and submit
requestAndSubmit runs these two calls:
requestAndSubmit throws SubmitFailedError. The round is already paid for, so submit error.result again with sdk.solana.submitAttestation instead of requesting a new round.
Constraints
- Subscription must be active.
- Requested quorum must be within the subscription’s signer limit.
- A consumer other than the owner must be an active delegate.
- The gateway response must carry the
sourceIdderived fromapiConfig; the SDK rejects a result that does not. - A submitted update must have a strictly newer
timestampthan the one stored in theFeedaccount.
Fast repeated rounds
For repeated updates, cache registry selection config and nodes:Several attestations in one transaction
sdk.solana.submitAttestations(attestations) submits several attestations of one feed (same sourceId and signaturesRequired, distinct timestamps) in one transaction, applied oldest first. The transaction is atomic. When the attestations do not fit, it throws BatchTooLargeError before sending; error.fits is how many do. See Batch submit.
Many sources at once
requestMany requests a list of sources and, by default, submits each attestation to Solana:
- The registry inputs are read once and shared by every request.
- Gateway concurrency is bounded. It halves when the gateway answers busy (HTTP 503 or 429) and grows back while requests succeed. Set the ceiling with
concurrency. spreadMsspreads request starts over a window by a hash of eachsourceId. The default is0, no spreading.submit: falseskips the Solana submit.submitConcurrencybounds submits in flight (default 8).- Results are returned in input order, and a source that fails does not stop the others. A failed submit keeps the signed
attestationon the result and setssubmitError.
Next steps
Read a feed
Consume the feed from TypeScript or your own program.
Gateway client
Retries, private APIs and paywalled sources.
Subscriptions
Plans, quota and delegates.