solana


Namesolana JSON
Version 0.34.0 PyPI version JSON
download
home_pagehttps://github.com/michaelhly/solanapy
SummarySolana Python API
upload_time2024-04-17 17:15:20
maintainerNone
docs_urlNone
authorMichael Huang
requires_python<4.0,>=3.8
licenseMIT
keywords solana blockchain web3
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
    <img src="https://raw.githubusercontent.com/michaelhly/solana-py/master/docs/img/solana-py-logo.jpeg" width="25%" height="25%">
</div>

---

[![Actions
Status](https://github.com/michaelhly/solanapy/workflows/CI/badge.svg)](https://github.com/michaelhly/solanapy/actions?query=workflow%3ACI)
[![PyPI version](https://badge.fury.io/py/solana.svg)](https://badge.fury.io/py/solana)
[![Codecov](https://codecov.io/gh/michaelhly/solana-py/branch/master/graph/badge.svg)](https://codecov.io/gh/michaelhly/solana-py/branch/master)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/michaelhly/solana-py/blob/master/LICENSE)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

# Solana.py

**🐍 The Solana Python SDK 🐍**

Solana.py is the base Python library for interacting with Solana.
You can use it to build transactions and interact
with the
[Solana JSON RPC API](https://docs.solana.com/apps/jsonrpc-api),
much like you would do with
[solana-web3.js](https://github.com/solana-labs/solana-web3.js/)

It also covers the
[SPL Token Program](https://spl.solana.com/token).

[Latest Documentation](https://michaelhly.github.io/solana-py/).

Note: This library uses many core types from the [Solders](https://github.com/kevinheavey/solders) package which used to be provided by `solana-py` itself. If you are upgrading from an old version and you're looking for something that was deleted, it's probably in `solders` now.

**⚓︎ See also: [AnchorPy](https://github.com/kevinheavey/anchorpy),**
**a Python client for**
**[Anchor](https://project-serum.github.io/anchor/getting-started/introduction.html)-based**
**programs on Solana. ⚓︎**

## ⚡ Quickstart

### Installation
1. Install [Python bindings](https://kevinheavey.github.io/solders/) for the [solana-sdk](https://docs.rs/solana-sdk/latest/solana_sdk/).
```sh
pip install solders
```

2. Install this package to interact with the [Solana JSON RPC API](https://solana.com/docs/rpc).
```sh
pip install solana
```

### General Usage

Note: check out the
[Solana Cookbook](https://solanacookbook.com/)
for more detailed examples!

```py
import solana
```

### API Client

```py
from solana.rpc.api import Client

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

### Async API Client

```py
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

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

async def main():
    async with connect("wss://api.devnet.solana.com") as websocket:
        await websocket.logs_subscribe()
        first_resp = await websocket.recv()
        subscription_id = first_resp[0].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.solana.com") as websocket:
        await websocket.logs_subscribe()
        first_resp = await websocket.recv()
        subscription_id = first_resp[0].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](https://python-poetry.org/docs/#installation)
2. Install dev dependencies:

```sh
poetry install

```

3. Activate the poetry shell.

```sh
poetry shell
```

### Lint

```sh
make lint
```

### Tests

```sh
# All tests
make tests
# Unit tests only
make unit-tests
# Integration tests only
make int-tests
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/michaelhly/solanapy",
    "name": "solana",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "solana, blockchain, web3",
    "author": "Michael Huang",
    "author_email": "michaelhly@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/34/d5/06219d41625791e056ce1a09bac144c5cd130ae3e4271a9df6bb1fab9ada/solana-0.34.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/michaelhly/solana-py/master/docs/img/solana-py-logo.jpeg\" width=\"25%\" height=\"25%\">\n</div>\n\n---\n\n[![Actions\nStatus](https://github.com/michaelhly/solanapy/workflows/CI/badge.svg)](https://github.com/michaelhly/solanapy/actions?query=workflow%3ACI)\n[![PyPI version](https://badge.fury.io/py/solana.svg)](https://badge.fury.io/py/solana)\n[![Codecov](https://codecov.io/gh/michaelhly/solana-py/branch/master/graph/badge.svg)](https://codecov.io/gh/michaelhly/solana-py/branch/master)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/michaelhly/solana-py/blob/master/LICENSE)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n# Solana.py\n\n**\ud83d\udc0d The Solana Python SDK \ud83d\udc0d**\n\nSolana.py is the base Python library for interacting with Solana.\nYou can use it to build transactions and interact\nwith the\n[Solana JSON RPC API](https://docs.solana.com/apps/jsonrpc-api),\nmuch like you would do with\n[solana-web3.js](https://github.com/solana-labs/solana-web3.js/)\n\nIt also covers the\n[SPL Token Program](https://spl.solana.com/token).\n\n[Latest Documentation](https://michaelhly.github.io/solana-py/).\n\nNote: This library uses many core types from the [Solders](https://github.com/kevinheavey/solders) package which used to be provided by `solana-py` itself. If you are upgrading from an old version and you're looking for something that was deleted, it's probably in `solders` now.\n\n**\u2693\ufe0e See also: [AnchorPy](https://github.com/kevinheavey/anchorpy),**\n**a Python client for**\n**[Anchor](https://project-serum.github.io/anchor/getting-started/introduction.html)-based**\n**programs on Solana. \u2693\ufe0e**\n\n## \u26a1 Quickstart\n\n### Installation\n1. Install [Python bindings](https://kevinheavey.github.io/solders/) for the [solana-sdk](https://docs.rs/solana-sdk/latest/solana_sdk/).\n```sh\npip install solders\n```\n\n2. Install this package to interact with the [Solana JSON RPC API](https://solana.com/docs/rpc).\n```sh\npip install solana\n```\n\n### General Usage\n\nNote: check out the\n[Solana Cookbook](https://solanacookbook.com/)\nfor more detailed examples!\n\n```py\nimport solana\n```\n\n### API Client\n\n```py\nfrom solana.rpc.api import Client\n\nhttp_client = Client(\"https://api.devnet.solana.com\")\n```\n\n### Async API Client\n\n```py\nimport asyncio\nfrom solana.rpc.async_api import AsyncClient\n\nasync def main():\n    async with AsyncClient(\"https://api.devnet.solana.com\") as client:\n        res = await client.is_connected()\n    print(res)  # True\n\n    # Alternatively, close the client explicitly instead of using a context manager:\n    client = AsyncClient(\"https://api.devnet.solana.com\")\n    res = await client.is_connected()\n    print(res)  # True\n    await client.close()\n\nasyncio.run(main())\n```\n\n### Websockets Client\n\n```py\nimport asyncio\nfrom asyncstdlib import enumerate\nfrom solana.rpc.websocket_api import connect\n\nasync def main():\n    async with connect(\"wss://api.devnet.solana.com\") as websocket:\n        await websocket.logs_subscribe()\n        first_resp = await websocket.recv()\n        subscription_id = first_resp[0].result\n        next_resp = await websocket.recv()\n        print(next_resp)\n        await websocket.logs_unsubscribe(subscription_id)\n\n    # Alternatively, use the client as an infinite asynchronous iterator:\n    async with connect(\"wss://api.devnet.solana.com\") as websocket:\n        await websocket.logs_subscribe()\n        first_resp = await websocket.recv()\n        subscription_id = first_resp[0].result\n        async for idx, msg in enumerate(websocket):\n            if idx == 3:\n                break\n            print(msg)\n        await websocket.logs_unsubscribe(subscription_id)\n\nasyncio.run(main())\n```\n\n## \ud83d\udd28 Development\n\n### Setup\n\n1. Install [poetry](https://python-poetry.org/docs/#installation)\n2. Install dev dependencies:\n\n```sh\npoetry install\n\n```\n\n3. Activate the poetry shell.\n\n```sh\npoetry shell\n```\n\n### Lint\n\n```sh\nmake lint\n```\n\n### Tests\n\n```sh\n# All tests\nmake tests\n# Unit tests only\nmake unit-tests\n# Integration tests only\nmake int-tests\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Solana Python API",
    "version": "0.34.0",
    "project_urls": {
        "Documentation": "https://michaelhly.github.io/solana-py/",
        "Homepage": "https://github.com/michaelhly/solanapy"
    },
    "split_keywords": [
        "solana",
        " blockchain",
        " web3"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6b81ffefab210a73952bb2f93c0bd24225efef58c556031073f9b70b0e27aa94",
                "md5": "71f8377ea8a00c2a94eaa069583702ef",
                "sha256": "13b08b995db60c67959e08396267b15a9f46af6ed65596625f27b361cb83d067"
            },
            "downloads": -1,
            "filename": "solana-0.34.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "71f8377ea8a00c2a94eaa069583702ef",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 65055,
            "upload_time": "2024-04-17T17:15:17",
            "upload_time_iso_8601": "2024-04-17T17:15:17.557245Z",
            "url": "https://files.pythonhosted.org/packages/6b/81/ffefab210a73952bb2f93c0bd24225efef58c556031073f9b70b0e27aa94/solana-0.34.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "34d506219d41625791e056ce1a09bac144c5cd130ae3e4271a9df6bb1fab9ada",
                "md5": "a9c88818e2cd66a10921a8ec498d4996",
                "sha256": "0914c7b5dd480e7c2bfb3bc296a64ea6bf069542cda3d96f460769fccc116a10"
            },
            "downloads": -1,
            "filename": "solana-0.34.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a9c88818e2cd66a10921a8ec498d4996",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 53334,
            "upload_time": "2024-04-17T17:15:20",
            "upload_time_iso_8601": "2024-04-17T17:15:20.371133Z",
            "url": "https://files.pythonhosted.org/packages/34/d5/06219d41625791e056ce1a09bac144c5cd130ae3e4271a9df6bb1fab9ada/solana-0.34.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-17 17:15:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "michaelhly",
    "github_project": "solanapy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "solana"
}
        
Elapsed time: 0.23233s