The repository or configuration that created this release differ from a previous release. View details.
This release is a pre-release and may not be stable for production use.
blockchain0x (Python SDK)
Official Python SDK for Blockchain0x - the non-custodial AI-agent wallet platform on Base.
Pre-release:
0.0.1a0ships the operational essentials - HTTP transport,apiKeysresource, andwebhooks.verify. The full surface (every resource + x402 client + async client) lands in the 21.3 Phase C follow-up rows.
Install
pip install blockchain0x
Requires Python 3.9 or newer.
Quick start
from blockchain0x import Client
client = Client(api_key="sk_test_...")
for key in client.api_keys.list()["data"]:
print(key["id"], key["prefix"])
The client pins the network from the api-key prefix
(sk_test_* → testnet, sk_live_* → mainnet). Override with
Client(api_key=..., network="mainnet") when you need both modes in
one process (mixed-mode tests).
Verify webhook signatures
This is the single most important utility this SDK ships - drop it into the top of your webhook handler BEFORE touching the body.
from blockchain0x import webhooks
# In your Flask / FastAPI / Django handler:
def receive_webhook(req, raw_body, secret):
result = webhooks.verify(headers=req.headers, raw_body=raw_body, secret=secret)
if not result.ok:
return {"code": result.code}, 400
# result.event_type / result.event_id / result.delivery_id populated
process_event(raw_body, result.event_type)
The verifier:
- Reads
X-Blockchain0x-Signaturein eithert=<ts>,v1=<hex>or bare-hex form (some load balancers strip commas). - Falls back to
X-Blockchain0x-Timestampwhen the signature is bare. - Rejects with
webhook.timestamp_outside_windowwhen drift exceeds 300s (5-minute replay window; matches the worker). - Constant-time compares via
hmac.compare_digest.
For exception-based flows pass raise_on_fail=True:
try:
webhooks.verify(headers=req.headers, raw_body=raw_body, secret=secret, raise_on_fail=True)
except WebhookSignatureError as e:
return {"code": e.code}, 400
Errors
Two classes:
Blockchain0xError- base class; every SDK error inherits.ApiKeyError- subclass for HTTP 401 / 403 envelopes whoseerror.codestarts withapikey.(e.g.apikey.scope_insufficient,apikey.wallet_not_assigned).
Always branch on .code, never regex-match .message:
from blockchain0x import ApiKeyError
try:
client.api_keys.list()
except ApiKeyError as e:
if e.code == "apikey.scope_insufficient":
# mint a fresh key with more scope
...
Workspace keys (sub-plan 21.3)
Two key shapes exist (see docs/concept-api-key-types.md for the full decision tree):
- Wallet-only: bound to ONE agent via
agent_id. The right shape for an autonomous AI agent that IS one wallet. - Workspace: for human operators that can carry workspace-level scopes AND assignments to N specific wallets.
The Python SDK forwards both shapes through the same client.api_keys resource; the body shape decides the flavor on the server. Once the create surface lands beyond the C-2 scaffold:
key = client.api_keys.create(
label="Treasury daily reconciliation",
workspace_scopes=["read_workspace"],
wallet_assignments=[
{"agentId": "agt_trading", "scopes": ["read_wallet_metadata"]},
{"agentId": "agt_settlement", "scopes": ["read_wallet_metadata"]},
],
expires_in_days=30,
)
print(key["secret"]) # shown ONCE
Server-side RBAC: the minter cannot grant a scope they do not have themselves. Over-grants reject with apikey.role_insufficient_for_grants - catch ApiKeyError and branch on e.code.
Cascade behaviour: when an assigned wallet is soft-deleted, the assignment row is removed. If the key has zero workspace scopes AND no remaining assignments, it auto-revokes with apikey.no_grants_remaining. Mint a fresh key.
x402 (Phase C-7)
The sibling package blockchain0x-x402 (Python port of @blockchain0x/x402) will ship the x402 client + FastAPI / Starlette / Flask adapters in sub-plan 21.3 row C-7. The wire format is identical across languages so a Python service can accept payments from a Node client and vice-versa.
Retry behaviour
The transport retries on 429 and 5xx with exponential backoff
(0.5s → 1s → 2s → ... → 30s cap). Retry-After is honoured when the
server sends it. Network errors (timeout, connection drop) get the
same retry budget.
POST / PATCH / DELETE requests carry an Idempotency-Key header
- the SDK mints a uuid4 if you do not supply one. Pass
idempotency_key="..."to thread a stable key across SDK retries OR across processes (e.g. cron jobs that hash their input deterministically).
Codegen
Type-only DTOs are generated from apps/backend/openapi/openapi.yaml
via datamodel-code-generator.
Transport, retry, error mapping, and the webhook verifier stay
handwritten - see codegen/README.md for the
decision rationale.
Source-of-truth + distribution
Source-of-truth: this directory in
tosh-labs/blockchain0x-app
under packages/sdk-python/.
Public mirror: tosh-labs/blockchain0x-python
(receives merges from this directory on each push to dev).
Distribution: pypi via Trusted Publisher OIDC.
License
Apache-2.0.
Metadata
Release files for blockchain0x 0.0.1a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Change of provenance
The repository or configuration that created these release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| blockchain0x-0.0.1a1.tar.gz | 27.4 kB | With provenance | Details for blockchain0x-0.0.1a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| blockchain0x-0.0.1a1-py3-none-any.whl | Python 3 | none | any | Details for blockchain0x-0.0.1a1-py3-none-any.whl |
Total release size: 50.8 kB
Release files / blockchain0x-0.0.1a1.tar.gz
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | blockchain0x-0.0.1a1.tar.gz |
|---|---|
| Size | 27.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad682026abdb44f405129772c0354cd295a24041ae139baebe9470b2daa02871
|
|
BLAKE2b-256 checksum How to use checksums |
fcc92b36de0803662f622ca188e1ef4423626ed0cee304e512e21ebeff49c741
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 11, 2026.
Transparency logRelease files / blockchain0x-0.0.1a1-py3-none-any.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | blockchain0x-0.0.1a1-py3-none-any.whl |
|---|---|
| Size | 23.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c631af10187acd5a037d7fafd6fcd25aafff01f757091589deee44eca6a2c28a
|
|
BLAKE2b-256 checksum How to use checksums |
70eb38673f89f498e834be07582e1f5e2a5fa6472f7b83d8939f32d6c95e9248
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 11, 2026.
Transparency logSecurity for blockchain0x 0.0.1a1
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.
Change of provenance
The repository and configuration that created this release differ from a previous release.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
Repository
- Removed 0.0.1a0 github.com/Tosh-Labs/blockchain0x-python
- Added 0.0.1a1 github.com/tosh-labs/blockchain0x-python
Attestation for blockchain0x-0.0.1a1.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 Jun 11, 2026.
Transparency logA 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.