Sulkta Coop's Python SDK for merchant-side Cardano payments + NFT certificate-of-authenticity minting. Zero-custody by design. Extracted from TradeCraft's services/cardano_*.py (2,400+ lines of production Cardano-mainnet code) and restructured as an installable Python package. Package layout (cardano_checkout/): - addresses.py — lifted verbatim: CIP-1852 HD derivation, pure pycardano - oracles.py — lifted from cardano_price.py: Koios ADA/USD feed w/ 5m cache - monitor.py — lifted verbatim (SQLAlchemy-coupled; v0.2 refactors to Store) - scheduler.py — lifted verbatim (same refactor note) - invoice.py — NEW: framework-agnostic Invoice dataclass + lifecycle enum - store.py — NEW: InvoiceStore Protocol for pluggable persistence - mint.py — NEW: CIP-25 v2 metadata builder (works); tx submission stub for v0.2 - ipfs.py — NEW: kubo HTTP client with primary-pin + mirror-pin pattern - txbuild.py — NEW: v0.2 stub for PyCardano / Ogmios tx construction Design: - Consumers provide xpub + InvoiceStore impl. SDK provides everything else. - IPFS: local kubo for upload + serve, optional mirror pins for archival. Chromaticcraft pattern: Rackham kubo primary, Lucy kubo mirror. - NFT: single native-script policy per merchant studio (CIP-25 v2, not CIP-68 — full wallet coverage, no mutability needed for static certs). Policy skey stays under Sulkta cold-custody (Lucy pattern); signing is an external hand-off like ADAMaps payouts. Tests: pure-module smoke tests pass for invoice, store-protocol, CIP-25 metadata envelope, IPFS client import, txbuild stub module. Address derivation tests ship but require pycardano + will exercise in CI. LICENSE: Apache-2.0 (matches upstream Cardano tooling). Next (v0.2 scope): - Refactor monitor + scheduler around InvoiceStore (drop SQLAlchemy coupling) - Wire mint.mint_nft_cert to PyCardano + local Ogmios on Rackham - txbuild: Ogmios chain-context + cold-signer hand-off shape - chromaticcraft Phase 2 imports the SDK as its first external consumer
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
"""cardano_checkout — Python SDK for merchant-side Cardano payments + NFT cert minting.
|
|
|
|
Zero-custody by design: consumers provide a wallet xpub (account-level
|
|
extended public key). The SDK derives unique receive addresses per
|
|
invoice, polls the chain for payment, and (optionally) mints a CIP-25
|
|
NFT certificate of authenticity on confirmation.
|
|
|
|
Quick start::
|
|
|
|
from cardano_checkout import addresses, oracles
|
|
|
|
addr = addresses.derive_address(xpub_hex, index=42, network="mainnet")
|
|
price = await oracles.get_ada_usd_price()
|
|
lovelace = await oracles.convert_usd_to_lovelace(99.00)
|
|
|
|
For full invoice lifecycle see :mod:`cardano_checkout.invoice` +
|
|
:mod:`cardano_checkout.store` (Protocol-based persistence).
|
|
|
|
For NFT minting see :mod:`cardano_checkout.mint`.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
__version__ = "0.1.0-dev"
|
|
|
|
# Pure modules — stable API from extraction
|
|
from cardano_checkout import addresses, oracles # noqa: F401
|
|
|
|
# Payment lifecycle
|
|
from cardano_checkout.invoice import Invoice, InvoiceStatus # noqa: F401
|
|
from cardano_checkout.store import InvoiceStore # noqa: F401
|
|
|
|
# NFT + IPFS
|
|
from cardano_checkout.mint import MintPolicy, mint_nft_cert # noqa: F401
|
|
from cardano_checkout.ipfs import IPFSClient, pin_bytes # noqa: F401
|
|
|
|
__all__ = [
|
|
"__version__",
|
|
"addresses",
|
|
"oracles",
|
|
"Invoice",
|
|
"InvoiceStatus",
|
|
"InvoiceStore",
|
|
"MintPolicy",
|
|
"mint_nft_cert",
|
|
"IPFSClient",
|
|
"pin_bytes",
|
|
]
|