---
title: Security
description: Best practices for securing Solana programs on Mainnet
---

## Key Management

- **Never expose private keys in frontend code.** Use backend signing, hardware
  wallets, multisignature wallets, or key management services.
- **Separate hot and cold wallets.** Hot wallet for operations, cold for
  treasury.
- **Backup all production keys.** Store encrypted backups in multiple secure
  locations. Losing a key means losing access permanently.
- **Use different keys for devnet and mainnet.** Your devnet keys shouldn't be
  your mainnet keys. Use environment-based configuration to ensure the right
  keys load for each network.

## Signing Infrastructure

For production backend signing, use [Keychain](/docs/tools/keychain)—a unified
signing library that abstracts multiple key management backends through a single
interface: Memory, Vault, Privy, Turnkey, AWS KMS, Fireblocks, GCP KMS, CDP,
Para, Dfns, Crossmint, Openfort, and Utila. This lets you develop locally with
in-memory keys, then swap to production-grade backends without changing
application code.

Not sure which backend fits? See
[Choosing a backend](/docs/tools/keychain/choosing-a-backend). Keychain is
available for both [Rust](https://crates.io/crates/solana-keychain) and
[TypeScript](https://www.npmjs.com/package/@solana/keychain).

## RPC Security

Treat RPC endpoints like API keys—don't expose them in frontend code where they
can be extracted and abused. Use a backend proxy or environment variables that
aren't bundled into client code.

- [QuickNode: Endpoint Security Best Practices](https://www.quicknode.com/guides/quicknode-products/endpoint-security/endpoint-security-best-practices)
- [Helius: Protect Your Solana API Keys: Security Best Practices](https://www.helius.dev/docs/rpc/protect-your-keys)

## Monitoring

Track these metrics in production:

| Metric                   | Why                    |
| ------------------------ | ---------------------- |
| Transaction success rate | Detect issues early    |
| Confirmation latency     | Monitor network health |
| Priority fee spend       | Cost management        |
| RPC error rate           | Provider health        |

Set up alerts for:

- Transfers above threshold from treasury
- Failed transaction rate spikes
- Unusual recipient patterns
- RPC error rate increases

For real-time transaction monitoring at scale, see our
[Indexing Guide](/docs/payments/accept-payments/indexing).

## Verify Addresses

Every token and program has exactly one correct address on mainnet. Spoofed
tokens mimicking USDC or other stablecoins are common—they'll have the same name
and symbol but a different mint. Your application should hardcode or allowlist
the mint addresses (based on your requirements), never accept them dynamically
from untrusted sources.

**Environment-based configuration:** Devnet and Mainnet often use completely
different token mints. Set up your application config to load the correct
addresses per environment—don't hardcode mainnet addresses and forget to swap
them during testing, or worse, ship devnet addresses to production.

Some common stablecoin mints are:

| Token | Issuer | Mint Address                                   |
| ----- | ------ | ---------------------------------------------- |
| USDC  | Circle | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` |
| USDT  | Tether | `Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB` |
| PYUSD | PayPal | `2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo` |
| USDG  | Paxos  | `2u1tszSeqZ3qBWF3uNGPFc8TzMk2tdiwknnRMWGWjGWH` |

Program addresses matter too. Sending instructions to the wrong program will
fail—or worse, result in irreversible loss of funds. The Token Program addresses
are:

| Program            | Address                                       |
| ------------------ | --------------------------------------------- |
| Token Program      | `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA` |
| Token-2022 Program | `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb` |

Allowlisting the right addresses protects against spoofed tokens, but it does
not protect against sending to the wrong _kind_ of account. A recipient address
can be a wallet, a token account, a mint, or a program, and each requires
different handling. Native SOL sent to anything other than a wallet leaves the
sender's control — lost outright for a mint or program, recoverable only by the
account owner for a token account — with no failed transaction to warn the user.

<Callout type="warn" title="Validate recipients before sending">
  Classify every recipient address before signing a transfer. See [Verify
  Address](/docs/payments/send-payments/verify-address) for the full decision
  tree and reference code that distinguishes wallets, token accounts, mints, and
  programs.
</Callout>
