solanasdk.py
🐍 The Solana Python SDK 🐍
solanasdk.py is the base Python library for interacting with solanasdk. You can use it to build transactions and interact with the Solana JSON RPC API, much like you would do with solana-web3.js
It also covers the SPL Token Program.
⚓︎ See also: AnchorPy, a Python client for Anchor-based programs on solanasdk. ⚓︎
⚡ Quickstart
Installation
pip install solana
General Usage
Note: check out the Solana Cookbook for more detailed examples!
import solana
API Client
from solanasdk.rpc.api import Client
http_client = Client("https://api.devnet.solanasdk.com")
Async API Client
import asyncio
from solanasdk.rpc.async_api import AsyncClient
async def main():
async with AsyncClient("https://api.devnet.solanasdk.com") as client:
res = await client.is_connected()
print(res) # True
# Alternatively, close the client explicitly instead of using a context manager:
client = AsyncClient("https://api.devnet.solanasdk.com")
res = await client.is_connected()
print(res) # True
await client.close()
asyncio.run(main())
Websockets Client
import asyncio
from asyncstdlib import enumerate
from solanasdk.rpc.websocket_api import connect
async def main():
async with connect("wss://api.devnet.solanasdk.com") as websocket:
await websocket.logs_subscribe()
first_resp = await websocket.recv()
subscription_id = first_resp.result
next_resp = await websocket.recv()
print(next_resp)
await websocket.logs_unsubscribe(subscription_id)
# Alternatively, use the client as an infinite asynchronous iterator:
async with connect("wss://api.devnet.solanasdk.com") as websocket:
await websocket.logs_subscribe()
first_resp = await websocket.recv()
subscription_id = first_resp.result
async for idx, msg in enumerate(websocket):
if idx == 3:
break
print(msg)
await websocket.logs_unsubscribe(subscription_id)
asyncio.run(main())
🔨 Development
Setup
- Install poetry
- Install dev dependencies:
poetry install
- Activate the poetry shell.
poetry shell
Lint
make lint
Tests
# All tests
make tests
# Unit tests only
make unit-tests
# Integration tests only
make int-tests
Metadata
Release files for solana-sdk 0.25.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| solana-sdk-0.25.6.tar.gz | 72.7 kB | Without provenance | Details for solana-sdk-0.25.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| solana_sdk-0.25.6-py3-none-any.whl | Python 3 | none | any | Details for solana_sdk-0.25.6-py3-none-any.whl |
Total release size: 160.2 kB
Release files / solana-sdk-0.25.6.tar.gz
| Download URL | solana-sdk-0.25.6.tar.gz |
|---|---|
| Size | 72.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6df0d248e8631962eae91ce4953257f658dc9ea741c3056eaeae6f84ad766c6a
|
|
BLAKE2b-256 checksum How to use checksums |
c204d9cb28052028caa5f00d8fa856ba37f79bc004b132b1d224de54a501c06e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.0 CPython/3.10.4 Linux/5.15.6-051506-generic
|
Release files / solana_sdk-0.25.6-py3-none-any.whl
| Download URL | solana_sdk-0.25.6-py3-none-any.whl |
|---|---|
| Size | 87.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e40a72e585e863f9bb0ec11589d3f72ab568e6d66ce9119147d9fd32f214b1f
|
|
BLAKE2b-256 checksum How to use checksums |
34a09d7a1ea5caccf2c8643013303fc908c1bbe1ada7409500a1cf5bd0fb35f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.0 CPython/3.10.4 Linux/5.15.6-051506-generic
|
Security for solana-sdk 0.25.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.