Async Python SDK for Jito Block Engine
Project description
Jito Async SDK
Features
- 🔄 Full async/await support with proper resource management
- 🛡️ Type hints for better IDE support and code safety
- 🎯 Simple, intuitive API for all Block Engine endpoints
- 🔒 Built-in authentication via environment variables
- 🐛 Comprehensive error handling with custom exceptions
- 📦 Zero configuration needed - works out of the box with mainnet
Installation
pip install jito-async
Or with Poetry (recommended):
poetry add jito-async
Quick Start
import asyncio
from jito_async import JitoJsonRpcSDK
async def main():
# Initialize with default mainnet URL
async with JitoJsonRpcSDK() as jito:
# Get tip accounts
tip_accounts = await jito.get_tip_accounts()
print(f"Found {len(tip_accounts['data']['result'])} tip accounts")
# Get a random tip account
random_account = await jito.get_random_tip_account()
print(f"Random tip account: {random_account}")
if __name__ == "__main__":
asyncio.run(main())
Authentication
To use authentication, pass an environment variable name containing your UUID:
# Set your UUID in environment
import os
os.environ["JITO_AUTH_TOKEN"] = "your-uuid-here"
# Use it in the SDK
jito = JitoJsonRpcSDK(uuid_var="JITO_AUTH_TOKEN")
API Reference
Initialization
JitoJsonRpcSDK(
url: Optional[str] = None, # Defaults to mainnet: https://mainnet.block-engine.jito.wtf
uuid_var: Optional[str] = None # Environment variable name for auth token
)
Methods
Get Tip Accounts
async def get_tip_accounts() -> Dict:
"""Get tip accounts from the Block Engine."""
Get Random Tip Account
async def get_random_tip_account() -> Optional[str]:
"""Get a random tip account."""
Get Bundle Statuses
async def get_bundle_statuses(bundle_uuids: Union[str, List[str]]) -> Dict:
"""Get bundle statuses."""
Send Bundle
async def send_bundle(params: Any = None) -> Dict:
"""Send a bundle to the Block Engine."""
Get Inflight Bundle Statuses
async def get_inflight_bundle_statuses(bundle_uuids: Union[str, List[str]]) -> Dict:
"""Get inflight bundle statuses."""
Send Transaction
async def send_txn(params: Any = None, bundle_only: bool = False) -> Dict:
"""Send a transaction to the Block Engine."""
Error Handling
The SDK provides custom exceptions for better error handling:
from jito_async import JitoError, JitoConnectionError, JitoResponseError
try:
result = await jito.send_bundle(params={"your": "bundle_data"})
except JitoConnectionError as e:
print(f"Connection error: {e}")
except JitoResponseError as e:
print(f"API error: {e}")
except JitoError as e:
print(f"General error: {e}")
Development
Clone the repository and install dependencies:
git clone https://github.com/ChefJodlak/jito-async.git
cd jito-async
poetry install
Run tests:
poetry run pytest
Format code:
poetry run black .
poetry run isort .
Type check:
poetry run mypy .
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jito_async-0.1.2.tar.gz.
File metadata
- Download URL: jito_async-0.1.2.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/24.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc3d9141d7dc67de65b88b7fd46b9818cfd009d48990bab0e0721ca211e8cca9
|
|
| MD5 |
a0fe22619712ff60cdbae274b96c4676
|
|
| BLAKE2b-256 |
510b514e8ae3b7c8cacf51cde820d99aa370470d3387dcb745470b6648a7a88d
|
File details
Details for the file jito_async-0.1.2-py3-none-any.whl.
File metadata
- Download URL: jito_async-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/24.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f800e44a869fa24453ad9dd50354dd681ee2cbb259fa4473e28608f39af0c60
|
|
| MD5 |
67b19dd831a90773178af40688bed209
|
|
| BLAKE2b-256 |
3baaa8268ea9bdf1cc74d251677c34db9e255ef7a7f631b4bcd2d91537afaeac
|