Skip to content
Version 2.0 is the first stable release of the Python package. The 2.0 migration guide covers the signing shapes it shares with Rust and TypeScript.

​Installation

Install the base package, plus one extra per backend that needs a provider dependency:
Requires Python 3.10 or later. Transactions are solders VersionedTransaction objects; legacy, v0, and v1 messages are all accepted, except by Fireblocks with use_program_call=True, which accepts legacy and v0 only. Memory, Vault, and Para are importable from the package root. Every other backend is imported from its own submodule (for example solana_keychain.aws_kms), and importing one without its extra raises an ImportError naming the extra to install. Ledger is Rust-only.

​Basic Usage

Every backend has a config dataclass and an async create_<backend>_signer factory that returns a ready-to-use signer. All signing methods are coroutines:
sign_transaction returns a SignedTransaction with encoded_transaction, signature, is_complete, and transaction. transaction is the authoritative signed transaction: continue from it, especially with a modifying signer, whose result is a different object from the one you passed in.

​Unified Factory

create_keychain_signer takes a backend name and that backend’s config dataclass, and imports the backend lazily, so only the extras you use need to be installed:
The names are listed in SUPPORTED_BACKENDS: aws-kms, cdp, crossmint, dfns, fireblocks, fordefi, gcp-kms, memory, openfort, para, privy, turnkey, utila, and vault. An unknown name, or a config of the wrong class, raises SignerError with SignerErrorCode.CONFIG_ERROR. The factory is typed as returning the base SolanaSigner, so narrow it with isinstance before signing (see Signer Capabilities).

​Remote HTTP Clients

Remote HTTP backends accept an optional http_client (an httpx.AsyncClient) for custom TLS or proxies. When it is unset, each request uses a one-shot client with a 60 second timeout, HTTPS enforced on the base URL, and redirects rejected.

​Signer Capabilities

Every backend subclasses the SolanaSigner ABC (pubkey, sign_message, is_available) plus exactly one capability class:
  • TransactionSigner: sign_transaction(tx) signs your transaction in place and returns a SignedTransaction. You broadcast it.
  • ModifyingSigner: modify_and_sign_transaction(tx) lets the provider rewrite the transaction, then signs it without broadcasting. Your object is left untouched; continue from the returned SignedTransaction.transaction.
  • SendingSigner: sign_and_send_transaction(tx) signs and broadcasts through the provider and returns the Signature of the transaction that landed. Your transaction is never mutated.
BackendCapability classsign_message
memory, vault, privy, turnkey, aws-kms, fireblocks, gcp-kms, dfns, para, openfortTransactionSignerYes
cdpTransactionSignerUTF-8 payloads only, else SERIALIZATION_ERROR
utilaTransactionSignerRaises SIGNING_FAILED
fordefi black box (FordefiBlackBoxSigner)TransactionSignerYes
fordefi native manual (FordefiNativeManualSigner)ModifyingSignerYes
fordefi native auto (FordefiNativeAutoSigner)SendingSignerYes
crossmintSendingSignerRaises SIGNING_FAILED
Narrow with isinstance. All capability classes are exported from the package root:

​Initialization

The create_* factories and create_keychain_signer do any required setup for you. If you construct the Privy, Fireblocks, Dfns, Crossmint, Para, Openfort, or Utila signer class directly, await signer.init() before use. Until then, pubkey and every signing call raise SignerErrorCode.NOT_INITIALIZED.

​Backend Configuration

​Memory

Build from a Solana CLI keypair file, a base58 or "[1,2,...]" string, raw bytes, or a solders Keypair:
The key lives in process memory, and Python cannot zeroize it. Use this backend for development and testing.

​HashiCorp Vault

The key must be an ed25519 key in the transit engine. The address must use HTTPS: a plain-HTTP address raises SignerErrorCode.CONFIG_ERROR, even on loopback, so a local vault server -dev doesn’t work.
For local development, run vault server -dev-tls instead. It serves HTTPS on 127.0.0.1:8200 with a self-signed certificate and prints the CA file path as VAULT_CACERT. Pass an httpx client that trusts that CA:

​AWS KMS

key_id is a key ID, ARN, or alias for an ECC_NIST_EDWARDS25519 key. Pass a pre-built boto3 KMS client for custom credentials or endpoints; region is then ignored:

​GCP KMS

The key version must be an EC_SIGN_ED25519 key. client optionally takes a pre-built KeyManagementServiceAsyncClient:

​Privy

Wallets protected by an authorization key take a PrivyAuthorizationConfig as authorization_context.

​Turnkey

​Fireblocks

use_program_call=True signs with the PROGRAM_CALL operation instead of RAW. It is sent sign-only, so Fireblocks neither rewrites nor broadcasts the transaction, and you broadcast as usual. It requires a hot wallet and must be enabled for your workspace by Fireblocks.

