Choose an authentication boundary
- Server-side SDK
- Browser or mobile SDK
Use API-key authentication only in a trusted server runtime:Store the key in a secret manager or a server-only environment variable. Never use a
NEXT_PUBLIC_*, VITE_*, or equivalent client-exposed variable for it.Secure sponsored intents
A valid client session should not automatically authorize unlimited sponsorship. Before your backend callsgetIntentExtensionToken, parse the complete serialized intent, bind it to the authenticated user and account, and enforce a server-side policy for:
- Source and destination chains
- Destination contracts, function selectors, and recipients
- Token addresses and maximum amounts
- Sponsorship categories and limits
- Rate limits and replay behavior
shouldSponsor option provides built-in filters only for destination chain IDs, account addresses, and destination calls. Use those filters as an additional guard, not as complete intent validation.
The extension-token endpoint should validate the complete request against a runtime schema before applying your application policy. This example assumes parseSerializedIntentInput mirrors the full exported SerializedIntentInput type, validates every nested field, and rejects unknown fields:
allowsSources must inspect every source-bearing field your application enables, including account access lists, pre-claim executions, and auxiliary funds. Keep the runtime schema and policy in server-owned code, bind the account to the authenticated session, and consume the rate limit before signing. Deny requests that cannot be parsed or do not match every applicable allowlist. See sponsorship setup and sponsorship policies and security.
Protect each credential
- Rhinestone API keys: create separate production and test keys in the Dashboard, grant only required scopes, rotate them, and revoke suspected leaks.
- JWT signing keys: register only the public key in the Dashboard. Keep the private JWK server-side, use distinct key IDs for rotation, and never return it from an API route.
- Wallet provider secrets: only publish values the provider explicitly labels publishable. Turnkey API private keys, Magic secret keys, and OIDC private keys belong on the server.
- Wallet keys: use provider policy controls or a secret manager. Do not log private keys, recovery material, signatures awaiting submission, or raw authentication tokens.
- RPC, bundler, and paymaster keys: server-side is safest. If a provider permits browser credentials, restrict them by origin, chain, method, and budget.
Validate signing requests
Display or independently validate the chain, recipient, token, amount, and call data before asking a user to sign. Treat provider callbacks and connected-wallet changes as untrusted state: confirm the active address before creating the account and clear cached account objects when the signer changes. For server wallets, authorize every signing request against the application session. Do not expose an endpoint that signs arbitrary hashes or typed data for any authenticated caller. For EIP-7702, verify the delegation target and chain scope before signing an authorization. The EOA remains a root authority after delegation; module-level controls do not make a compromised EOA safe.Operational controls
- Separate production, staging, and development projects and credentials.
- Apply request-size limits, rate limits, abuse detection, and structured audit logs without sensitive payloads.
- Alert on sponsorship spikes, repeated authorization failures, and unexpected destination contracts.
- Rotate a credential immediately after suspected exposure and invalidate active sessions where supported.
- Test recovery and key-rotation procedures before an incident.