Skip to main content

SuperArmor's Solana Python wrapper.

Project description

sapysol

sapysol is a Solana Python wrapper. It doesn't reinvent what solana-py, solders or AnchorPy do, but rather uses their power to create easy-to-use Python classes and wrappers to rapidly develop short and fast Python scripts to interact with Solana blockchain.

Like @solana/web3.js helps developers write JS code, sapysol will ease using blockchain technologies to more developers that prefer Python instead. More developers on board - better for the community and Solana.

sapysol can also serve as a base layer for other wrappers because it simplifies Pubkey/Keypair management, creating and sending transactions, tokens, instructions etc.

WARNING! sapysol is currently in alpha version, so, bugs, lack of tests and descriptions are expected. Some things may not work, future versions may bring breaking changes. It is a hard path for Python in Solana and I hope we hat a lot of friends along the way.

Installation

pip install sapysol

Note: Requires Python >= 3.10.

Usage

sapysol uses Client instead of AsyncClient for few reasons:

  • First - without async you can put more logic to Python constructors and other non-async functions;
  • Second - what is the point of async if you really use await in 100% of cases?

Please use threading if you need parallel execution.

# ========================================
# Sending SOL to another wallet
from solana.rpc.api import Client 
from sapysol        import *

connection: Client          = Client("https://api.mainnet-beta.solana.com")
wallet:     SapysolWallet   = SapysolWallet(connection=connection, keypair="path/to/file.json")
result:     SapysolTxStatus = wallet.SendSol(destinationAddress="11111111111111111111111111111111", amountSol=0.5)
assert(result==SapysolTxStatus.SUCCESS)

# ========================================
# Jupiter swap
from solana.rpc.api import Client
from sapysol        import *
from sapysol.jupag  import SapysolJupag

connection: Client = Client("https://api.mainnet-beta.solana.com")
quote = SapysolJupag.GetSwapQuote(connection    = connection,
                                  tokenFrom     = "So11111111111111111111111111111111111111112",
                                  tokenTo       = "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", # BONK
                                  inAmount      = 1 * LAMPORTS_PER_SOL)
txB64 = SapysolJupag.GetSwapTxBase64(walletAddress=wallet.KEYPAIR.pubkey(), coinQuote=quote)
tx: SapysolTx = SapysolTx(connection=connection, payer=wallet.KEYPAIR)
tx.FromBase64(txB64)
result: SapysolTxStatus = tx.SendAndWait()
assert(result==SapysolTxStatus.SUCCESS)

# ========================================
# TODO - other simple use cases

TODO

Contributing

All contributions are welcome! Although the devil is in the details:

  • One of the main requirements is to keep the same coding style for all future changes.
  • sapysol is designed as a wrapper, one layer above solders/solana-py, don't expect it to do very narrow or specific tasks. If you need custom behavior in your case just go one level down and implement that using solders/solana-py in your local scripts.

Tests

TODO

Contact

Telegram

Donations: SAxxD7JGPQWqDihYDfD6mFp7JWz5xGrf9RXmE4BJWTS

Disclaimer

Intended Purpose and Use

The Content is provided solely for educational, informational, and general purposes. It is not intended for use in making any business, investment, or legal decisions. Although every effort has been made to keep the information up-to-date and accurate, no representations or warranties, express or implied, are made regarding the completeness, accuracy, reliability, suitability, or availability of the Content.

Opinions and Views

The views and opinions expressed herein are those of Anton Platonov and do not necessarily reflect the official policy, position, or views of any other agency, organization, employer, or company. These views are subject to change, revision, and rethinking at any time.

Third-Party Content and Intellectual Property

Some Content may include or link to third-party materials. The User agrees to respect all applicable intellectual property laws, including copyrights and trademarks, when engaging with this Content.

Amendments

Anton Platonov reserves the right to update or change this disclaimer at any time without notice. Continued use of the Content following modifications to this disclaimer will constitute acceptance of the revised terms.

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

sapysol-0.6.0.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

sapysol-0.6.0-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file sapysol-0.6.0.tar.gz.

File metadata

  • Download URL: sapysol-0.6.0.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.8 Linux/6.6.10-1-MANJARO

File hashes

Hashes for sapysol-0.6.0.tar.gz
Algorithm Hash digest
SHA256 7c92cb5080a0d7e8c0ece6c96626934c464122b57ed1985c650b265babbe5ef4
MD5 c028f3db8bef7aaac398b02d22d7bcb7
BLAKE2b-256 6352e8f8367981c2df9e1c079d2fcc44015eddc6622608dbd0415a4b322a2234

See more details on using hashes here.

File details

Details for the file sapysol-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: sapysol-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 25.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.8 Linux/6.6.10-1-MANJARO

File hashes

Hashes for sapysol-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00799d0fc935fd229f7df70b15239503f5c7c44d27599506f4236ba05df9b737
MD5 cd85d131d74e8afef9447e4001b82c7e
BLAKE2b-256 d1542d26ca09f6adfed3003964a7baf0be02f89560005c82ed513090515e38c0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page