Installation
Install the base package, plus one extra per backend that needs a provider dependency: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 asynccreate_<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:
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 optionalhttp_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 theSolanaSigner ABC (pubkey, sign_message,
is_available) plus exactly one capability class:
TransactionSigner:sign_transaction(tx)signs your transaction in place and returns aSignedTransaction. 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 returnedSignedTransaction.transaction.SendingSigner:sign_and_send_transaction(tx)signs and broadcasts through the provider and returns theSignatureof the transaction that landed. Your transaction is never mutated.
| Backend | Capability class | sign_message |
|---|---|---|
| memory, vault, privy, turnkey, aws-kms, fireblocks, gcp-kms, dfns, para, openfort | TransactionSigner | Yes |
| cdp | TransactionSigner | UTF-8 payloads only, else SERIALIZATION_ERROR |
| utila | TransactionSigner | Raises SIGNING_FAILED |
fordefi black box (FordefiBlackBoxSigner) | TransactionSigner | Yes |
fordefi native manual (FordefiNativeManualSigner) | ModifyingSigner | Yes |
fordefi native auto (FordefiNativeAutoSigner) | SendingSigner | Yes |
| crossmint | SendingSigner | Raises SIGNING_FAILED |
isinstance. All capability classes are exported from the package
root:
Initialization
Thecreate_* 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:
HashiCorp Vault
The key must be an ed25519 key in the transit engine. The address must use HTTPS: a plain-HTTP address raisesSignerErrorCode.CONFIG_ERROR, even on
loopback, so a local vault server -dev doesn’t work.
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 anEC_SIGN_ED25519 key. client optionally takes a
pre-built KeyManagementServiceAsyncClient:
Privy
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
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 bychain and
push_mode. create_fordefi_signer picks the class, each class rejects a
config meant for another, and all three sign messages:
| Mode | Config | Class | Method |
|---|---|---|---|
| Black box | chain unset | FordefiBlackBoxSigner | sign_transaction |
| Native auto | chain set, push_mode unset or "auto" | FordefiNativeAutoSigner | sign_and_send_transaction |
| Native manual | chain set, push_mode="manual" | FordefiNativeManualSigner | modify_and_sign_transaction |
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:
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.
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):
CONFIG_ERROR, and a
transaction still missing signatures after signing raises SIGNING_FAILED.
Error Handling
Every failure is aSignerError 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_idis set when the create was accepted, andidempotency_keycarries 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 withtransaction_signatureset to the completed transaction’s signature. - Fireblocks raises it only if a poll shows Fireblocks broadcast a
use_program_calltransaction despite it being sent sign-only.
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.