cdp-sdk 0.0.1__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.
Files changed (156) hide show
  1. cdp_sdk-0.0.1/LICENSE.md +15 -0
  2. cdp_sdk-0.0.1/PKG-INFO +264 -0
  3. cdp_sdk-0.0.1/README.md +161 -0
  4. cdp_sdk-0.0.1/cdp/__init__.py +27 -0
  5. cdp_sdk-0.0.1/cdp/__version__.py +1 -0
  6. cdp_sdk-0.0.1/cdp/address.py +107 -0
  7. cdp_sdk-0.0.1/cdp/api_clients.py +148 -0
  8. cdp_sdk-0.0.1/cdp/asset.py +165 -0
  9. cdp_sdk-0.0.1/cdp/balance.py +79 -0
  10. cdp_sdk-0.0.1/cdp/balance_map.py +75 -0
  11. cdp_sdk-0.0.1/cdp/cdp.py +117 -0
  12. cdp_sdk-0.0.1/cdp/cdp_api_client.py +180 -0
  13. cdp_sdk-0.0.1/cdp/client/__init__.py +147 -0
  14. cdp_sdk-0.0.1/cdp/client/api/__init__.py +20 -0
  15. cdp_sdk-0.0.1/cdp/client/api/addresses_api.py +2476 -0
  16. cdp_sdk-0.0.1/cdp/client/api/assets_api.py +277 -0
  17. cdp_sdk-0.0.1/cdp/client/api/balance_history_api.py +357 -0
  18. cdp_sdk-0.0.1/cdp/client/api/contract_events_api.py +430 -0
  19. cdp_sdk-0.0.1/cdp/client/api/contract_invocations_api.py +1164 -0
  20. cdp_sdk-0.0.1/cdp/client/api/external_addresses_api.py +1127 -0
  21. cdp_sdk-0.0.1/cdp/client/api/networks_api.py +247 -0
  22. cdp_sdk-0.0.1/cdp/client/api/server_signers_api.py +1525 -0
  23. cdp_sdk-0.0.1/cdp/client/api/smart_contracts_api.py +1097 -0
  24. cdp_sdk-0.0.1/cdp/client/api/stake_api.py +1449 -0
  25. cdp_sdk-0.0.1/cdp/client/api/trades_api.py +1144 -0
  26. cdp_sdk-0.0.1/cdp/client/api/transfers_api.py +1144 -0
  27. cdp_sdk-0.0.1/cdp/client/api/users_api.py +232 -0
  28. cdp_sdk-0.0.1/cdp/client/api/validators_api.py +615 -0
  29. cdp_sdk-0.0.1/cdp/client/api/wallet_stake_api.py +856 -0
  30. cdp_sdk-0.0.1/cdp/client/api/wallets_api.py +1203 -0
  31. cdp_sdk-0.0.1/cdp/client/api/webhooks_api.py +988 -0
  32. cdp_sdk-0.0.1/cdp/client/api_client.py +694 -0
  33. cdp_sdk-0.0.1/cdp/client/api_response.py +21 -0
  34. cdp_sdk-0.0.1/cdp/client/configuration.py +457 -0
  35. cdp_sdk-0.0.1/cdp/client/exceptions.py +194 -0
  36. cdp_sdk-0.0.1/cdp/client/models/__init__.py +114 -0
  37. cdp_sdk-0.0.1/cdp/client/models/address.py +95 -0
  38. cdp_sdk-0.0.1/cdp/client/models/address_balance_list.py +100 -0
  39. cdp_sdk-0.0.1/cdp/client/models/address_historical_balance_list.py +98 -0
  40. cdp_sdk-0.0.1/cdp/client/models/address_list.py +100 -0
  41. cdp_sdk-0.0.1/cdp/client/models/address_transaction_list.py +98 -0
  42. cdp_sdk-0.0.1/cdp/client/models/asset.py +93 -0
  43. cdp_sdk-0.0.1/cdp/client/models/balance.py +88 -0
  44. cdp_sdk-0.0.1/cdp/client/models/broadcast_contract_invocation_request.py +79 -0
  45. cdp_sdk-0.0.1/cdp/client/models/broadcast_staking_operation_request.py +87 -0
  46. cdp_sdk-0.0.1/cdp/client/models/broadcast_trade_request.py +85 -0
  47. cdp_sdk-0.0.1/cdp/client/models/broadcast_transfer_request.py +77 -0
  48. cdp_sdk-0.0.1/cdp/client/models/build_staking_operation_request.py +97 -0
  49. cdp_sdk-0.0.1/cdp/client/models/contract_event.py +126 -0
  50. cdp_sdk-0.0.1/cdp/client/models/contract_event_list.py +98 -0
  51. cdp_sdk-0.0.1/cdp/client/models/contract_invocation.py +121 -0
  52. cdp_sdk-0.0.1/cdp/client/models/contract_invocation_list.py +102 -0
  53. cdp_sdk-0.0.1/cdp/client/models/create_address_request.py +92 -0
  54. cdp_sdk-0.0.1/cdp/client/models/create_contract_invocation_request.py +94 -0
  55. cdp_sdk-0.0.1/cdp/client/models/create_payload_signature_request.py +80 -0
  56. cdp_sdk-0.0.1/cdp/client/models/create_server_signer_request.py +89 -0
  57. cdp_sdk-0.0.1/cdp/client/models/create_smart_contract_request.py +91 -0
  58. cdp_sdk-0.0.1/cdp/client/models/create_staking_operation_request.py +87 -0
  59. cdp_sdk-0.0.1/cdp/client/models/create_trade_request.py +85 -0
  60. cdp_sdk-0.0.1/cdp/client/models/create_transfer_request.py +99 -0
  61. cdp_sdk-0.0.1/cdp/client/models/create_wallet_request.py +88 -0
  62. cdp_sdk-0.0.1/cdp/client/models/create_wallet_request_wallet.py +83 -0
  63. cdp_sdk-0.0.1/cdp/client/models/create_webhook_request.py +126 -0
  64. cdp_sdk-0.0.1/cdp/client/models/deploy_smart_contract_request.py +79 -0
  65. cdp_sdk-0.0.1/cdp/client/models/erc20_transfer_event.py +159 -0
  66. cdp_sdk-0.0.1/cdp/client/models/erc721_transfer_event.py +158 -0
  67. cdp_sdk-0.0.1/cdp/client/models/error.py +92 -0
  68. cdp_sdk-0.0.1/cdp/client/models/ethereum_transaction.py +186 -0
  69. cdp_sdk-0.0.1/cdp/client/models/ethereum_transaction_access.py +80 -0
  70. cdp_sdk-0.0.1/cdp/client/models/ethereum_transaction_access_list.py +94 -0
  71. cdp_sdk-0.0.1/cdp/client/models/ethereum_transaction_flattened_trace.py +137 -0
  72. cdp_sdk-0.0.1/cdp/client/models/ethereum_validator_metadata.py +127 -0
  73. cdp_sdk-0.0.1/cdp/client/models/faucet_transaction.py +87 -0
  74. cdp_sdk-0.0.1/cdp/client/models/feature_set.py +98 -0
  75. cdp_sdk-0.0.1/cdp/client/models/fetch_historical_staking_balances200_response.py +98 -0
  76. cdp_sdk-0.0.1/cdp/client/models/fetch_staking_rewards200_response.py +98 -0
  77. cdp_sdk-0.0.1/cdp/client/models/fetch_staking_rewards_request.py +107 -0
  78. cdp_sdk-0.0.1/cdp/client/models/get_staking_context_request.py +89 -0
  79. cdp_sdk-0.0.1/cdp/client/models/historical_balance.py +96 -0
  80. cdp_sdk-0.0.1/cdp/client/models/network.py +127 -0
  81. cdp_sdk-0.0.1/cdp/client/models/network_identifier.py +37 -0
  82. cdp_sdk-0.0.1/cdp/client/models/nft_contract_options.py +78 -0
  83. cdp_sdk-0.0.1/cdp/client/models/payload_signature.py +107 -0
  84. cdp_sdk-0.0.1/cdp/client/models/payload_signature_list.py +102 -0
  85. cdp_sdk-0.0.1/cdp/client/models/seed_creation_event.py +82 -0
  86. cdp_sdk-0.0.1/cdp/client/models/seed_creation_event_result.py +96 -0
  87. cdp_sdk-0.0.1/cdp/client/models/server_signer.py +87 -0
  88. cdp_sdk-0.0.1/cdp/client/models/server_signer_event.py +92 -0
  89. cdp_sdk-0.0.1/cdp/client/models/server_signer_event_event.py +147 -0
  90. cdp_sdk-0.0.1/cdp/client/models/server_signer_event_list.py +100 -0
  91. cdp_sdk-0.0.1/cdp/client/models/server_signer_list.py +102 -0
  92. cdp_sdk-0.0.1/cdp/client/models/signature_creation_event.py +112 -0
  93. cdp_sdk-0.0.1/cdp/client/models/signature_creation_event_result.py +102 -0
  94. cdp_sdk-0.0.1/cdp/client/models/signed_voluntary_exit_message_metadata.py +89 -0
  95. cdp_sdk-0.0.1/cdp/client/models/smart_contract.py +125 -0
  96. cdp_sdk-0.0.1/cdp/client/models/smart_contract_list.py +98 -0
  97. cdp_sdk-0.0.1/cdp/client/models/smart_contract_options.py +147 -0
  98. cdp_sdk-0.0.1/cdp/client/models/smart_contract_type.py +31 -0
  99. cdp_sdk-0.0.1/cdp/client/models/sponsored_send.py +119 -0
  100. cdp_sdk-0.0.1/cdp/client/models/staking_balance.py +112 -0
  101. cdp_sdk-0.0.1/cdp/client/models/staking_context.py +88 -0
  102. cdp_sdk-0.0.1/cdp/client/models/staking_context_context.py +106 -0
  103. cdp_sdk-0.0.1/cdp/client/models/staking_operation.py +133 -0
  104. cdp_sdk-0.0.1/cdp/client/models/staking_operation_metadata.py +141 -0
  105. cdp_sdk-0.0.1/cdp/client/models/staking_reward.py +120 -0
  106. cdp_sdk-0.0.1/cdp/client/models/staking_reward_format.py +31 -0
  107. cdp_sdk-0.0.1/cdp/client/models/staking_reward_usd_value.py +88 -0
  108. cdp_sdk-0.0.1/cdp/client/models/token_contract_options.py +87 -0
  109. cdp_sdk-0.0.1/cdp/client/models/trade.py +137 -0
  110. cdp_sdk-0.0.1/cdp/client/models/trade_list.py +102 -0
  111. cdp_sdk-0.0.1/cdp/client/models/transaction.py +147 -0
  112. cdp_sdk-0.0.1/cdp/client/models/transaction_content.py +133 -0
  113. cdp_sdk-0.0.1/cdp/client/models/transaction_type.py +30 -0
  114. cdp_sdk-0.0.1/cdp/client/models/transfer.py +162 -0
  115. cdp_sdk-0.0.1/cdp/client/models/transfer_list.py +102 -0
  116. cdp_sdk-0.0.1/cdp/client/models/update_webhook_request.py +107 -0
  117. cdp_sdk-0.0.1/cdp/client/models/user.py +78 -0
  118. cdp_sdk-0.0.1/cdp/client/models/validator.py +107 -0
  119. cdp_sdk-0.0.1/cdp/client/models/validator_details.py +135 -0
  120. cdp_sdk-0.0.1/cdp/client/models/validator_list.py +98 -0
  121. cdp_sdk-0.0.1/cdp/client/models/validator_status.py +42 -0
  122. cdp_sdk-0.0.1/cdp/client/models/wallet.py +120 -0
  123. cdp_sdk-0.0.1/cdp/client/models/wallet_list.py +100 -0
  124. cdp_sdk-0.0.1/cdp/client/models/webhook.py +142 -0
  125. cdp_sdk-0.0.1/cdp/client/models/webhook_event_filter.py +94 -0
  126. cdp_sdk-0.0.1/cdp/client/models/webhook_event_type.py +33 -0
  127. cdp_sdk-0.0.1/cdp/client/models/webhook_event_type_filter.py +135 -0
  128. cdp_sdk-0.0.1/cdp/client/models/webhook_list.py +101 -0
  129. cdp_sdk-0.0.1/cdp/client/models/webhook_wallet_activity_filter.py +84 -0
  130. cdp_sdk-0.0.1/cdp/client/py.typed +0 -0
  131. cdp_sdk-0.0.1/cdp/client/rest.py +222 -0
  132. cdp_sdk-0.0.1/cdp/errors.py +359 -0
  133. cdp_sdk-0.0.1/cdp/faucet_transaction.py +44 -0
  134. cdp_sdk-0.0.1/cdp/py.typed +0 -0
  135. cdp_sdk-0.0.1/cdp/sponsored_send.py +164 -0
  136. cdp_sdk-0.0.1/cdp/trade.py +266 -0
  137. cdp_sdk-0.0.1/cdp/transaction.py +181 -0
  138. cdp_sdk-0.0.1/cdp/transfer.py +325 -0
  139. cdp_sdk-0.0.1/cdp/wallet.py +622 -0
  140. cdp_sdk-0.0.1/cdp/wallet_address.py +191 -0
  141. cdp_sdk-0.0.1/cdp_sdk.egg-info/PKG-INFO +264 -0
  142. cdp_sdk-0.0.1/cdp_sdk.egg-info/SOURCES.txt +154 -0
  143. cdp_sdk-0.0.1/cdp_sdk.egg-info/dependency_links.txt +1 -0
  144. cdp_sdk-0.0.1/cdp_sdk.egg-info/requires.txt +78 -0
  145. cdp_sdk-0.0.1/cdp_sdk.egg-info/top_level.txt +1 -0
  146. cdp_sdk-0.0.1/pyproject.toml +137 -0
  147. cdp_sdk-0.0.1/setup.cfg +4 -0
  148. cdp_sdk-0.0.1/tests/test_address.py +168 -0
  149. cdp_sdk-0.0.1/tests/test_asset.py +120 -0
  150. cdp_sdk-0.0.1/tests/test_balance.py +99 -0
  151. cdp_sdk-0.0.1/tests/test_errors.py +140 -0
  152. cdp_sdk-0.0.1/tests/test_trade.py +267 -0
  153. cdp_sdk-0.0.1/tests/test_transaction.py +150 -0
  154. cdp_sdk-0.0.1/tests/test_transfer.py +347 -0
  155. cdp_sdk-0.0.1/tests/test_wallet.py +448 -0
  156. cdp_sdk-0.0.1/tests/test_wallet_address.py +375 -0
