chipi-stack 2.0.0__py3-none-any.whl

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,366 @@
1
+ Metadata-Version: 2.4
2
+ Name: chipi-stack
3
+ Version: 2.0.0
4
+ Summary: Python SDK for Starknet Gasless Transactions via Chipi
5
+ Author-email: Carlos Castillo <carlos@chipipay.com>, Roberto Yamanaka <roberto@chipipay.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/chipi-pay/sdks
8
+ Project-URL: Documentation, https://docs.chipipay.com
9
+ Project-URL: Repository, https://github.com/chipi-pay/sdks
10
+ Project-URL: Issues, https://github.com/chipi-pay/sdks/issues
11
+ Keywords: starknet,blockchain,gasless,transactions,web3,chipi,paymaster
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Topic :: Internet
19
+ Classifier: Topic :: Software Development
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: starknet-py>=0.23.0
24
+ Requires-Dist: pydantic>=2.0.0
25
+ Requires-Dist: httpx>=0.27.0
26
+ Requires-Dist: cryptography>=42.0.0
27
+ Requires-Dist: typing-extensions>=4.9.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
30
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
31
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
32
+ Requires-Dist: pytest-mock>=3.12.0; extra == "dev"
33
+ Requires-Dist: black>=24.0.0; extra == "dev"
34
+ Requires-Dist: ruff>=0.3.0; extra == "dev"
35
+ Requires-Dist: mypy>=1.8.0; extra == "dev"
36
+ Requires-Dist: build>=1.0.0; extra == "dev"
37
+ Requires-Dist: twine>=5.0.0; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # Chipi Python SDK
41
+
42
+ [![PyPI version](https://badge.fury.io/py/chipi-python.svg)](https://badge.fury.io/py/chipi-python)
43
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
44
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
45
+
46
+ Python SDK for executing gasless transactions on Starknet via Chipi's paymaster infrastructure.
47
+
48
+ ## Features
49
+
50
+ - 🚀 **Gasless Transactions** - Execute transactions without paying gas fees
51
+ - 💼 **Wallet Management** - Create and manage Starknet wallets
52
+ - 🔐 **Session Keys** - SNIP-9 compatible session key support for CHIPI wallets
53
+ - 🔄 **Sync & Async** - Full support for both synchronous and asynchronous operations
54
+ - 📦 **Type Safe** - Built with Pydantic for runtime validation and type safety
55
+ - 🎯 **Simple API** - Easy-to-use interface for all operations
56
+
57
+ ## Installation
58
+
59
+ ```bash
60
+ pip install chipi-python
61
+ ```
62
+
63
+ Or with uv:
64
+
65
+ ```bash
66
+ uv add chipi-python
67
+ ```
68
+
69
+ ### Requirements
70
+
71
+ - Python 3.11 or higher
72
+ - Dependencies:
73
+ - `starknet-py>=0.23.0` - Starknet interactions
74
+ - `pydantic>=2.0.0` - Data validation
75
+ - `httpx>=0.27.0` - HTTP client
76
+ - `cryptography>=42.0.0` - AES encryption
77
+
78
+ ## Quick Start
79
+
80
+ ### Initialize the SDK
81
+
82
+ ```python
83
+ from chipi_sdk import ChipiSDK, ChipiSDKConfig
84
+
85
+ # Initialize SDK with your API keys
86
+ sdk = ChipiSDK(
87
+ config=ChipiSDKConfig(
88
+ api_public_key="your_public_key",
89
+ api_secret_key="your_secret_key", # Optional for server-side
90
+ )
91
+ )
92
+ ```
93
+
94
+ ### Create a Wallet
95
+
96
+ ```python
97
+ from chipi_sdk import CreateWalletParams, WalletType
98
+
99
+ # Synchronous
100
+ wallet_response = sdk.create_wallet(
101
+ params=CreateWalletParams(
102
+ encrypt_key="user_password",
103
+ external_user_id="user123",
104
+ wallet_type=WalletType.CHIPI,
105
+ )
106
+ )
107
+
108
+ print(f"Wallet created: {wallet_response.wallet_public_key}")
109
+ print(f"Transaction hash: {wallet_response.tx_hash}")
110
+
111
+ # Async version
112
+ wallet_response = await sdk.acreate_wallet(params=params)
113
+ ```
114
+
115
+ ### Execute a Gasless Transaction
116
+
117
+ ```python
118
+ from chipi_sdk import ExecuteTransactionParams, Call
119
+
120
+ # Transfer tokens without gas fees
121
+ tx_hash = sdk.execute_transaction(
122
+ params=ExecuteTransactionParams(
123
+ encrypt_key="user_password",
124
+ wallet=wallet_data,
125
+ calls=[
126
+ Call(
127
+ contractAddress="0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
128
+ entrypoint="transfer",
129
+ calldata=[recipient_address, amount, "0x0"],
130
+ )
131
+ ],
132
+ )
133
+ )
134
+
135
+ print(f"Transaction executed: {tx_hash}")
136
+ ```
137
+
138
+ ### Transfer Tokens (Convenience Method)
139
+
140
+ ```python
141
+ from chipi_sdk import TransferParams, ChainToken
142
+
143
+ tx_hash = sdk.transfer(
144
+ params=TransferParams(
145
+ encrypt_key="user_password",
146
+ wallet=wallet_data,
147
+ token=ChainToken.USDC,
148
+ recipient="0x...",
149
+ amount="1.5", # Human-readable amount
150
+ )
151
+ )
152
+ ```
153
+
154
+ ### Session Keys (CHIPI Wallets Only)
155
+
156
+ ```python
157
+ from chipi_sdk import CreateSessionKeyParams, SessionConfig, AddSessionKeyParams
158
+
159
+ # 1. Create session key locally
160
+ session = sdk.sessions.create_session_key(
161
+ params=CreateSessionKeyParams(
162
+ encrypt_key="user_password",
163
+ duration_seconds=21600, # 6 hours
164
+ )
165
+ )
166
+
167
+ # 2. Register session on-chain (one-time)
168
+ tx_hash = await sdk.sessions.aadd_session_key_to_contract(
169
+ params=AddSessionKeyParams(
170
+ encrypt_key="user_password",
171
+ wallet=wallet_data,
172
+ session_config=SessionConfig(
173
+ session_public_key=session.public_key,
174
+ valid_until=session.valid_until,
175
+ max_calls=1000,
176
+ allowed_entrypoints=[], # Empty = all allowed
177
+ ),
178
+ ),
179
+ bearer_token="your_token",
180
+ )
181
+
182
+ # 3. Execute transactions with session (no owner key needed!)
183
+ from chipi_sdk import ExecuteWithSessionParams
184
+
185
+ tx_hash = await sdk.aexecute_transaction_with_session(
186
+ params=ExecuteWithSessionParams(
187
+ encrypt_key="user_password",
188
+ wallet=wallet_data,
189
+ session=session,
190
+ calls=[...],
191
+ )
192
+ )
193
+ ```
194
+
195
+ ## Async/Await Support
196
+
197
+ Every method has both sync and async versions:
198
+
199
+ ```python
200
+ # Synchronous
201
+ wallet = sdk.get_wallet(params=params, bearer_token="token")
202
+ tx_hash = sdk.transfer(params=transfer_params)
203
+
204
+ # Asynchronous (prefix with 'a')
205
+ wallet = await sdk.aget_wallet(params=params, bearer_token="token")
206
+ tx_hash = await sdk.atransfer(params=transfer_params)
207
+ ```
208
+
209
+ ## API Reference
210
+
211
+ ### Main SDK Class
212
+
213
+ - `ChipiSDK` - Main SDK class with all operations
214
+
215
+ ### Wallet Operations
216
+
217
+ - `create_wallet()` / `acreate_wallet()` - Create new wallet
218
+ - `get_wallet()` / `aget_wallet()` - Retrieve wallet by user ID
219
+ - `get_token_balance()` / `aget_token_balance()` - Query token balances
220
+
221
+ ### Transaction Operations
222
+
223
+ - `execute_transaction()` / `aexecute_transaction()` - Execute custom calls
224
+ - `transfer()` / `atransfer()` - Transfer tokens
225
+ - `approve()` / `aapprove()` - Approve token spending
226
+ - `stake_vesu_usdc()` / `astake_vesu_usdc()` - Stake in Vesu protocol
227
+ - `withdraw_vesu_usdc()` / `awithdraw_vesu_usdc()` - Withdraw from Vesu
228
+ - `get_transaction_list()` / `aget_transaction_list()` - Query transaction history
229
+
230
+ ### Session Key Operations (CHIPI Wallets)
231
+
232
+ - `create_session_key()` - Generate session keypair locally
233
+ - `add_session_key_to_contract()` / `aadd_session_key_to_contract()` - Register session
234
+ - `revoke_session_key()` / `arevoke_session_key()` - Revoke session
235
+ - `get_session_data()` / `aget_session_data()` - Query session status
236
+ - `execute_transaction_with_session()` / `aexecute_transaction_with_session()` - Execute with session
237
+
238
+ ### User Operations
239
+
240
+ - `create_user()` / `acreate_user()` - Create user
241
+ - `get_user()` / `aget_user()` - Get user by external ID
242
+
243
+ ### SKU Operations
244
+
245
+ - `get_sku_list()` / `aget_sku_list()` - List SKUs
246
+ - `get_sku()` / `aget_sku()` - Get SKU by ID
247
+ - `create_sku_transaction()` / `acreate_sku_transaction()` - Create SKU transaction
248
+
249
+ ## Error Handling
250
+
251
+ ```python
252
+ from chipi_sdk import (
253
+ ChipiError,
254
+ ChipiApiError,
255
+ ChipiWalletError,
256
+ ChipiTransactionError,
257
+ ChipiSessionError,
258
+ )
259
+
260
+ try:
261
+ tx_hash = sdk.execute_transaction(params=params)
262
+ except ChipiTransactionError as e:
263
+ print(f"Transaction failed: {e.message}")
264
+ print(f"Error code: {e.code}")
265
+ except ChipiApiError as e:
266
+ print(f"API error: {e.message} (status: {e.status})")
267
+ except ChipiError as e:
268
+ print(f"General error: {e.message}")
269
+ ```
270
+
271
+ ## Configuration
272
+
273
+ ### SDK Config Options
274
+
275
+ ```python
276
+ from chipi_sdk import ChipiSDKConfig
277
+
278
+ config = ChipiSDKConfig(
279
+ api_public_key="your_public_key", # Required
280
+ api_secret_key="your_secret_key", # Optional - for server-side
281
+ alpha_url="https://custom-api.com", # Optional - custom API URL
282
+ node_url="https://custom-rpc.com", # Optional - custom Starknet RPC
283
+ )
284
+ ```
285
+
286
+ ### Wallet Types
287
+
288
+ - `WalletType.CHIPI` - OpenZeppelin account with SNIP-9 session keys (default)
289
+ - `WalletType.READY` - Argent X Account v0.4.0
290
+
291
+ ### Supported Tokens
292
+
293
+ - USDC (Native)
294
+ - USDC_E (Bridged)
295
+ - USDT
296
+ - ETH
297
+ - STRK
298
+ - DAI
299
+ - WBTC
300
+ - OTHER (custom tokens)
301
+
302
+ ## Development
303
+
304
+ ### Setup Development Environment
305
+
306
+ ```bash
307
+ # Clone the repository
308
+ git clone https://github.com/chipi-pay/chipi-sdk.git
309
+ cd chipi-sdk/python
310
+
311
+ # Install with dev dependencies
312
+ pip install -e ".[dev]"
313
+
314
+ # Or with uv
315
+ uv pip install -e ".[dev]"
316
+ ```
317
+
318
+ ### Run Tests
319
+
320
+ ```bash
321
+ pytest tests/
322
+ ```
323
+
324
+ ### Format Code
325
+
326
+ ```bash
327
+ black chipi_sdk/
328
+ ruff check chipi_sdk/ --fix
329
+ ```
330
+
331
+ ### Type Checking
332
+
333
+ ```bash
334
+ mypy chipi_sdk/
335
+ ```
336
+
337
+ ## Examples
338
+
339
+ See the [examples](https://github.com/chipi-pay/chipi-sdk/tree/main/python/examples) directory for more usage examples.
340
+
341
+ ## Related SDKs
342
+
343
+ - [TypeScript SDK](https://www.npmjs.com/package/@chipi-stack/backend) - For Node.js/TypeScript projects
344
+ - [React SDK](https://www.npmjs.com/package/@chipi-stack/react) - For React applications
345
+
346
+ ## Documentation
347
+
348
+ Full documentation is available at [docs.chipipay.com](https://docs.chipipay.com)
349
+
350
+ ## Support
351
+
352
+ - 📧 Email: carlos@chipipay.com
353
+ - 💬 Discord: [Starknet Discord](https://discord.gg/starknet) (#chipi channel)
354
+ - 🐛 Issues: [GitHub Issues](https://github.com/chipi-pay/chipi-sdk/issues)
355
+
356
+ ## License
357
+
358
+ MIT License - see [LICENSE](LICENSE) file for details
359
+
360
+ ## Contributing
361
+
362
+ Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
363
+
364
+ ---
365
+
366
+ Built with ❤️ by the Chipi team
@@ -0,0 +1,33 @@
1
+ chipi_sdk/__init__.py,sha256=L_NXPv03kDojMLWd225kaVG5vYZdyaN2_afUjD4O7DE,7757
2
+ chipi_sdk/client.py,sha256=RdRKEgUjD4Ac60rlpbH1G-lbiPTjniII8EwwMlUHhwA,13993
3
+ chipi_sdk/constants.py,sha256=tfBc5pfPcd4DxU5hdx8BpQP_Ey3gnnrYz2BziS6O77A,5077
4
+ chipi_sdk/encryption.py,sha256=fYIPG3eXbG16IV1gCEh9Kks33alVy9CvvRBayWQpWkA,5101
5
+ chipi_sdk/errors.py,sha256=WPHG4vNlY_vx2gH_5N2MEoGMhZAaeW34NYBv62wVsmM,3722
6
+ chipi_sdk/execute_paymaster.py,sha256=AvIRoXv5yf2HLSaJZMLrjx7AwEaCl4m1HhXSMxgUvf8,14833
7
+ chipi_sdk/formatters.py,sha256=J6cDIOi4qciJC6CKLnwYbbiCgEH2cwtycjRXFqkVtKc,3444
8
+ chipi_sdk/py.typed,sha256=2fYELBifmrW34-PPJa0CTNoeda-08ZmdmE8dw_OKb_U,71
9
+ chipi_sdk/sdk.py,sha256=y2Y4RL391yVWosrHxZJ2JfQYFhc5YjK86pSS_2RVX1E,28218
10
+ chipi_sdk/sessions.py,sha256=fBA5XUoZwOYYpYe0M_Wd8hYAlR4o1gBrKEMn_sSdsQg,29551
11
+ chipi_sdk/sku_transactions.py,sha256=r3j4T7nCntdG_Pn_Iv9D0aV1cO0KbNMa1bzQskA3iwM,1646
12
+ chipi_sdk/skus.py,sha256=nNLGzvbmnTnJPIDz0AKtd4clVfBgAe7GIgupkSObGQ4,2508
13
+ chipi_sdk/transactions.py,sha256=m_s0XWBiC4vODImSgodVs332AZ-tIz-irYp0Eceh5Z4,13918
14
+ chipi_sdk/users.py,sha256=NlJ7nPODAzG5W65h11DhcG5IDZJUQYGhh8Sn_LbSv9o,2496
15
+ chipi_sdk/validators.py,sha256=mgDZdzhqBtnnyoUTM8Iem5bCxg-Hjg3IduqFlCG3myU,1771
16
+ chipi_sdk/wallets.py,sha256=XYwBRMMBy8VjhNg5UTv285i0X7l_iJZ9Gku5viAEKLU,15434
17
+ chipi_sdk/x402_client.py,sha256=aql69YBLjPiwfxD-Zm5D56bY1d1gb0OmE0r73b-ZXI0,8330
18
+ chipi_sdk/x402_facilitator.py,sha256=up6PO7FTn6HTXtBpks6mwTpPuo8QPslEsyp7horVs0E,7513
19
+ chipi_sdk/x402_middleware.py,sha256=fzFqChn7NWyCKwRuayh7lGppCzP8Wa3AIkHQa6VoWhQ,9964
20
+ chipi_sdk/models/__init__.py,sha256=DO-BJddsF1hJaDwYaUrU6SRDAR5iShsVXGiHeZg40Js,3109
21
+ chipi_sdk/models/core.py,sha256=GUZE8UzEU_bKUZq3PUCSTsb2-ZQJFwVFCvQQIybrmkI,3088
22
+ chipi_sdk/models/session.py,sha256=20YATTj6DGIbvOy8cAxOSImr_hTR0aZdm-ecOE03B6M,4867
23
+ chipi_sdk/models/sku.py,sha256=hFsWPHy8aFupAGGrvJkcdY2nor58RyWj5SERfxyPR-s,639
24
+ chipi_sdk/models/sku_transaction.py,sha256=XqaU3rpYzfy8dbhFuJfdvPxb7zgETnydPJwwcwou3vE,863
25
+ chipi_sdk/models/transaction.py,sha256=T68TsznIbiS4vW218dG9pTCUn9Byp2knZXTGmCZAk-g,5692
26
+ chipi_sdk/models/user.py,sha256=R1sQucy6eyt8hrAjQ5WEPteZ0rzxfqiioavsY6sdDAU,831
27
+ chipi_sdk/models/wallet.py,sha256=qaFOhjlTt7hM-zDWLj9bEvyZffXdjNFbSyfgAiiN6os,5992
28
+ chipi_sdk/models/x402.py,sha256=UZnMkjHetqfD3gb5JaUkOgfMT4XiheWauLUBIW-iZuM,4205
29
+ chipi_stack-2.0.0.dist-info/licenses/LICENSE,sha256=uNS3IuTaoCCqK375oWjGgJYA5AYH3Z92eLjhw_cB7y8,1071
30
+ chipi_stack-2.0.0.dist-info/METADATA,sha256=_ojpieYLHe15RYFNA67Y7Mi0D3UG9sjUW7EdzWk3Gxc,10030
31
+ chipi_stack-2.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
32
+ chipi_stack-2.0.0.dist-info/top_level.txt,sha256=K5WFszW7Is7H5_3h_fxf371ID1WM6NWHrKTEDPh9XPk,10
33
+ chipi_stack-2.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Chipi Pay
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 @@
1
+ chipi_sdk