Skip to main content

constellation-digital-evidence-sdk-x402

PyPI CI License

x402 micropayment extension for the Digital Evidence Depository SDK. Pay-per-request fingerprint submission using USDC on Base via an Ethereum wallet — no API key required.

For full documentation including payment control, custom signers, and pricing, see the x402 Payments guide.

Install

pip install constellation-digital-evidence-sdk-x402

This installs the base SDK (constellation-digital-evidence-sdk) and eth-account for EIP-712 signing.

Quick start

import asyncio
import uuid

from constellation_digital_evidence_sdk_x402 import (
    DedX402Client,
    X402Config,
    GenerateOptions,
)


async def main():
    async with DedX402Client(X402Config(
            base_url="https://de-api.constellationnetwork.io",
            wallet_private_key="0x...",   # Ethereum key (for x402 payments)
            signing_private_key="...",    # DAG/SECP256K1 key (for fingerprint signing)
    )) as client:
        # Generate a fingerprint — org_id and tenant_id are auto-derived from wallet
        submission = client.generate_fingerprint(GenerateOptions(
            org_id="",
            tenant_id="",
            event_id=str(uuid.uuid4()),
            document_id="contract-2024-001",
            document_content="This is my document content",
            include_metadata=True,
            tags={"department": "legal"},
        ))

        print("Submission:", submission)

        # Submit (x402 payment handled automatically)
        results = await client.fingerprints.submit([submission])
        print("Results:", results)

        # Public endpoints (free, no payment)
        hash_value = results.data[0]["hash"]
        detail = await client.fingerprints.get_by_hash(hash_value)
        print("Detail:", detail)
        stats = await client.fingerprints.get_stats()
        print("Stats:", stats)
        # proof = await client.fingerprints.get_proof(hash_value)  # available after batch commit

asyncio.run(main())

How it works

The client uses the x402 protocol to handle payments transparently. When the API responds with 402 Payment Required, the client signs an EIP-3009 TransferWithAuthorization using your Ethereum wallet and retries the request with the payment header attached.

Organization and tenant IDs are deterministically derived from your wallet address (UUID v5), so no prior registration is needed.

Configuration

from constellation_digital_evidence_sdk_x402 import DedX402Client, X402Config

client = DedX402Client(X402Config(
    base_url="https://de-api.constellationnetwork.io",
    wallet_private_key="0x...",  # Ethereum key for x402 payments
    signing_private_key="...",   # DAG/SECP256K1 key for fingerprint signing (optional)
    auto_pay=True,               # Auto-pay on 402 responses (default: True)
    timeout=30.0,                # Request timeout in seconds (default: 30.0)
))

When auto_pay=False, paid endpoints return a PaymentRequired result instead of paying automatically, allowing caller-driven payment flows:

result = await client.fingerprints.submit([submission])

if result.kind == "payment_required":
    offer = result.payment.accepts[0]
    print(f"Cost: {offer.amount} atomic USDC on {offer.network}")
    print(f"Pay to: {offer.pay_to}")

    # Sign an EIP-3009 TransferWithAuthorization for the offer
    # (see x402 payments guide for full signing details)
    payment_header = sign_x402_payment(wallet_private_key, offer)  # base64-encoded

    # Retry the request with the signed payment header
    async with httpx.AsyncClient() as http:
        response = await http.post(
            f"{base_url}/v1/fingerprints",
            headers={
                "Content-Type": "application/json",
                "X-PAYMENT": payment_header,
            },
            content=json.dumps([submission.to_dict()]),
        )
    print("Submitted:", response.json())

elif result.kind == "result":
    print(f"Submitted: {result.data}")

Custom signer

Implement the X402Signer protocol to use hardware wallets, KMS, or other backends:

from constellation_digital_evidence_sdk_x402 import X402Signer, DedX402Client, X402Config

class MyKmsSigner:
    @property
    def address(self) -> str:
        return "0x..."

    async def sign_typed_data(self, domain, types, message) -> str:
        return await my_kms.sign_eip712(domain, types, message)

client = DedX402Client(
    X402Config(base_url="...", wallet_private_key=""),
    signer=MyKmsSigner(),
)

API

Client

Property / Method Description
client.fingerprints Fingerprint API (submit, search, upload)
client.batches Batch status API
client.generate_fingerprint(opts) Generate a signed fingerprint (requires signing_private_key)
client.org_id Deterministic org UUID from wallet
client.tenant_id Deterministic tenant UUID from wallet
client.wallet_address Ethereum wallet address

Fingerprints

Method Payment Description
submit(submissions) Paid Submit fingerprints for notarization
submit_in_batches(submissions, batch_size, delay_ms) Paid Submit in batches (separate payment per batch)
upload(submissions, documents) Paid Upload fingerprints with documents (multipart)
search(params) Paid Search fingerprints with filtering and pagination
get_by_hash(hash) Public Get fingerprint detail by hash
get_proof(hash) Public Get Merkle inclusion proof
get_latest(limit, status) Public Get latest fingerprints
get_stats() Public Get platform-wide statistics

Development

python3 -m venv .venv
.venv/bin/pip install -e "../python[network]" -e ".[dev]"
.venv/bin/pytest tests/ -v

License

Apache-2.0

Metadata

Release files for constellation-digital-evidence-sdk-x402 0.1.1

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

Source distribution (sdist)

Source distribution for constellation-digital-evidence-sdk-x402 0.1.1
File Size Uploaded Provenance Actions
constellation_digital_evidence_sdk_x402-0.1.1.tar.gz 16.2 kB With provenance Details for constellation_digital_evidence_sdk_x402-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for constellation-digital-evidence-sdk-x402 0.1.1
File Interpreter ABI Platform Actions
constellation_digital_evidence_sdk_x402-0.1.1-py3-none-any.whl Python 3 none any Details for constellation_digital_evidence_sdk_x402-0.1.1-py3-none-any.whl

Total release size: 29.9 kB

Release files / constellation_digital_evidence_sdk_x402-0.1.1.tar.gz

Download URL constellation_digital_evidence_sdk_x402-0.1.1.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a8d775bcc36631f2aa9c54282cd42c628f4d5969a46822d97a8e95a1ebcab4b6
BLAKE2b-256 checksum
How to use checksums
9dbc935e7717f00d3903c4370c5851019cac6b04c3599b4caf89c0e472ee5521
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Apr 2, 2026.

Transparency log

Release files / constellation_digital_evidence_sdk_x402-0.1.1-py3-none-any.whl

Download URL constellation_digital_evidence_sdk_x402-0.1.1-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30ed2ce4bcf16332edab47f6cf8401423c106bca9b68a0dbb0ed720655de0c5c
BLAKE2b-256 checksum
How to use checksums
901e564f8364a2648a3f69dce629fb723517f58992092f09e9edbfc96299fb47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Apr 2, 2026.

Transparency log

Security for constellation-digital-evidence-sdk-x402 0.1.1

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 constellation_digital_evidence_sdk_x402-0.1.1.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 Apr 2, 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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

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