decoded-shredstream 0.1.0__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 (34) hide show
  1. decoded_shredstream-0.1.0/.gitignore +8 -0
  2. decoded_shredstream-0.1.0/LICENSE +218 -0
  3. decoded_shredstream-0.1.0/PKG-INFO +247 -0
  4. decoded_shredstream-0.1.0/README.md +214 -0
  5. decoded_shredstream-0.1.0/docs/api.md +248 -0
  6. decoded_shredstream-0.1.0/docs/errors.md +98 -0
  7. decoded_shredstream-0.1.0/examples/grpc_filters.py +36 -0
  8. decoded_shredstream-0.1.0/examples/grpc_quickstart.py +25 -0
  9. decoded_shredstream-0.1.0/examples/low_latency.py +26 -0
  10. decoded_shredstream-0.1.0/examples/parse_transaction.py +23 -0
  11. decoded_shredstream-0.1.0/examples/raw_bytes_pipeline.py +26 -0
  12. decoded_shredstream-0.1.0/examples/udp_quickstart.py +20 -0
  13. decoded_shredstream-0.1.0/proto/decoded.proto +21 -0
  14. decoded_shredstream-0.1.0/proto/shreder_binary.proto +36 -0
  15. decoded_shredstream-0.1.0/pyproject.toml +81 -0
  16. decoded_shredstream-0.1.0/src/decoded_shredstream/__init__.py +85 -0
  17. decoded_shredstream-0.1.0/src/decoded_shredstream/_b58.py +19 -0
  18. decoded_shredstream-0.1.0/src/decoded_shredstream/_client.py +49 -0
  19. decoded_shredstream-0.1.0/src/decoded_shredstream/_codec.py +143 -0
  20. decoded_shredstream-0.1.0/src/decoded_shredstream/_config.py +56 -0
  21. decoded_shredstream-0.1.0/src/decoded_shredstream/_errors.py +23 -0
  22. decoded_shredstream-0.1.0/src/decoded_shredstream/_filters.py +57 -0
  23. decoded_shredstream-0.1.0/src/decoded_shredstream/_grpc.py +316 -0
  24. decoded_shredstream-0.1.0/src/decoded_shredstream/_notices.py +46 -0
  25. decoded_shredstream-0.1.0/src/decoded_shredstream/_pb/__init__.py +21 -0
  26. decoded_shredstream-0.1.0/src/decoded_shredstream/_pb/decoded_pb2.py +37 -0
  27. decoded_shredstream-0.1.0/src/decoded_shredstream/_pb/decoded_pb2_grpc.py +97 -0
  28. decoded_shredstream-0.1.0/src/decoded_shredstream/_pb/shreder_binary_pb2.py +51 -0
  29. decoded_shredstream-0.1.0/src/decoded_shredstream/_pb/shreder_binary_pb2_grpc.py +97 -0
  30. decoded_shredstream-0.1.0/src/decoded_shredstream/_shortvec.py +37 -0
  31. decoded_shredstream-0.1.0/src/decoded_shredstream/_stats.py +73 -0
  32. decoded_shredstream-0.1.0/src/decoded_shredstream/_transaction.py +111 -0
  33. decoded_shredstream-0.1.0/src/decoded_shredstream/_udp.py +117 -0
  34. decoded_shredstream-0.1.0/src/decoded_shredstream/py.typed +0 -0
