Skip to main content
Attention: This project is currently in BETA.This means that while we’ve worked hard to ensure its functionality, stability, and security, there may still be bugs, performance issues, or unexpected behavior.
The Python SDK is designed for server-side/backend applications. It handles request signing and provides typed access to the Dfns API. You can find the repository here.

Installation

pip install dfns_sdk

Quick start

1. Read-only operations

For read-only operations (listing wallets, fetching balances, etc.), you only need an auth token:
from dfns_sdk import DfnsClient, DfnsClientConfig

config = DfnsClientConfig(auth_token="your-auth-token")

with DfnsClient(config) as client:
    wallets = client.wallets.list_wallets()
    for wallet in wallets["items"]:
        print(f"{wallet['id']}: {wallet['network']} {wallet['address']}")
For a quick test you can get your login token (short-lived) from the Dfns Dashboard under Settings > Personal Access Tokens.

2. Signing requests

State-changing operations (creating wallets, signing transactions, etc.) require cryptographic request signing. Choose your approach based on where the private key lives:
Use DfnsClient with a KeySigner when your backend has direct access to the private key (e.g., stored in a file or environment variable).This is ideal for service accounts where the private key is securely stored on your server.
from dfns_sdk import DfnsClient, DfnsClientConfig, KeySigner

signer = KeySigner(
    credential_id="cr-...",
    private_key=open("/path/to/private-key.pem").read(),
    app_origin="https://your-app.example.com"
)

config = DfnsClientConfig(
    auth_token="your-auth-token",
    signer=signer
)

with DfnsClient(config) as client:
    wallet = client.wallets.create_wallet({"network": "EthereumSepolia"})
    print(f"Created wallet: {wallet['id']}")

Next steps