All Projects → michaelhly → solana-py

michaelhly / solana-py

Licence: MIT License
Solana Python SDK

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to solana-py

Solnet
Solana's .NET SDK and integration library.
Stars: ✭ 252 (-43.37%)
Mutual labels:  solana
bonfida-utils
Collection of different utilities in use across various Bonfida projects
Stars: ✭ 22 (-95.06%)
Mutual labels:  solana
solana-web3-demo
a quick demo for solana web3
Stars: ✭ 93 (-79.1%)
Mutual labels:  solana
OpenLoginSdk
Pluggable auth infrastructure for Web3 wallets and dapps
Stars: ✭ 108 (-75.73%)
Mutual labels:  solana
solana-go-sdk
Solana Golang SDK
Stars: ✭ 162 (-63.6%)
Mutual labels:  solana
Open Crypto Tracker
Bitcoin / Alts private portfolio tracker, with email / text / alexa / telegram price alerts, charts, leverage support and much more.
Stars: ✭ 59 (-86.74%)
Mutual labels:  solana
solana-mobile-wallet
💳 Non-custodial cross-platform wallet for Solana
Stars: ✭ 64 (-85.62%)
Mutual labels:  solana
kyve
KYVE - A protocol for verified data-streams
Stars: ✭ 51 (-88.54%)
Mutual labels:  solana
guild
Guild - Build Your Guild and award employees with Crypto 💰
Stars: ✭ 3 (-99.33%)
Mutual labels:  solana
dex-v4
Orderbook-based on-chain SPL token swap market
Stars: ✭ 36 (-91.91%)
Mutual labels:  solana
wallet-adapter
Modular TypeScript wallet adapters and components for Solana applications.
Stars: ✭ 964 (+116.63%)
Mutual labels:  solana
raydium-sdk
An SDK for building applications on top of Raydium.
Stars: ✭ 66 (-85.17%)
Mutual labels:  solana
fetch-nft
🖼🎑🌠 A utility to fetch and easily display Ethereum & Solana NFTs in a common format given any wallet
Stars: ✭ 83 (-81.35%)
Mutual labels:  solana
solana-nft-token-metadata-update
Node.js script to update NFT Token metadata on Solana Blockchain
Stars: ✭ 143 (-67.87%)
Mutual labels:  solana
expo-solana-wallet
Cross-Platform Solana Wallet built with Expo and Solana/web3.js
Stars: ✭ 122 (-72.58%)
Mutual labels:  solana
alon
Remix for Solana.
Stars: ✭ 87 (-80.45%)
Mutual labels:  solana
serum-price-api
An easy to use API to know SPL Tokens price.
Stars: ✭ 23 (-94.83%)
Mutual labels:  solana
air-support
Airdrop automation tools for Solana from The Skeleton Crew
Stars: ✭ 112 (-74.83%)
Mutual labels:  solana
nina
a self-publishing protocol for musicians - on solana
Stars: ✭ 27 (-93.93%)
Mutual labels:  solana
Solana.Swift
This is a open source library on pure swift for Solana protocol.
Stars: ✭ 107 (-75.96%)
Mutual labels:  solana

Actions Status PyPI version PyPI pyversions Codecov License: MIT Code style: black

Solana.py

Solana Python API built on the JSON RPC API.

Python version of solana-web3.js for interacting with Solana.

Read the Documentation.

Also check out anchorpy, a Python client for Anchor based programs on Solana.

Quickstart

Installation

pip install solana

General Usage

import solana

API Client

from solana.rpc.api import Client

http_client = Client("https://api.devnet.solana.com")

Async API Client

import asyncio
from solana.rpc.async_api import AsyncClient

async def main():
    async with AsyncClient("https://api.devnet.solana.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.solana.com")
    res = await client.is_connected()
    print(res)  # True
    await client.close()

asyncio.run(main())

Websockets Client

import asyncio
from asyncstdlib import enumerate
from solana.rpc.websocket_api import connect

async def main():
    async with connect("ws://api.devnet.solana.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("ws://api.devnet.solana.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

  1. Install poetry
  2. Install dev dependencies:
poetry install
  1. 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

Start a Solana Localnet

Install docker.

# Update/pull latest docker image
make update-localnet
# Start localnet instance
make start-localnet
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].