​CDP (Coinbase Developer Platform)

​Crossmint

Crossmint is sending-only. Its API always executes an approved transaction server-side and sponsors gas, so CrossmintSigner is a SendingSigner and sign_message raises SIGNING_FAILED. The returned signature identifies the transaction Crossmint landed, which may differ from yours. Setting signer_secret (an xmsk1_... delegated-signer secret) approves transactions automatically, which delegates the choice of what gets approved to Crossmint.

​Dfns

​Openfort

​Para

​Utila

Utila signs transactions only; sign_message raises SIGNING_FAILED.

​Fordefi

Fordefi has three signing modes, fixed at construction by chain and push_mode. create_fordefi_signer picks the class, each class rejects a config meant for another, and all three sign messages:
ModeConfigClassMethod
Black boxchain unsetFordefiBlackBoxSignersign_transaction
Native autochain set, push_mode unset or "auto"FordefiNativeAutoSignersign_and_send_transaction
Native manualchain set, push_mode="manual"FordefiNativeManualSignermodify_and_sign_transaction
API requests are authenticated with an ECDSA P-256 request signature: supply the key as private_key_pem, or keep it in a KMS/HSM by passing a FordefiRequestSigner subclass as request_signer. Native auto mode: set chain ("solana_devnet" or "solana_mainnet"), and Fordefi may replace the blockhash and fees, then signs and broadcasts the transaction itself. It accepts only an unsigned transaction whose sole required signer is the vault. fee is passed through to Fordefi verbatim:
Native manual mode: set chain and push_mode="manual". Fordefi rewrites the message (recent blockhash, Compute Budget fee instructions) and signs it, but does not broadcast. The returned transaction replaces the one you submitted, so always continue from result.transaction. Fordefi must be the fee payer and must sign before any other required signer: a transaction that already carries signatures is accepted, but the rewrite voids them. The rewrite is not diffed, so inspect the result before broadcasting, and broadcast promptly, since Fordefi does not return the new blockhash’s expiry height.
Broadcast the inspected transaction as in Sign and Send, and reconcile before retrying if the send fails. Black box mode: omit chain. Fordefi signs your exact message bytes and does not broadcast. Use this with a Fordefi black box vault.

​Sign and Send

sign_and_send_transaction gets a transaction onchain whatever the signer’s shape. A SendingSigner broadcasts through its provider and your send function is never called. A TransactionSigner or ModifyingSigner signs, and your send function broadcasts the base64-encoded result (the package has no RPC client):
A signing-only signer with no send function raises CONFIG_ERROR, and a transaction still missing signatures after signing raises SIGNING_FAILED.

​Error Handling

Every failure is a SignerError with a stable code from SignerErrorCode: BROADCAST_UNCONFIRMED, CONFIG_ERROR, EXPECTED_SOLANA_SIGNER, HTTP_ERROR, INVALID_PRIVATE_KEY, INVALID_PUBLIC_KEY, IO_ERROR, NOT_AVAILABLE, NOT_INITIALIZED, OTHER, PARSING_ERROR, REMOTE_API_ERROR, SERIALIZATION_ERROR, and SIGNING_FAILED. Match on code, not the message: str() and repr() carry only a fixed generic message, never key material or raw provider responses. status_code and provider_error_code are set when the failure came from a provider response. SignerErrorCode.BROADCAST_UNCONFIRMED ("SIGNER_BROADCAST_UNCONFIRMED") means the transaction may have landed:
  • On Crossmint and Fordefi native auto, provider_transaction_id is set when the create was accepted, and idempotency_key carries the key derived from the message that the create went out under. Resending the byte-identical transaction is safe; a rebuilt one (for example with a new blockhash) is a new transfer.
  • From sign_and_send_transaction, a failing send function raises it with transaction_signature set to the completed transaction’s signature.
  • Fireblocks raises it only if a poll shows Fireblocks broadcast a use_program_call transaction despite it being sent sign-only.
A cancelled call re-raises asyncio.CancelledError, which carries no fields. To recover an id the provider accepted before the cancellation, pass a PendingTransactionId() (from solana_keychain.core) as the Crossmint or Fordefi native auto config’s pending_transaction_id, and read .get() after the cancellation. Reconcile with the provider before retrying. Keychain validates the signing hop, not what the transaction does: a provider-returned signature is ed25519-verified against the locally computed message before it is attached. Python cannot zeroize key buffers, so with local-key backends (Memory, and the API keys and PEMs held in remote backend configs) treat the whole process memory as sensitive. See the security model for what each signing shape guarantees.

​Adding Custom Signers

Subclass the one capability class your backend matches (TransactionSigner, ModifyingSigner, or SendingSigner) from solana_keychain.core. See the Adding Signers guide to integrate additional key management services.

​Resources