Skip to main content

x402 micropayment extension for the Digital Evidence Depository SDK

Reason this release was yanked:

bug found in signing operation

Project description

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

from constellation_digital_evidence_sdk_x402 import (
    DedX402Client,
    X402Config,
    GenerateOptions,
)

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="evt-001",
        document_id="contract-2024-001",
        document_content="This is my document content",
        include_metadata=True,
        tags={"department": "legal"},
    ))

    # Submit (x402 payment handled automatically)
    results = await client.fingerprints.submit([submission])

    # Public endpoints (free, no payment)
    detail = await client.fingerprints.get_by_hash(hash_value)
    proof = await client.fingerprints.get_proof(hash_value)
    stats = await client.fingerprints.get_stats()

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=30000,               # Request timeout in ms (default: 30000)
))

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}")
    # Re-submit with auto_pay=True, or sign manually
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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file constellation_digital_evidence_sdk_x402-0.1.0.tar.gz.

File metadata

File hashes

Hashes for constellation_digital_evidence_sdk_x402-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a229acdcc7f14489a582bdf52e51b638991d62a7505aa651696fe08b6d5b68b1
MD5 b0f4b251f33004a3f60471985606e86b
BLAKE2b-256 73dea99830a4ecb70976ac384c97036f92217851cba0cf424c2c46d5ae06edcb

See more details on using hashes here.

Provenance

The following attestation bundles were made for constellation_digital_evidence_sdk_x402-0.1.0.tar.gz:

Publisher: publish-py-x402.yml on Constellation-Labs/digital-evidence-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file constellation_digital_evidence_sdk_x402-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for constellation_digital_evidence_sdk_x402-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73abe6cf99d72d1d7edf6ae513e4dd3d4ca95c073ab51e3a88cfdeafe2b34fd4
MD5 37393c7009bcf1a95428ac98706a08ad
BLAKE2b-256 6358b8c7b1b8abf333d6993f845acd375b55a45f56a18334384bc328c37245c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for constellation_digital_evidence_sdk_x402-0.1.0-py3-none-any.whl:

Publisher: publish-py-x402.yml on Constellation-Labs/digital-evidence-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page