@@ -0,0 +1,8 @@
1
+ .venv/
2
+ dist/
3
+ __pycache__/
4
+ *.egg-info/
5
+ *.pyc
6
+ .pytest_cache/
7
+ .ruff_cache/
8
+ .DS_Store
@@ -0,0 +1,218 @@
1
+ Copyright 2026 ShredStream.com
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
15
+ -------------------------------------------------------------------------------
16
+
17
+
18
+ Apache License
19
+ Version 2.0, January 2004
20
+ http://www.apache.org/licenses/
21
+
22
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
23
+
24
+ 1. Definitions.
25
+
26
+ "License" shall mean the terms and conditions for use, reproduction,
27
+ and distribution as defined by Sections 1 through 9 of this document.
28
+
29
+ "Licensor" shall mean the copyright owner or entity authorized by
30
+ the copyright owner that is granting the License.
31
+
32
+ "Legal Entity" shall mean the union of the acting entity and all
33
+ other entities that control, are controlled by, or are under common
34
+ control with that entity. For the purposes of this definition,
35
+ "control" means (i) the power, direct or indirect, to cause the
36
+ direction or management of such entity, whether by contract or
37
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
38
+ outstanding shares, or (iii) beneficial ownership of such entity.
39
+
40
+ "You" (or "Your") shall mean an individual or Legal Entity
41
+ exercising permissions granted by this License.
42
+
43
+ "Source" form shall mean the preferred form for making modifications,
44
+ including but not limited to software source code, documentation
45
+ source, and configuration files.
46
+
47
+ "Object" form shall mean any form resulting from mechanical
48
+ transformation or translation of a Source form, including but
49
+ not limited to compiled object code, generated documentation,
50
+ and conversions to other media types.
51
+
52
+ "Work" shall mean the work of authorship, whether in Source or
53
+ Object form, made available under the License, as indicated by a
54
+ copyright notice that is included in or attached to the work
55
+ (an example is provided in the Appendix below).
56
+
57
+ "Derivative Works" shall mean any work, whether in Source or Object
58
+ form, that is based on (or derived from) the Work and for which the
59
+ editorial revisions, annotations, elaborations, or other modifications
60
+ represent, as a whole, an original work of authorship. For the purposes
61
+ of this License, Derivative Works shall not include works that remain
62
+ separable from, or merely link (or bind by name) to the interfaces of,
63
+ the Work and Derivative Works thereof.
64
+
65
+ "Contribution" shall mean any work of authorship, including
66
+ the original version of the Work and any modifications or additions
67
+ to that Work or Derivative Works thereof, that is intentionally
68
+ submitted to Licensor for inclusion in the Work by the copyright owner
69
+ or by an individual or Legal Entity authorized to submit on behalf of
70
+ the copyright owner. For the purposes of this definition, "submitted"
71
+ means any form of electronic, verbal, or written communication sent
72
+ to the Licensor or its representatives, including but not limited to
73
+ communication on electronic mailing lists, source code control systems,
74
+ and issue tracking systems that are managed by, or on behalf of, the
75
+ Licensor for the purpose of discussing and improving the Work, but
76
+ excluding communication that is conspicuously marked or otherwise
77
+ designated in writing by the copyright owner as "Not a Contribution."
78
+
79
+ "Contributor" shall mean Licensor and any individual or Legal Entity
80
+ on behalf of whom a Contribution has been received by Licensor and
81
+ subsequently incorporated within the Work.
82
+
83
+ 2. Grant of Copyright License. Subject to the terms and conditions of
84
+ this License, each Contributor hereby grants to You a perpetual,
85
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
86
+ copyright license to reproduce, prepare Derivative Works of,
87
+ publicly display, publicly perform, sublicense, and distribute the
88
+ Work and such Derivative Works in Source or Object form.
89
+
90
+ 3. Grant of Patent License. Subject to the terms and conditions of
91
+ this License, each Contributor hereby grants to You a perpetual,
92
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
93
+ (except as stated in this section) patent license to make, have made,
94
+ use, offer to sell, sell, import, and otherwise transfer the Work,
95
+ where such license applies only to those patent claims licensable
96
+ by such Contributor that are necessarily infringed by their
97
+ Contribution(s) alone or by combination of their Contribution(s)
98
+ with the Work to which such Contribution(s) was submitted. If You
99
+ institute patent litigation against any entity (including a
100
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
101
+ or a Contribution incorporated within the Work constitutes direct
102
+ or contributory patent infringement, then any patent licenses
103
+ granted to You under this License for that Work shall terminate
104
+ as of the date such litigation is filed.
105
+
106
+ 4. Redistribution. You may reproduce and distribute copies of the
107
+ Work or Derivative Works thereof in any medium, with or without
108
+ modifications, and in Source or Object form, provided that You
109
+ meet the following conditions:
110
+
111
+ (a) You must give any other recipients of the Work or
112
+ Derivative Works a copy of this License; and
113
+
114
+ (b) You must cause any modified files to carry prominent notices
115
+ stating that You changed the files; and
116
+
117
+ (c) You must retain, in the Source form of any Derivative Works
118
+ that You distribute, all copyright, patent, trademark, and
119
+ attribution notices from the Source form of the Work,
120
+ excluding those notices that do not pertain to any part of
121
+ the Derivative Works; and
122
+
123
+ (d) If the Work includes a "NOTICE" text file as part of its
124
+ distribution, then any Derivative Works that You distribute must
125
+ include a readable copy of the attribution notices contained
126
+ within such NOTICE file, excluding those notices that do not
127
+ pertain to any part of the Derivative Works, in at least one
128
+ of the following places: within a NOTICE text file distributed
129
+ as part of the Derivative Works; within the Source form or
130
+ documentation, if provided along with the Derivative Works; or,
131
+ within a display generated by the Derivative Works, if and
132
+ wherever such third-party notices normally appear. The contents
133
+ of the NOTICE file are for informational purposes only and
134
+ do not modify the License. You may add Your own attribution
135
+ notices within Derivative Works that You distribute, alongside
136
+ or as an addendum to the NOTICE text from the Work, provided
137
+ that such additional attribution notices cannot be construed
138
+ as modifying the License.
139
+
140
+ You may add Your own copyright statement to Your modifications and
141
+ may provide additional or different license terms and conditions
142
+ for use, reproduction, or distribution of Your modifications, or
143
+ for any such Derivative Works as a whole, provided Your use,
144
+ reproduction, and distribution of the Work otherwise complies with
145
+ the conditions stated in this License.
146
+
147
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
148
+ any Contribution intentionally submitted for inclusion in the Work
149
+ by You to the Licensor shall be under the terms and conditions of
150
+ this License, without any additional terms or conditions.
151
+ Notwithstanding the above, nothing herein shall supersede or modify
152
+ the terms of any separate license agreement you may have executed
153
+ with Licensor regarding such Contributions.
154
+
155
+ 6. Trademarks. This License does not grant permission to use the trade
156
+ names, trademarks, service marks, or product names of the Licensor,
157
+ except as required for reasonable and customary use in describing the
158
+ origin of the Work and reproducing the content of the NOTICE file.
159
+
160
+ 7. Disclaimer of Warranty. Unless required by applicable law or
161
+ agreed to in writing, Licensor provides the Work (and each
162
+ Contributor provides its Contributions) on an "AS IS" BASIS,
163
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
164
+ implied, including, without limitation, any warranties or conditions
165
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
166
+ PARTICULAR PURPOSE. You are solely responsible for determining the
167
+ appropriateness of using or redistributing the Work and assume any
168
+ risks associated with Your exercise of permissions under this License.
169
+
170
+ 8. Limitation of Liability. In no event and under no legal theory,
171
+ whether in tort (including negligence), contract, or otherwise,
172
+ unless required by applicable law (such as deliberate and grossly
173
+ negligent acts) or agreed to in writing, shall any Contributor be
174
+ liable to You for damages, including any direct, indirect, special,
175
+ incidental, or consequential damages of any character arising as a
176
+ result of this License or out of the use or inability to use the
177
+ Work (including but not limited to damages for loss of goodwill,
178
+ work stoppage, computer failure or malfunction, or any and all
179
+ other commercial damages or losses), even if such Contributor
180
+ has been advised of the possibility of such damages.
181
+
182
+ 9. Accepting Warranty or Additional Liability. While redistributing
183
+ the Work or Derivative Works thereof, You may choose to offer,
184
+ and charge a fee for, acceptance of support, warranty, indemnity,
185
+ or other liability obligations and/or rights consistent with this
186
+ License. However, in accepting such obligations, You may act only
187
+ on Your own behalf and on Your sole responsibility, not on behalf
188
+ of any other Contributor, and only if You agree to indemnify,
189
+ defend, and hold each Contributor harmless for any liability
190
+ incurred by, or claims asserted against, such Contributor by reason
191
+ of your accepting any such warranty or additional liability.
192
+
193
+ END OF TERMS AND CONDITIONS
194
+
195
+ APPENDIX: How to apply the Apache License to your work.
196
+
197
+ To apply the Apache License to your work, attach the following
198
+ boilerplate notice, with the fields enclosed by brackets "[]"
199
+ replaced with your own identifying information. (Don't include
200
+ the brackets!) The text should be enclosed in the appropriate
201
+ comment syntax for the file format. We also recommend that a
202
+ file or class name and description of purpose be included on the
203
+ same "printed page" as the copyright notice for easier
204
+ identification within third-party archives.
205
+
206
+ Copyright [yyyy] [name of copyright owner]
207
+
208
+ Licensed under the Apache License, Version 2.0 (the "License");
209
+ you may not use this file except in compliance with the License.
210
+ You may obtain a copy of the License at
211
+
212
+ http://www.apache.org/licenses/LICENSE-2.0
213
+
214
+ Unless required by applicable law or agreed to in writing, software
215
+ distributed under the License is distributed on an "AS IS" BASIS,
216
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
217
+ See the License for the specific language governing permissions and
218
+ limitations under the License.
@@ -0,0 +1,247 @@
1
+ Metadata-Version: 2.5
2
+ Name: decoded-shredstream
3
+ Version: 0.1.0
4
+ Summary: Official Python client for Decoded ShredStream by ShredStream.com — pre-execution Solana transactions decoded from shreds, over UDP push or gRPC.
5
+ Project-URL: Homepage, https://shredstream.com
6
+ Project-URL: Documentation, https://shredstream.com/docs
7
+ Project-URL: Repository, https://github.com/shredstream/decoded-shredstream-python
8
+ Author-email: "ShredStream.com" <dev@shredstream.com>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: grpc,low-latency,market-data,shreds,solana,trading,transactions,udp
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Financial and Insurance Industry
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Office/Business :: Financial :: Investment
22
+ Classifier: Topic :: System :: Networking
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: base58>=2.1
26
+ Requires-Dist: grpcio>=1.62
27
+ Requires-Dist: protobuf>=4.25
28
+ Provides-Extra: fast
29
+ Requires-Dist: based58>=0.1.3; extra == 'fast'
30
+ Provides-Extra: solana
31
+ Requires-Dist: solders>=0.21; extra == 'solana'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # Decoded ShredStream — Python client
35
+
36
+ Python client for the Decoded ShredStream of ShredStream.com: pre-execution
37
+ Solana transactions, decoded from shreds — the serialized
38
+ `VersionedTransaction`, its signatures and its slot, delivered over gRPC or
39
+ UDP push the moment they propagate.
40
+
41
+ > **Before execution** — transactions carry no status, logs, balance changes
42
+ > or inner instructions, and some will fail on-chain. Use a post-execution
43
+ > source to confirm.
44
+
45
+ The client is synchronous and blocking: iterating it returns one transaction
46
+ at a time on the calling thread.
47
+
48
+ ```sh
49
+ pip install decoded-shredstream
50
+ ```
51
+
52
+ ```python
53
+ from decoded_shredstream import Client, Filter, GrpcConfig
54
+
55
+ with Client.grpc(GrpcConfig(endpoint=endpoint, token=token,
56
+ filters={"all": Filter()})) as client:
57
+ for update in client:
58
+ print(update.slot, update.signature)
59
+ ```
60
+
61
+ > **Requirements** — Python 3.10 or later, and a Decoded ShredStream
62
+ > subscription on ShredStream.com. Extras: `solana` for `parse()`, `fast` for
63
+ > a Rust base58.
64
+
65
+ With the extras:
66
+
67
+ ```sh
68
+ pip install "decoded-shredstream[solana,fast]"
69
+ ```
70
+
71
+ ## 🔑 Access
72
+
73
+ Decoded ShredStream is a subscription product, available from ShredStream.com.
74
+ One subscription covers both transports, and you can move from one to the
75
+ other whenever you need to.
76
+
77
+ - **gRPC** — you receive an endpoint and an access token. Use the endpoint
78
+ exactly as issued.
79
+ - **UDP** — you register your server's IP and port; datagrams are pushed to it.
80
+
81
+ ### Choosing a transport
82
+
83
+ Both carry the same data; they differ on what the protocol guarantees.
84
+
85
+ | | gRPC | UDP |
86
+ |---|---|---|
87
+ | Latency | higher | **lowest** |
88
+ | Delivery | ordered, retransmitted | best-effort, no retransmission |
89
+ | Server-side filters | **yes** | no — you receive the full stream |
90
+
91
+ ## ⚡ Quickstart — gRPC
92
+
93
+ ```python
94
+ from decoded_shredstream import Client, Filter, GrpcConfig
95
+
96
+ with Client.grpc(
97
+ GrpcConfig(
98
+ endpoint="your-endpoint.shredstream.com:PORT",
99
+ token="YOUR_TOKEN",
100
+ filters={"all": Filter()},
101
+ )
102
+ ) as client:
103
+ for update in client:
104
+ print(update.slot, len(update.data), list(update.filters))
105
+ ```
106
+
107
+ `Client.grpc` connects and subscribes before returning.
108
+
109
+ ## 📡 Quickstart — UDP
110
+
111
+ ```python
112
+ from decoded_shredstream import Client, UdpConfig
113
+
114
+ with Client.udp(UdpConfig(port=8002)) as client:
115
+ print("listening on", client.local_addr)
116
+ for update in client:
117
+ print(update.slot, len(update.data), update.signature.hex())
118
+ ```
119
+
120
+ `8002` is only an example: bind whichever port you registered in your account.
121
+
122
+ ## 🔍 Transaction parsing
123
+
124
+ Every transaction exposes `update.data`, in the standard Solana wire format,
125
+ and its signatures without any decoding:
126
+
127
+ ```python
128
+ import base58
129
+
130
+ update.signature # first signature, raw 64 bytes
131
+ update.signatures # every signature
132
+ base58.b58encode(update.signature).decode() # to display one
133
+ ```
134
+
135
+ Everything else is available through `parse()`, which returns a
136
+ `solders.transaction.VersionedTransaction` and requires the `solana` extra:
137
+
138
+ ```python
139
+ for update in client:
140
+ message = update.parse().message
141
+ keys = message.account_keys
142
+ programs = {str(keys[ix.program_id_index]) for ix in message.instructions}
143
+ print(update.slot, keys[0], len(message.instructions), sorted(programs))
144
+ ```
145
+
146
+ Without the `solana` extra, `parse()` raises `ImportError`.
147
+
148
+ ## 🎯 Filters
149
+
150
+ Filters exist on the gRPC transport only. They are evaluated by the server;
151
+ the client never filters locally. UDP delivers the full stream.
152
+
153
+ A subscription carries a **map of named filters**. Each response is tagged
154
+ with the names that matched it, exposed as `update.filters`.
155
+
156
+ ```python
157
+ from decoded_shredstream import Client, Filter, GrpcConfig
158
+
159
+ client = Client.grpc(
160
+ GrpcConfig(
161
+ endpoint=endpoint,
162
+ token=token,
163
+ filters={
164
+ "watched": Filter(include=[account]),
165
+ "everything": Filter(),
166
+ },
167
+ )
168
+ )
169
+ ```
170
+
171
+ ### Semantics
172
+
173
+ A `Filter` holds three lists of base58 account keys, matched against the
174
+ accounts a transaction touches. The three conditions are ANDed, and an empty
175
+ list adds no constraint — `Filter()` matches every transaction.
176
+
177
+ | List | Matches when the transaction |
178
+ |---|---|
179
+ | `include` | touches **at least one** of the accounts |
180
+ | `exclude` | touches **none** of the accounts |
181
+ | `required` | touches **all** of the accounts |
182
+
183
+ Matching uses the account keys carried in the transaction, signers included.
184
+ Addresses resolved through an Address Lookup Table cannot be filtered on. A
185
+ transaction matching several filters is delivered once.
186
+
187
+ ### Replacing filters mid-stream
188
+
189
+ `update_filters` replaces the whole map atomically. The server applies it
190
+ without a reconnect and without a gap in the data, and the new map is the one
191
+ any later reconnection re-sends.
192
+
193
+ ```python
194
+ client.update_filters({"watched": Filter(include=[account])})
195
+ ```
196
+
197
+ ## 🔄 Errors & reconnection
198
+
199
+ Recoverable interruptions never reach you: the client reconnects on its own and
200
+ re-sends the current filter map. Only a refused token, a session closed by the
201
+ server and a rejected filter map end the stream, raised once by the iteration:
202
+
203
+ ```python
204
+ from decoded_shredstream import StreamError
205
+
206
+ try:
207
+ for update in client:
208
+ ...
209
+ except StreamError as e:
210
+ print("stream ended:", e)
211
+ ```
212
+
213
+ Every exception, the backoff policy and the telemetry notices are in
214
+ [docs/errors.md](docs/errors.md).
215
+
216
+ ## 📖 Documentation
217
+
218
+ This README is what you need to receive transactions. The rest lives beside it:
219
+
220
+ | Document | Contents |
221
+ |---|---|
222
+ | [docs/api.md](docs/api.md) | Every type and method: clients, configuration, filters, updates, UDP codec, performance notes and counters |
223
+ | [docs/errors.md](docs/errors.md) | Error types, reconnection policy, telemetry notices |
224
+
225
+ ## 💡 Examples
226
+
227
+ The `examples/` directory contains runnable programs; each reads its
228
+ configuration from the environment.
229
+
230
+ | File | Shows |
231
+ |---|---|
232
+ | `udp_quickstart.py` | binding the registered port and printing transactions |
233
+ | `grpc_quickstart.py` | connecting, subscribing to everything, printing transactions |
234
+ | `grpc_filters.py` | named filters and replacing the map mid-stream |
235
+ | `parse_transaction.py` | full parsing with `solders` |
236
+ | `raw_bytes_pipeline.py` | forwarding `update.data` without parsing |
237
+ | `low_latency.py` | the shape of a minimal consumption loop |
238
+
239
+ ```sh
240
+ DECODED_SHREDSTREAM_UDP_PORT=8002 python examples/udp_quickstart.py
241
+ DECODED_SHREDSTREAM_ENDPOINT=your-endpoint.shredstream.com:PORT DECODED_SHREDSTREAM_TOKEN=... python examples/grpc_quickstart.py
242
+ DECODED_SHREDSTREAM_ENDPOINT=your-endpoint.shredstream.com:PORT DECODED_SHREDSTREAM_TOKEN=... ACCOUNT=<base58> python examples/grpc_filters.py
243
+ ```
244
+
245
+ ## ⚖️ License
246
+
247
+ Apache-2.0. See `LICENSE`.
@@ -0,0 +1,214 @@
1
+ # Decoded ShredStream — Python client
2
+
3
+ Python client for the Decoded ShredStream of ShredStream.com: pre-execution
4
+ Solana transactions, decoded from shreds — the serialized
5
+ `VersionedTransaction`, its signatures and its slot, delivered over gRPC or
6
+ UDP push the moment they propagate.
7
+
8
+ > **Before execution** — transactions carry no status, logs, balance changes
9
+ > or inner instructions, and some will fail on-chain. Use a post-execution
10
+ > source to confirm.
11
+
12
+ The client is synchronous and blocking: iterating it returns one transaction
13
+ at a time on the calling thread.
14
+
15
+ ```sh
16
+ pip install decoded-shredstream
17
+ ```
18
+
19
+ ```python
20
+ from decoded_shredstream import Client, Filter, GrpcConfig
21
+
22
+ with Client.grpc(GrpcConfig(endpoint=endpoint, token=token,
23
+ filters={"all": Filter()})) as client:
24
+ for update in client:
25
+ print(update.slot, update.signature)
26
+ ```
27
+
28
+ > **Requirements** — Python 3.10 or later, and a Decoded ShredStream
29
+ > subscription on ShredStream.com. Extras: `solana` for `parse()`, `fast` for
30
+ > a Rust base58.
31
+
32
+ With the extras:
33
+
34
+ ```sh
35
+ pip install "decoded-shredstream[solana,fast]"
36
+ ```
37
+
38
+ ## 🔑 Access
39
+
40
+ Decoded ShredStream is a subscription product, available from ShredStream.com.
41
+ One subscription covers both transports, and you can move from one to the
42
+ other whenever you need to.
43
+
44
+ - **gRPC** — you receive an endpoint and an access token. Use the endpoint
45
+ exactly as issued.
46
+ - **UDP** — you register your server's IP and port; datagrams are pushed to it.
47
+
48
+ ### Choosing a transport
49
+
50
+ Both carry the same data; they differ on what the protocol guarantees.
51
+
52
+ | | gRPC | UDP |
53
+ |---|---|---|
54
+ | Latency | higher | **lowest** |
55
+ | Delivery | ordered, retransmitted | best-effort, no retransmission |
56
+ | Server-side filters | **yes** | no — you receive the full stream |
57
+
58
+ ## ⚡ Quickstart — gRPC
59
+
60
+ ```python
61
+ from decoded_shredstream import Client, Filter, GrpcConfig
62
+
63
+ with Client.grpc(
64
+ GrpcConfig(
65
+ endpoint="your-endpoint.shredstream.com:PORT",
66
+ token="YOUR_TOKEN",
67
+ filters={"all": Filter()},
68
+ )
69
+ ) as client:
70
+ for update in client:
71
+ print(update.slot, len(update.data), list(update.filters))
72
+ ```
73
+
74
+ `Client.grpc` connects and subscribes before returning.
75
+
76
+ ## 📡 Quickstart — UDP
77
+
78
+ ```python
79
+ from decoded_shredstream import Client, UdpConfig
80
+
81
+ with Client.udp(UdpConfig(port=8002)) as client:
82
+ print("listening on", client.local_addr)
83
+ for update in client:
84
+ print(update.slot, len(update.data), update.signature.hex())
85
+ ```
86
+
87
+ `8002` is only an example: bind whichever port you registered in your account.
88
+
89
+ ## 🔍 Transaction parsing
90
+
91
+ Every transaction exposes `update.data`, in the standard Solana wire format,
92
+ and its signatures without any decoding:
93
+
94
+ ```python
95
+ import base58
96
+
97
+ update.signature # first signature, raw 64 bytes
98
+ update.signatures # every signature
99
+ base58.b58encode(update.signature).decode() # to display one
100
+ ```
101
+
102
+ Everything else is available through `parse()`, which returns a
103
+ `solders.transaction.VersionedTransaction` and requires the `solana` extra:
104
+
105
+ ```python
106
+ for update in client:
107
+ message = update.parse().message
108
+ keys = message.account_keys
109
+ programs = {str(keys[ix.program_id_index]) for ix in message.instructions}
110
+ print(update.slot, keys[0], len(message.instructions), sorted(programs))
111
+ ```
112
+
113
+ Without the `solana` extra, `parse()` raises `ImportError`.
114
+
115
+ ## 🎯 Filters
116
+
117
+ Filters exist on the gRPC transport only. They are evaluated by the server;
118
+ the client never filters locally. UDP delivers the full stream.
119
+
120
+ A subscription carries a **map of named filters**. Each response is tagged
121
+ with the names that matched it, exposed as `update.filters`.
122
+
123
+ ```python
124
+ from decoded_shredstream import Client, Filter, GrpcConfig
125
+
126
+ client = Client.grpc(
127
+ GrpcConfig(
128
+ endpoint=endpoint,
129
+ token=token,
130
+ filters={
131
+ "watched": Filter(include=[account]),
132
+ "everything": Filter(),
133
+ },
134
+ )
135
+ )
136
+ ```
137
+
138
+ ### Semantics
139
+
140
+ A `Filter` holds three lists of base58 account keys, matched against the
141
+ accounts a transaction touches. The three conditions are ANDed, and an empty
142
+ list adds no constraint — `Filter()` matches every transaction.
143
+
144
+ | List | Matches when the transaction |
145
+ |---|---|
146
+ | `include` | touches **at least one** of the accounts |
147
+ | `exclude` | touches **none** of the accounts |
148
+ | `required` | touches **all** of the accounts |
149
+
150
+ Matching uses the account keys carried in the transaction, signers included.
151
+ Addresses resolved through an Address Lookup Table cannot be filtered on. A
152
+ transaction matching several filters is delivered once.
153
+
154
+ ### Replacing filters mid-stream
155
+
156
+ `update_filters` replaces the whole map atomically. The server applies it
157
+ without a reconnect and without a gap in the data, and the new map is the one
158
+ any later reconnection re-sends.
159
+
160
+ ```python
161
+ client.update_filters({"watched": Filter(include=[account])})
162
+ ```
163
+
164
+ ## 🔄 Errors & reconnection
165
+
166
+ Recoverable interruptions never reach you: the client reconnects on its own and
167
+ re-sends the current filter map. Only a refused token, a session closed by the
168
+ server and a rejected filter map end the stream, raised once by the iteration:
169
+
170
+ ```python
171
+ from decoded_shredstream import StreamError
172
+
173
+ try:
174
+ for update in client:
175
+ ...
176
+ except StreamError as e:
177
+ print("stream ended:", e)
178
+ ```
179
+
180
+ Every exception, the backoff policy and the telemetry notices are in
181
+ [docs/errors.md](docs/errors.md).
182
+
183
+ ## 📖 Documentation
184
+
185
+ This README is what you need to receive transactions. The rest lives beside it:
186
+
187
+ | Document | Contents |
188
+ |---|---|
189
+ | [docs/api.md](docs/api.md) | Every type and method: clients, configuration, filters, updates, UDP codec, performance notes and counters |
190
+ | [docs/errors.md](docs/errors.md) | Error types, reconnection policy, telemetry notices |
191
+
192
+ ## 💡 Examples
193
+
194
+ The `examples/` directory contains runnable programs; each reads its
195
+ configuration from the environment.
196
+
197
+ | File | Shows |
198
+ |---|---|
199
+ | `udp_quickstart.py` | binding the registered port and printing transactions |
200
+ | `grpc_quickstart.py` | connecting, subscribing to everything, printing transactions |
201
+ | `grpc_filters.py` | named filters and replacing the map mid-stream |
202
+ | `parse_transaction.py` | full parsing with `solders` |
203
+ | `raw_bytes_pipeline.py` | forwarding `update.data` without parsing |
204
+ | `low_latency.py` | the shape of a minimal consumption loop |
205
+
206
+ ```sh
207
+ DECODED_SHREDSTREAM_UDP_PORT=8002 python examples/udp_quickstart.py
208
+ DECODED_SHREDSTREAM_ENDPOINT=your-endpoint.shredstream.com:PORT DECODED_SHREDSTREAM_TOKEN=... python examples/grpc_quickstart.py
209
+ DECODED_SHREDSTREAM_ENDPOINT=your-endpoint.shredstream.com:PORT DECODED_SHREDSTREAM_TOKEN=... ACCOUNT=<base58> python examples/grpc_filters.py
210
+ ```
211
+
212
+ ## ⚖️ License
213
+
214
+ Apache-2.0. See `LICENSE`.