paratro-sdk 1.1.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Paratro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,361 @@
1
+ Metadata-Version: 2.4
2
+ Name: paratro-sdk
3
+ Version: 1.1.5
4
+ Summary: Official Python SDK for Paratro MPC Wallet Infrastructure
5
+ Author-email: Paratro <hello@paratro.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://paratro.com
8
+ Project-URL: Documentation, https://docs.paratro.com
9
+ Project-URL: Repository, https://github.com/paratro/paratro-sdk-python
10
+ Keywords: paratro,mpc,wallet,x402,crypto,sdk
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: requests>=2.28.0
25
+ Dynamic: license-file
26
+
27
+ # Paratro MPC Wallet Gateway Python SDK
28
+
29
+ [![PyPI version](https://img.shields.io/pypi/v/paratro-sdk.svg)](https://pypi.org/project/paratro-sdk/)
30
+ [![Python](https://img.shields.io/pypi/pyversions/paratro-sdk.svg)](https://pypi.org/project/paratro-sdk/)
31
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
32
+
33
+ Official Python SDK for [Paratro](https://paratro.com) MPC Wallet Gateway — a comprehensive Multi-Party Computation wallet management platform.
34
+
35
+ ## Features
36
+
37
+ - **MPC Wallets** — Create and manage MPC wallets with threshold-signature security
38
+ - **Multi-Chain Support** — Ethereum, BSC, Polygon, Avalanche, Arbitrum, Optimism, Tron, Bitcoin, Solana
39
+ - **Account Management** — Create and manage multiple accounts per wallet
40
+ - **Asset Management** — Support for native tokens and ERC20/TRC20 tokens
41
+ - **Transfer** — Send funds to external addresses with automatic asset resolution
42
+ - **Transaction Tracking** — Complete transaction history and status tracking
43
+ - **x402 Payments** — Native support for HTTP 402 payment protocol (X402_SIGN, X402_SETTLE)
44
+ - **Secure** — Built-in JWT authentication with automatic token refresh
45
+ - **Thread-Safe** — Token management with thread-safe locking for concurrent usage
46
+
47
+ ## Installation
48
+
49
+ ```bash
50
+ pip install paratro-sdk
51
+ ```
52
+
53
+ **Requirements:** Python 3.9+
54
+
55
+ ## Quick Start
56
+
57
+ ```python
58
+ from paratro import (
59
+ MPCClient, Config,
60
+ CreateWalletRequest, CreateAccountRequest,
61
+ CreateAssetRequest, CreateTransferRequest,
62
+ )
63
+
64
+ # 1. Initialize client
65
+ client = MPCClient("your-api-key", "your-api-secret", Config.sandbox())
66
+
67
+ # 2. Create a wallet
68
+ wallet = client.create_wallet(CreateWalletRequest(wallet_name="My Wallet"))
69
+ print(f"Wallet ID: {wallet.wallet_id}, Status: {wallet.status}")
70
+
71
+ # 3. Wait for wallet to be ready (status=ACTIVE, key_status=ACTIVE)
72
+ # New wallets are created asynchronously. Poll get_wallet() until ready.
73
+ wallet = client.get_wallet(wallet.wallet_id)
74
+ assert wallet.status == "ACTIVE" and wallet.key_status == "ACTIVE"
75
+
76
+ # 4. Create an account
77
+ account = client.create_account(CreateAccountRequest(
78
+ wallet_id=wallet.wallet_id,
79
+ chain="ethereum",
80
+ label="Deposit Account",
81
+ ))
82
+ print(f"Account: {account.account_id}, Address: {account.address}")
83
+
84
+ # 5. Add an asset
85
+ asset = client.create_asset(CreateAssetRequest(
86
+ account_id=account.account_id,
87
+ symbol="USDT",
88
+ chain="ethereum",
89
+ ))
90
+ print(f"Asset: {asset.asset_id}, Symbol: {asset.symbol}")
91
+
92
+ # 6. Create a transfer
93
+ transfer = client.create_transfer(CreateTransferRequest(
94
+ from_address=account.address,
95
+ to_address="0xRecipient...",
96
+ chain="ethereum",
97
+ token_symbol="USDT",
98
+ amount="10.5",
99
+ ))
100
+ print(f"Transfer: {transfer.tx_id}, Status: {transfer.status}")
101
+
102
+ # 7. List transactions
103
+ resp = client.list_transactions()
104
+ for tx in resp.items:
105
+ print(f"TX: {tx.tx_hash} {tx.amount} {tx.token_symbol} ({tx.status})")
106
+
107
+ # 8. Clean up
108
+ client.logout()
109
+ ```
110
+
111
+ ## Configuration
112
+
113
+ ```python
114
+ from paratro import Config
115
+
116
+ # Sandbox (for testing)
117
+ config = Config.sandbox() # https://api-sandbox.paratro.com
118
+
119
+ # Production
120
+ config = Config.production() # https://api.paratro.com
121
+
122
+ # Custom environment
123
+ config = Config.custom("https://your-api.example.com")
124
+ ```
125
+
126
+ ## API Reference
127
+
128
+ ### Wallets
129
+
130
+ Create and manage MPC wallets. New wallets are created asynchronously — wait until both `status` and `key_status` are `ACTIVE` before creating accounts.
131
+
132
+ ```python
133
+ from paratro import CreateWalletRequest, ListWalletsRequest
134
+
135
+ # Create a wallet
136
+ wallet = client.create_wallet(CreateWalletRequest(
137
+ wallet_name="Treasury",
138
+ description="Primary treasury wallet",
139
+ ))
140
+
141
+ # Get wallet by ID
142
+ wallet = client.get_wallet("wallet_id")
143
+
144
+ # List wallets with pagination
145
+ resp = client.list_wallets(ListWalletsRequest(page=1, page_size=10))
146
+ print(f"Total: {resp.total}, Has more: {resp.has_more}")
147
+ for w in resp.items:
148
+ print(f" {w.wallet_id}: {w.wallet_name} ({w.status})")
149
+ ```
150
+
151
+ **Wallet fields:** `wallet_id`, `client_id`, `wallet_name`, `description`, `status`, `key_status`, `created_at`, `updated_at`
152
+
153
+ ### Accounts
154
+
155
+ Create blockchain accounts under a wallet. The gateway derives the account `network` automatically from the selected `chain`. EVM-compatible chains share the same key derivation and produce the same address.
156
+
157
+ ```python
158
+ from paratro import CreateAccountRequest, ListAccountsRequest
159
+
160
+ # Create an account
161
+ account = client.create_account(CreateAccountRequest(
162
+ wallet_id="wallet_id",
163
+ chain="ethereum", # See supported chains below
164
+ account_type="DEPOSIT", # Optional
165
+ label="Hot Wallet", # Optional
166
+ ))
167
+
168
+ # Get account by ID
169
+ account = client.get_account("account_id")
170
+
171
+ # List accounts filtered by wallet
172
+ resp = client.list_accounts(ListAccountsRequest(
173
+ wallet_id="wallet_id",
174
+ page=1,
175
+ page_size=20,
176
+ ))
177
+ ```
178
+
179
+ **Account fields:** `account_id`, `wallet_id`, `client_id`, `address`, `network`, `address_type`, `label`, `status`, `created_at`
180
+
181
+ ### Assets
182
+
183
+ Add tokens to an account. Asset configuration (contract address, decimals, etc.) is resolved automatically by the gateway.
184
+
185
+ ```python
186
+ from paratro import CreateAssetRequest, ListAssetsRequest
187
+
188
+ # Add USDC on Ethereum to an account
189
+ asset = client.create_asset(CreateAssetRequest(
190
+ account_id="account_id",
191
+ symbol="USDC",
192
+ chain="ethereum", # Required for EVM accounts to specify target chain
193
+ ))
194
+
195
+ # Get asset by ID
196
+ asset = client.get_asset("asset_id")
197
+ print(f"Balance: {asset.balance} {asset.symbol}")
198
+
199
+ # List assets for an account
200
+ resp = client.list_assets(ListAssetsRequest(account_id="account_id"))
201
+ for a in resp.items:
202
+ print(f" {a.symbol}: {a.balance} (locked: {a.locked_balance})")
203
+ ```
204
+
205
+ **Asset fields:** `asset_id`, `account_id`, `wallet_id`, `client_id`, `chain`, `network`, `symbol`, `name`, `contract_address`, `decimals`, `asset_type`, `balance`, `locked_balance`, `is_active`, `created_at`
206
+
207
+ **Supported symbols:** `ETH`, `BNB`, `MATIC`, `AVAX`, `TRX`, `BTC`, `SOL`, `USDT`, `USDC`, and other ERC20/TRC20 tokens
208
+
209
+ ### Transfers
210
+
211
+ Send funds to external addresses. The API automatically resolves the asset using chain + token symbol.
212
+
213
+ ```python
214
+ from paratro import CreateTransferRequest
215
+
216
+ result = client.create_transfer(CreateTransferRequest(
217
+ from_address="0xYourAddress...",
218
+ to_address="0xRecipient...",
219
+ chain="ethereum",
220
+ token_symbol="USDC",
221
+ amount="100.50",
222
+ memo="Invoice #1234", # Optional
223
+ ))
224
+ print(f"TX ID: {result.tx_id}, Status: {result.status}")
225
+ ```
226
+
227
+ **Transfer response fields:** `tx_id`, `status`, `message`
228
+
229
+ ### Transactions
230
+
231
+ Query transaction history. Supports filtering by wallet, account, and chain.
232
+
233
+ ```python
234
+ from paratro import ListTransactionsRequest
235
+
236
+ # Get a single transaction
237
+ tx = client.get_transaction("tx_id")
238
+ print(f"Type: {tx.transaction_type}, Hash: {tx.tx_hash}")
239
+
240
+ # List transactions with filters
241
+ resp = client.list_transactions(ListTransactionsRequest(
242
+ wallet_id="wallet_id", # Optional filter
243
+ account_id="account_id", # Optional filter
244
+ chain="ethereum", # Optional filter
245
+ page=1,
246
+ page_size=20,
247
+ ))
248
+ for tx in resp.items:
249
+ print(f" {tx.tx_id}: {tx.transaction_type} {tx.amount} {tx.token_symbol} -> {tx.status}")
250
+ ```
251
+
252
+ **Transaction fields:** `tx_id`, `wallet_id`, `client_id`, `chain`, `transaction_type`, `from_address`, `to_address`, `token_symbol`, `amount`, `status`, `tx_hash`, `created_at`
253
+
254
+ **Transaction types:** `TRANSFER`, `X402_SIGN`, `X402_SETTLE`
255
+
256
+ ## Error Handling
257
+
258
+ The SDK raises `APIError` for all API failures with structured error information:
259
+
260
+ ```python
261
+ from paratro import APIError, is_not_found, is_rate_limited, is_auth_error
262
+
263
+ try:
264
+ wallet = client.get_wallet("nonexistent_id")
265
+ except APIError as e:
266
+ print(f"HTTP {e.http_status}: [{e.code}] {e.message}")
267
+ print(f"Error type: {e.error_type}")
268
+
269
+ # Convenience helpers
270
+ if is_not_found(e):
271
+ print("Resource not found")
272
+ elif is_rate_limited(e):
273
+ print("Rate limited — retry after backoff")
274
+ elif is_auth_error(e):
275
+ print("Authentication failed — check API key/secret")
276
+ ```
277
+
278
+ **Error attributes:**
279
+
280
+ | Attribute | Type | Description |
281
+ |-----------|------|-------------|
282
+ | `http_status` | `int` | HTTP status code (400, 401, 403, 404, 429, 500, etc.) |
283
+ | `code` | `str` | Machine-readable error code (e.g. `not_found`, `invalid_parameter`) |
284
+ | `error_type` | `str` | Error category (e.g. `business_error`, `validation_error`) |
285
+ | `message` | `str` | Human-readable error description |
286
+
287
+ ## Supported Chains
288
+
289
+ | Chain | Value | Type |
290
+ |-------|-------|------|
291
+ | Ethereum | `ethereum` | EVM |
292
+ | BNB Smart Chain | `bsc` | EVM |
293
+ | Polygon | `polygon` | EVM |
294
+ | Avalanche | `avalanche` | EVM |
295
+ | Arbitrum | `arbitrum` | EVM |
296
+ | Optimism | `optimism` | EVM |
297
+ | Tron | `tron` | TVM |
298
+ | Bitcoin | `bitcoin` | UTXO |
299
+ | Solana | `solana` | SVM |
300
+
301
+ > **Note:** EVM-compatible chains (`ethereum`, `bsc`, `polygon`, `avalanche`, `arbitrum`, `optimism`) share the same key derivation and produce the same address per wallet.
302
+
303
+ ## Authentication
304
+
305
+ The SDK handles authentication automatically:
306
+
307
+ 1. On the first API call, the client exchanges your `api_key` and `api_secret` for a JWT token
308
+ 2. The token is cached and reused for subsequent requests
309
+ 3. When the token approaches expiration (< 5 minutes remaining), it is automatically refreshed
310
+ 4. Token management is thread-safe for concurrent usage
311
+ 5. Call `client.logout()` to explicitly invalidate the token
312
+
313
+ ## Project Structure
314
+
315
+ ```
316
+ paratro-sdk-python/
317
+ ├── paratro/
318
+ │ ├── __init__.py # Public API exports
319
+ │ ├── client.py # MPCClient with all API methods
320
+ │ ├── config.py # Environment configuration
321
+ │ ├── errors.py # APIError and helper functions
322
+ │ ├── models.py # Request/response dataclasses
323
+ │ └── version.py # SDK version
324
+ ├── tests/
325
+ │ └── test_client.py # Unit tests
326
+ ├── pyproject.toml # Package metadata
327
+ ├── LICENSE # MIT License
328
+ └── README.md
329
+ ```
330
+
331
+ ## Development
332
+
333
+ ```bash
334
+ # Install dev dependencies
335
+ pip install pytest requests
336
+
337
+ # Run tests
338
+ python -m pytest tests/ -v
339
+
340
+ # Type checking (optional)
341
+ pip install mypy
342
+ mypy paratro/
343
+ ```
344
+
345
+ ## Related SDKs
346
+
347
+ | Language | Package | Repository |
348
+ |----------|---------|------------|
349
+ | Go | `github.com/paratro/paratro-sdk-go` | [paratro-sdk-go](https://github.com/paratro/paratro-sdk-go) |
350
+ | Rust | `paratro-sdk` | [paratro-sdk-rust](https://github.com/paratro/paratro-sdk-rust) |
351
+ | Python | `paratro-sdk` | [paratro-sdk-python](https://github.com/paratro/paratro-sdk-python) |
352
+
353
+ ## Support
354
+
355
+ - Documentation: https://docs.paratro.com
356
+ - Email: hello@paratro.com
357
+ - Issues: https://github.com/paratro/paratro-sdk-python/issues
358
+
359
+ ## License
360
+
361
+ This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.