Skip to main content

Dfns Python SDK

Auto-generated Python SDK for the Dfns API.

Installation

pip install dfns_sdk

Or install from source:

pip install -e .

Quick Start

from dfns_sdk import DfnsClient, DfnsClientConfig

# Configure the client
config = DfnsClientConfig(
    auth_token="your-auth-token",
    base_url="https://api.dfns.io",  # Optional, this is the default
)

# Create the client
client = DfnsClient(config)

# Use the client
wallets = client.wallets.list_wallets()
print(wallets)

# Clean up
client.close()

Using as a Context Manager

from dfns_sdk import DfnsClient, DfnsClientConfig

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

with DfnsClient(config) as client:
    wallets = client.wallets.list_wallets()
    print(wallets)

User Action Signing

Some operations (like creating wallets or signing transactions) require user action signing. Configure a signer to enable these operations:

from dfns_sdk import DfnsClient, DfnsClientConfig, KeySigner

# Load your private key
with open("private_key.pem") as f:
    private_key = f.read()

# Create a signer
signer = KeySigner(
    credential_id="cr-xxx-xxx",  # Your credential ID
    private_key=private_key,
    app_origin="https://app.dfns.io",
)

# Configure the client with the signer
config = DfnsClientConfig(
    auth_token="your-auth-token",
    signer=signer,
)

with DfnsClient(config) as client:
    # Operations requiring signatures will automatically sign
    wallet = client.wallets.create_wallet({
        "network": "EthereumSepolia",
    })
    print(wallet)

Delegated Client (External Signing)

For service accounts that orchestrate signing externally (e.g., using a separate signing service), use the DfnsDelegatedClient. This client separates user action signing into *_init() and *_complete() method pairs:

from dfns_sdk import DfnsDelegatedClient, DfnsDelegatedClientConfig

# Configure the delegated client (no signer needed)
config = DfnsDelegatedClientConfig(
    auth_token="service-account-token",
)

with DfnsDelegatedClient(config) as client:
    # Step 1: Initialize the action (returns challenge)
    challenge = client.wallets.create_wallet_init(
        body={"network": "EthereumSepolia"}
    )

    # Step 2: Sign challenge externally (your signing system)
    # The challenge contains everything needed to sign:
    # - challenge["challenge"]: The challenge string to sign
    # - challenge["challengeIdentifier"]: Unique ID for this challenge
    signed_assertion = your_external_signer.sign(challenge)

    # Step 3: Complete the action with signed challenge
    wallet = client.wallets.create_wallet_complete(
        body={"network": "EthereumSepolia"},
        signed_challenge={
            "challengeIdentifier": challenge["challengeIdentifier"],
            "firstFactor": signed_assertion,
        },
    )
    print(wallet)

When to Use Delegated vs Regular Client

Use Case Client Type
Single application with embedded signing DfnsClient
Mobile app with local key storage DfnsClient
Backend service with external HSM DfnsDelegatedClient
Multi-step approval workflows DfnsDelegatedClient
Service account orchestrating user actions DfnsDelegatedClient

Available Domains

The client provides access to the following API domains:

  • client.auth - Authentication and user management
  • client.wallets - Wallet operations
  • client.policies - Policy management
  • client.permissions - Permission management
  • client.webhooks - Webhook subscriptions
  • And more...

Each domain provides typed methods for all available API endpoints.

Error Handling

from dfns_sdk import DfnsClient, DfnsClientConfig, DfnsError

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

try:
    wallet = client.wallets.get_wallet(wallet_id="invalid-id")
except DfnsError as e:
    print(f"Error: {e.message}")
    print(f"Status: {e.status_code}")
    print(f"Code: {e.error_code}")

License

MIT License - See LICENSE file for details.

Metadata

Release files for dfns-sdk 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dfns-sdk 0.0.4
File Size Uploaded Provenance
dfns_sdk-0.0.4.tar.gz 81.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dfns-sdk 0.0.4
File Interpreter ABI Platform
dfns_sdk-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 199.3 kB

Release files / dfns_sdk-0.0.4.tar.gz

Download URL dfns_sdk-0.0.4.tar.gz
Size 81.3 kB
Tags Source
SHA-256 checksum
How to use checksums
14f9921531978480c2add3cff260b82da8d9accfe91165e38c3ae20fa76a7630
BLAKE2b-256 checksum
How to use checksums
eb6d30bcc7a492e075cfca8bf6b41d78dd010d935b3e73cbb268bfdc4c860e11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release files / dfns_sdk-0.0.4-py3-none-any.whl

Download URL dfns_sdk-0.0.4-py3-none-any.whl
Size 118.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
427758d6a5df6aeb157a587452810bfd3a050fba86662c8151195772113e20b0
BLAKE2b-256 checksum
How to use checksums
d49216ff1be6358ffbb81a2a2c506e0b750911be158d02c674bfeee3c318d632
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Security for dfns-sdk 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dfns_sdk-0.0.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page