@@ -0,0 +1,15 @@
1
+ Apache-2.0 License
2
+
3
+ Copyright 2024 Coinbase
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
cdp_sdk-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,264 @@
1
+ Metadata-Version: 2.1
2
+ Name: cdp-sdk
3
+ Version: 0.0.1
4
+ Summary: CDP Python SDK
5
+ Author-email: John Peterson <john.peterson@coinbase.com>
6
+ License: Apache-2.0 License
7
+
8
+ Copyright 2024 Coinbase
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+ Project-URL: Homepage, https://docs.cdp.coinbase.com/cdp-sdk/docs/welcome
22
+ Keywords: coinbase,sdk,crypto,cdp
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE.md
26
+ Requires-Dist: aiohappyeyeballs==2.4.0
27
+ Requires-Dist: aiohttp==3.10.5
28
+ Requires-Dist: aiosignal==1.3.1
29
+ Requires-Dist: annotated-types==0.7.0
30
+ Requires-Dist: asn1crypto==1.5.1
31
+ Requires-Dist: async-timeout==4.0.3
32
+ Requires-Dist: attrs==24.2.0
33
+ Requires-Dist: bip-utils==2.9.3
34
+ Requires-Dist: bitarray==2.9.2
35
+ Requires-Dist: cbor2==5.6.4
36
+ Requires-Dist: certifi==2024.8.30
37
+ Requires-Dist: cffi==1.17.1
38
+ Requires-Dist: charset-normalizer==3.3.2
39
+ Requires-Dist: ckzg==2.0.1
40
+ Requires-Dist: coincurve==20.0.0
41
+ Requires-Dist: crcmod==1.7
42
+ Requires-Dist: cryptography==43.0.1
43
+ Requires-Dist: cytoolz==0.12.3
44
+ Requires-Dist: ecdsa==0.19.0
45
+ Requires-Dist: ed25519-blake2b==1.4.1
46
+ Requires-Dist: eth-account==0.13.3
47
+ Requires-Dist: eth-hash==0.7.0
48
+ Requires-Dist: eth-keyfile==0.8.1
49
+ Requires-Dist: eth-keys==0.5.1
50
+ Requires-Dist: eth-rlp==2.1.0
51
+ Requires-Dist: eth-typing==5.0.0
52
+ Requires-Dist: eth-utils==5.0.0
53
+ Requires-Dist: eth_abi==5.1.0
54
+ Requires-Dist: frozenlist==1.4.1
55
+ Requires-Dist: hexbytes==1.2.1
56
+ Requires-Dist: idna==3.10
57
+ Requires-Dist: multidict==6.1.0
58
+ Requires-Dist: parsimonious==0.10.0
59
+ Requires-Dist: py-sr25519-bindings==0.2.0
60
+ Requires-Dist: pycparser==2.22
61
+ Requires-Dist: pycryptodome==3.20.0
62
+ Requires-Dist: pydantic==2.9.2
63
+ Requires-Dist: pydantic_core==2.23.4
64
+ Requires-Dist: PyJWT==2.9.0
65
+ Requires-Dist: PyNaCl==1.5.0
66
+ Requires-Dist: python-dateutil==2.9.0.post0
67
+ Requires-Dist: pyunormalize==16.0.0
68
+ Requires-Dist: regex==2024.9.11
69
+ Requires-Dist: requests==2.32.3
70
+ Requires-Dist: rlp==4.0.1
71
+ Requires-Dist: six==1.16.0
72
+ Requires-Dist: toolz==0.12.1
73
+ Requires-Dist: types-requests==2.32.0.20240914
74
+ Requires-Dist: typing_extensions==4.12.2
75
+ Requires-Dist: urllib3==2.2.3
76
+ Requires-Dist: web3==7.2.0
77
+ Requires-Dist: websockets==13.0.1
78
+ Requires-Dist: yarl==1.11.1
79
+ Provides-Extra: dev
80
+ Requires-Dist: astroid==3.2.4; extra == "dev"
81
+ Requires-Dist: autopep8==1.5.5; extra == "dev"
82
+ Requires-Dist: isort==5.13.2; extra == "dev"
83
+ Requires-Dist: mccabe==0.6.1; extra == "dev"
84
+ Requires-Dist: mypy==1.11.2; extra == "dev"
85
+ Requires-Dist: mypy-extensions==1.0.0; extra == "dev"
86
+ Requires-Dist: pycodestyle==2.6.0; extra == "dev"
87
+ Requires-Dist: pydocstyle==6.3.0; extra == "dev"
88
+ Requires-Dist: pyflakes==2.2.0; extra == "dev"
89
+ Requires-Dist: pylint==3.2.7; extra == "dev"
90
+ Requires-Dist: pytest==8.3.3; extra == "dev"
91
+ Requires-Dist: ruff==0.6.5; extra == "dev"
92
+ Requires-Dist: types-requests==2.32.0.20240914; extra == "dev"
93
+ Requires-Dist: yapf==0.40.2; extra == "dev"
94
+ Requires-Dist: jedi==0.17.2; extra == "dev"
95
+ Requires-Dist: pygls==1.3.1; extra == "dev"
96
+ Requires-Dist: python-language-server==0.36.2; extra == "dev"
97
+ Requires-Dist: pytoolconfig==1.3.1; extra == "dev"
98
+ Requires-Dist: rope==1.13.0; extra == "dev"
99
+ Requires-Dist: ruff-lsp==0.0.56; extra == "dev"
100
+ Requires-Dist: pluggy==1.5.0; extra == "dev"
101
+ Requires-Dist: parso==0.7.1; extra == "dev"
102
+ Requires-Dist: lsprotocol==2023.0.1; extra == "dev"
103
+
104
+ # CDP Python SDK
105
+
106
+ The CDP Python SDK enables the simple integration of crypto into your app.
107
+ By calling Coinbase's CDP APIs, the SDK allows you to provision crypto wallets,
108
+ send crypto into/out of those wallets, track wallet balances, and trade crypto from
109
+ one asset into another.
110
+
111
+ **CDP SDK v0 is a pre-alpha release, which means that the APIs and SDK methods are subject to change. We will continuously release updates to support new capabilities and improve the developer experience.**
112
+
113
+ ## Documentation
114
+
115
+ - [CDP API Documentation](https://docs.cdp.coinbase.com/platform-apis/docs/welcome)
116
+
117
+ ## Requirements
118
+
119
+ - Python 3.10+
120
+
121
+ ### Checking Python Version
122
+
123
+ Before using the SDK, ensure that you have the correct version of Python installed. The SDK requires Python 3.10 or higher. You can check your Python version by running the following code:
124
+
125
+ ```bash
126
+ python --version
127
+ ```
128
+
129
+ If you need to upgrade your Python version, you can download and install the latest version of Python from the [official Python website](https://www.python.org/downloads/).
130
+
131
+ ## Installation
132
+
133
+ ```bash
134
+ pip install cdp-sdk
135
+ ```
136
+
137
+ ### Starting a Python REPL
138
+
139
+ To start a Python REPL:
140
+
141
+ ```bash
142
+ python
143
+ ```
144
+
145
+ ## Creating a Wallet
146
+
147
+ To start, [create a CDP API key](https://portal.cdp.coinbase.com/access/api). Then, initialize the CDP SDK by passing your API key name and API key's private key via the `configure` method:
148
+
149
+ ```python
150
+ from cdp import *
151
+
152
+ api_key_name = "Copy your API key name here."
153
+ # Ensure that you are using double-quotes here.
154
+ api_key_private_key = "Copy your API key's private key here."
155
+
156
+ Cdp.configure(api_key_name, api_key_private_key)
157
+
158
+ print("CDP SDK has been successfully configured with CDP API key.")
159
+ ```
160
+
161
+ Another way to initialize the SDK is by sourcing the API key from the JSON file that contains your API key,
162
+ downloaded from the CDP portal.
163
+
164
+ ```python
165
+ Cdp.configure_from_json("~/Downloads/cdp_api_key.json")
166
+
167
+ print("CDP SDK has been successfully configured from JSON file.")
168
+ ```
169
+
170
+ This will allow you to authenticate with the Platform APIs.
171
+
172
+ If you are using a CDP Server-Signer to manage your private keys, enable it with
173
+
174
+ ```python
175
+ Cdp.use_server_signer = True
176
+ ```
177
+
178
+ Now create a wallet. Wallets are created with a single default address.
179
+
180
+ ```python
181
+ # Create a wallet with one address by default.
182
+ wallet1 = Wallet.create()
183
+ ```
184
+
185
+ Wallets come with a single default address, accessible via `default_address`:
186
+
187
+ ```python
188
+ # A wallet has a default address.
189
+ address = wallet1.default_address
190
+ ```
191
+
192
+ ## Funding a Wallet
193
+
194
+ Wallets do not have funds on them to start. For Base Sepolia testnet, we provide a `faucet` method to fund your wallet with
195
+ testnet ETH. You are allowed one faucet claim per 24-hour window.
196
+
197
+ ```python
198
+ # Fund the wallet with a faucet transaction.
199
+ faucet_tx = wallet1.faucet()
200
+
201
+ print(f"Faucet transaction successfully completed: {faucet_tx}")
202
+ ```
203
+
204
+ ## Transferring Funds
205
+
206
+ See [Transfers](https://docs.cdp.coinbase.com/wallets/docs/transfers) for more information.
207
+
208
+ Now that your faucet transaction has successfully completed, you can send the funds in your wallet to another wallet.
209
+ The code below creates another wallet, and uses the `transfer` function to send testnet ETH from the first wallet to
210
+ the second:
211
+
212
+ ```python
213
+ # Create a new wallet wallet2 to transfer funds to.
214
+ wallet2 = Wallet.create()
215
+
216
+ print(f"Wallet successfully created: {wallet2}")
217
+
218
+ transfer = wallet1.transfer(0.00001, "eth", wallet2).wait()
219
+
220
+ print(f"Transfer successfully completed: {transfer}")
221
+ ```
222
+
223
+ ### Gasless USDC Transfers
224
+
225
+ To transfer USDC without needing to hold ETH for gas, you can use the `transfer` method with the `gasless` option set to `True`.
226
+
227
+ ```python
228
+ # Create a new wallet wallet3 to transfer funds to.
229
+ wallet3 = Wallet.create()
230
+
231
+ print(f"Wallet successfully created: {wallet3}")
232
+
233
+ transfer = wallet1.transfer(0.00001, "usdc", wallet3, gasless=True).wait()
234
+ ```
235
+
236
+ ## Listing Transfers
237
+
238
+ ```python
239
+ # Return list of all transfers. This will paginate and fetch all transfers for the address.
240
+ address.transfers()
241
+ ```
242
+
243
+ ## Trading Funds
244
+
245
+ See [Trades](https://docs.cdp.coinbase.com/wallets/docs/trades) for more information.
246
+
247
+ ```python
248
+ wallet = Wallet.create("base-mainnet")
249
+
250
+ print(f"Wallet successfully created: {wallet}")
251
+ print(f"Send `base-mainnet` ETH to wallets default address: {wallet.default_address.address_id}")
252
+
253
+ trade = wallet.trade(0.00001, "eth", "usdc").wait()
254
+
255
+ print(f"Trade successfully completed: {trade}")
256
+ ```
257
+
258
+ ## Listing Trades
259
+
260
+ ```python
261
+ # Return list of all trades. This will paginate and fetch all trades for the address.
262
+ address.trades()
263
+ ```
264
+
@@ -0,0 +1,161 @@
1
+ # CDP Python SDK
2
+
3
+ The CDP Python SDK enables the simple integration of crypto into your app.
4
+ By calling Coinbase's CDP APIs, the SDK allows you to provision crypto wallets,
5
+ send crypto into/out of those wallets, track wallet balances, and trade crypto from
6
+ one asset into another.
7
+
8
+ **CDP SDK v0 is a pre-alpha release, which means that the APIs and SDK methods are subject to change. We will continuously release updates to support new capabilities and improve the developer experience.**
9
+
10
+ ## Documentation
11
+
12
+ - [CDP API Documentation](https://docs.cdp.coinbase.com/platform-apis/docs/welcome)
13
+
14
+ ## Requirements
15
+
16
+ - Python 3.10+
17
+
18
+ ### Checking Python Version
19
+
20
+ Before using the SDK, ensure that you have the correct version of Python installed. The SDK requires Python 3.10 or higher. You can check your Python version by running the following code:
21
+
22
+ ```bash
23
+ python --version
24
+ ```
25
+
26
+ If you need to upgrade your Python version, you can download and install the latest version of Python from the [official Python website](https://www.python.org/downloads/).
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ pip install cdp-sdk
32
+ ```
33
+
34
+ ### Starting a Python REPL
35
+
36
+ To start a Python REPL:
37
+
38
+ ```bash
39
+ python
40
+ ```
41
+
42
+ ## Creating a Wallet
43
+
44
+ To start, [create a CDP API key](https://portal.cdp.coinbase.com/access/api). Then, initialize the CDP SDK by passing your API key name and API key's private key via the `configure` method:
45
+
46
+ ```python
47
+ from cdp import *
48
+
49
+ api_key_name = "Copy your API key name here."
50
+ # Ensure that you are using double-quotes here.
51
+ api_key_private_key = "Copy your API key's private key here."
52
+
53
+ Cdp.configure(api_key_name, api_key_private_key)
54
+
55
+ print("CDP SDK has been successfully configured with CDP API key.")
56
+ ```
57
+
58
+ Another way to initialize the SDK is by sourcing the API key from the JSON file that contains your API key,
59
+ downloaded from the CDP portal.
60
+
61
+ ```python
62
+ Cdp.configure_from_json("~/Downloads/cdp_api_key.json")
63
+
64
+ print("CDP SDK has been successfully configured from JSON file.")
65
+ ```
66
+
67
+ This will allow you to authenticate with the Platform APIs.
68
+
69
+ If you are using a CDP Server-Signer to manage your private keys, enable it with
70
+
71
+ ```python
72
+ Cdp.use_server_signer = True
73
+ ```
74
+
75
+ Now create a wallet. Wallets are created with a single default address.
76
+
77
+ ```python
78
+ # Create a wallet with one address by default.
79
+ wallet1 = Wallet.create()
80
+ ```
81
+
82
+ Wallets come with a single default address, accessible via `default_address`:
83
+
84
+ ```python
85
+ # A wallet has a default address.
86
+ address = wallet1.default_address
87
+ ```
88
+
89
+ ## Funding a Wallet
90
+
91
+ Wallets do not have funds on them to start. For Base Sepolia testnet, we provide a `faucet` method to fund your wallet with
92
+ testnet ETH. You are allowed one faucet claim per 24-hour window.
93
+
94
+ ```python
95
+ # Fund the wallet with a faucet transaction.
96
+ faucet_tx = wallet1.faucet()
97
+
98
+ print(f"Faucet transaction successfully completed: {faucet_tx}")
99
+ ```
100
+
101
+ ## Transferring Funds
102
+
103
+ See [Transfers](https://docs.cdp.coinbase.com/wallets/docs/transfers) for more information.
104
+
105
+ Now that your faucet transaction has successfully completed, you can send the funds in your wallet to another wallet.
106
+ The code below creates another wallet, and uses the `transfer` function to send testnet ETH from the first wallet to
107
+ the second:
108
+
109
+ ```python
110
+ # Create a new wallet wallet2 to transfer funds to.
111
+ wallet2 = Wallet.create()
112
+
113
+ print(f"Wallet successfully created: {wallet2}")
114
+
115
+ transfer = wallet1.transfer(0.00001, "eth", wallet2).wait()
116
+
117
+ print(f"Transfer successfully completed: {transfer}")
118
+ ```
119
+
120
+ ### Gasless USDC Transfers
121
+
122
+ To transfer USDC without needing to hold ETH for gas, you can use the `transfer` method with the `gasless` option set to `True`.
123
+
124
+ ```python
125
+ # Create a new wallet wallet3 to transfer funds to.
126
+ wallet3 = Wallet.create()
127
+
128
+ print(f"Wallet successfully created: {wallet3}")
129
+
130
+ transfer = wallet1.transfer(0.00001, "usdc", wallet3, gasless=True).wait()
131
+ ```
132
+
133
+ ## Listing Transfers
134
+
135
+ ```python
136
+ # Return list of all transfers. This will paginate and fetch all transfers for the address.
137
+ address.transfers()
138
+ ```
139
+
140
+ ## Trading Funds
141
+
142
+ See [Trades](https://docs.cdp.coinbase.com/wallets/docs/trades) for more information.
143
+
144
+ ```python
145
+ wallet = Wallet.create("base-mainnet")
146
+
147
+ print(f"Wallet successfully created: {wallet}")
148
+ print(f"Send `base-mainnet` ETH to wallets default address: {wallet.default_address.address_id}")
149
+
150
+ trade = wallet.trade(0.00001, "eth", "usdc").wait()
151
+
152
+ print(f"Trade successfully completed: {trade}")
153
+ ```
154
+
155
+ ## Listing Trades
156
+
157
+ ```python
158
+ # Return list of all trades. This will paginate and fetch all trades for the address.
159
+ address.trades()
160
+ ```
161
+
@@ -0,0 +1,27 @@
1
+ from cdp.__version__ import __version__
2
+ from cdp.address import Address
3
+ from cdp.asset import Asset
4
+ from cdp.balance import Balance
5
+ from cdp.balance_map import BalanceMap
6
+ from cdp.cdp import Cdp
7
+ from cdp.faucet_transaction import FaucetTransaction
8
+ from cdp.sponsored_send import SponsoredSend
9
+ from cdp.trade import Trade
10
+ from cdp.transaction import Transaction
11
+ from cdp.transfer import Transfer
12
+ from cdp.wallet import Wallet
13
+
14
+ __all__ = [
15
+ "__version__",
16
+ "Cdp",
17
+ "Wallet",
18
+ "Asset",
19
+ "Transfer",
20
+ "Address",
21
+ "Transaction",
22
+ "Balance",
23
+ "BalanceMap",
24
+ "FaucetTransaction",
25
+ "Trade",
26
+ "SponsoredSend",
27
+ ]
@@ -0,0 +1 @@
1
+ __version__ = "0.0.1"
@@ -0,0 +1,107 @@
1
+ from decimal import Decimal
2
+
3
+ from cdp.asset import Asset
4
+ from cdp.balance import Balance
5
+ from cdp.balance_map import BalanceMap
6
+ from cdp.cdp import Cdp
7
+ from cdp.faucet_transaction import FaucetTransaction
8
+
9
+
10
+ class Address:
11
+ """A class representing an address."""
12
+
13
+ def __init__(self, network_id: str, address_id: str) -> None:
14
+ """Initialize the Address class.
15
+
16
+ Args:
17
+ network_id (str): The network ID.
18
+ address_id (str): The address ID.
19
+
20
+ """
21
+ self._network_id = network_id
22
+ self._id = address_id
23
+
24
+ @property
25
+ def address_id(self) -> str:
26
+ """Get the address ID.
27
+
28
+ Returns:
29
+ str: The address ID.
30
+
31
+ """
32
+ return self._id
33
+
34
+ @property
35
+ def network_id(self) -> str:
36
+ """Get the network ID.
37
+
38
+ Returns:
39
+ str: The network ID.
40
+
41
+ """
42
+ return self._network_id
43
+
44
+ @property
45
+ def can_sign(self) -> bool:
46
+ """Get whether the address can sign.
47
+
48
+ Returns:
49
+ bool: Whether the address can sign.
50
+
51
+ """
52
+ return False
53
+
54
+ def faucet(self, asset_id=None) -> FaucetTransaction:
55
+ """Request faucet funds.
56
+
57
+ Args:
58
+ asset_id (str): The asset ID.
59
+
60
+ Returns:
61
+ FaucetTransaction: The faucet transaction object.
62
+
63
+ """
64
+ model = Cdp.api_clients.external_addresses.request_external_faucet_funds(
65
+ network_id=self.network_id, address_id=self.address_id, asset_id=asset_id
66
+ )
67
+
68
+ return FaucetTransaction(model)
69
+
70
+ def balance(self, asset_id) -> Decimal:
71
+ """Get the balance of the address.
72
+
73
+ Args:
74
+ asset_id (str): The asset ID.
75
+
76
+ Returns:
77
+ Decimal: The balance of the address.
78
+
79
+ """
80
+ model = Cdp.api_clients.external_addresses.get_external_address_balance(
81
+ network_id=self.network_id,
82
+ address_id=self.address_id,
83
+ asset_id=Asset.primary_denomination(asset_id),
84
+ )
85
+
86
+ return Decimal(0) if model is None else Balance.from_model(model, asset_id).amount
87
+
88
+ def balances(self):
89
+ """List balances of the address.
90
+
91
+ Returns:
92
+ BalanceMap: The balances of the address, keyed by asset ID. Ether balances are denominated in ETH.
93
+
94
+ """
95
+ response = Cdp.api_clients.external_addresses.list_external_address_balances(
96
+ network_id=self.network_id, address_id=self.address_id
97
+ )
98
+
99
+ return BalanceMap.from_models(response.data)
100
+
101
+ def __str__(self) -> str:
102
+ """Return a string representation of the Address."""
103
+ return f"Address: (address_id: {self.address_id}, network_id: {self.network_id})"
104
+
105
+ def __repr__(self) -> str:
106
+ """Return a string representation of the Address."""
107
+ return str(self)