settle-sdk (Python)
F5.2 — Python port of the Settle TypeScript SDK. Same canonical hashing algorithm; outputs are byte-identical so a Python verifier can confirm a TS-emitted receipt and vice versa.
Install
pip install settle-sdk
(Until first PyPI publish, install from this repo:
pip install -e packages/python-sdk from a Settle clone.)
Requires blake3 (auto-installed).
Quick start
from settle_sdk import kernel_commit, verify_receipt, compute_capability_hash_hex
# Compute a capability hash for a tool spec
hash_hex = compute_capability_hash_hex({
"domain": "translate.example.com",
"method": "POST",
"path": "/v1/translate",
"amount_lamports": "20000",
"version": 1,
})
# Compute the 4-hash kernel commit for a payment
result = kernel_commit({
"kind": "direct_send",
"request_id": "11111111-2222-3333-4444-555555555555",
"amount_lamports": "500000",
"sender": "B4cArR1M1MySM4dn4HeDdifdPiF98wTNmbzKYg6to2Cp",
"recipient": "C9HAssvFBtEgHvZRVGdfxcUwrGfu5iK4Z3FKn52Ns7yY",
"decision_slot": 1000,
"purpose_text": "test payment",
})
print("receipt_hash:", result.receipt_hash)
print("context_hash:", result.context_hash)
# Verify a receipt by re-deriving its hashes
v = verify_receipt({
"receipt": result.canonical_receipt,
"reason": result.canonical_reason,
"policy_snapshot": result.canonical_policy_snapshot,
"http": { "method": "POST", "path": "/_kernel/direct_send" },
"expected": {
"receipt_hash": result.receipt_hash,
"reason_hash": result.reason_hash,
"policy_snapshot_hash": result.policy_snapshot_hash,
"purpose_hash": result.purpose_hash,
},
})
assert v.ok, f"verification failed: {v.mismatches}"
What's in this port
purpose_text_hash,canonical_receipt_hash,canonical_reason_hash,canonical_policy_snapshot_hash,canonical_purpose_hash— the 5 canonical hash functions.compute_capability_hash_hex— capability hash derivation.kernel_commit— F2.0 universal receipt kernel for any kind (x402_spend, direct_send, link_send, streaming_claim, escrow_*, refund).verify_receipt— recompute and compare against expected hashes.
What's NOT in this port (yet)
- Solana transaction building (use
solders/solana-pydirectly). - On-chain
record_receiptix builder (build manually from the IDL JSON inprograms/settle-agent-card/target/idl/settle_agent_card.json). - Sealed-box encryption (use
pynacldirectly with the same X25519 + XChaCha20 parameters as@settle/sdk).
These will land in subsequent versions if there's demand. The hashing core ships first because it's what every verifier needs.
Cross-implementation parity
If you compute a hash in TypeScript and a hash in Python from the same canonical object, you must get the same bytes. This is enforced by:
- JSON serialization: sorted keys, no whitespace, both runtimes use the
exact same algorithm in
_stable_json. - NFC Unicode normalization for purpose text in both runtimes.
- BLAKE3 — both runtimes use the reference
blake3implementation.
If you find a parity bug, file an issue with reproducer inputs from both sides.
License
MIT.
Metadata
Release files for settle-protocol-sdk 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| settle_protocol_sdk-0.2.1.tar.gz | 13.7 kB | Without provenance | Details for settle_protocol_sdk-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| settle_protocol_sdk-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for settle_protocol_sdk-0.2.1-py3-none-any.whl |
Total release size: 28.9 kB
Release files / settle_protocol_sdk-0.2.1.tar.gz
| Download URL | settle_protocol_sdk-0.2.1.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6cb4afb1abb4fe49472a73e8209097eaba53cd73d49e272488c1782945b280dc
|
|
BLAKE2b-256 checksum How to use checksums |
f3f3b57a2c6831c9a1223f1abba274eb448f265623c0e14fe66ff03f5f418826
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / settle_protocol_sdk-0.2.1-py3-none-any.whl
| Download URL | settle_protocol_sdk-0.2.1-py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f719977ef30dc2fb03cfb5a76321e938fec0acd5c4ac56d6338a3531567baed
|
|
BLAKE2b-256 checksum How to use checksums |
047e50848d46bc6292648879cea4755949c930b600751f1d3429946285b54fdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for settle-protocol-sdk 0.2.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.