Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

elizaOS Plugin Solana (Python)

Python implementation of the Solana blockchain plugin for elizaOS agents.

Installation

pip install elizaos-plugin-solana

Quick Start

import asyncio
from elizaos_plugin_solana import SolanaClient, WalletConfig

async def main():
    # Read-only mode (just need a public key)
    config = WalletConfig.read_only(
        "https://api.mainnet-beta.solana.com",
        "YourPublicKeyHere"
    )

    async with SolanaClient(config) as client:
        # Get SOL balance
        balance = await client.get_sol_balance()
        print(f"Balance: {balance} SOL")

        # Get token accounts
        tokens = await client.get_token_accounts()
        for token in tokens:
            print(f"{token.mint}: {token.ui_amount}")

asyncio.run(main())

With Signing Capability

from elizaos_plugin_solana import SolanaClient, WalletConfig
from decimal import Decimal

# Full access mode (with private key)
config = WalletConfig.with_keypair(
    "https://api.mainnet-beta.solana.com",
    "YourPrivateKeyHere"
)

async with SolanaClient(config) as client:
    # Transfer SOL
    recipient = "RecipientPublicKey"
    result = await client.transfer_sol(recipient, Decimal("0.1"))
    print(f"Transfer signature: {result.signature}")

Environment Variables

Load configuration from environment:

config = WalletConfig.from_env()

Required environment variables:

  • SOLANA_RPC_URL - Solana RPC endpoint (defaults to mainnet)
  • SOLANA_PRIVATE_KEY or WALLET_PRIVATE_KEY - Private key for signing
  • SOLANA_PUBLIC_KEY or WALLET_PUBLIC_KEY - Public key (if no private key)

Optional:

  • SLIPPAGE - Slippage tolerance in basis points (default: 50)
  • HELIUS_API_KEY - For enhanced RPC
  • BIRDEYE_API_KEY - For token price data

Token Swaps via Jupiter

from elizaos_plugin_solana import SwapQuoteParams

params = SwapQuoteParams(
    input_mint="So11111111111111111111111111111111111111112",  # SOL
    output_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",  # USDC
    amount="1000000000",  # 1 SOL in lamports
    slippage_bps=50,
)

quote = await client.get_swap_quote(params)
print(f"Expected output: {quote.out_amount}")

# Execute the swap
result = await client.execute_swap(quote)
print(f"Swap signature: {result.signature}")

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Run linting
ruff check .
ruff format .

# Run type checking
mypy elizaos_plugin_solana

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elizaos_plugin_solana-2.0.0a5.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elizaos_plugin_solana-2.0.0a5-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file elizaos_plugin_solana-2.0.0a5.tar.gz.

File metadata

  • Download URL: elizaos_plugin_solana-2.0.0a5.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for elizaos_plugin_solana-2.0.0a5.tar.gz
Algorithm Hash digest
SHA256 73a7aeec28e7c3c7345e1ec76573b2901d787aeed252977ceadbe582dd165a16
MD5 a684b0b236ffff6bf56ed0b1dd8f2a78
BLAKE2b-256 d8028b2c5d5e6eb2b242c63e0381bb31ecfca074bcf4109ba247d45800023138

See more details on using hashes here.

File details

Details for the file elizaos_plugin_solana-2.0.0a5-py3-none-any.whl.

File metadata

File hashes

Hashes for elizaos_plugin_solana-2.0.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 59cc474d76713b0729cdf44026c60372d4c76fbabdc346357b2e174db48fd0da
MD5 e8f4926841f491d1a120c7474c12c305
BLAKE2b-256 77b9754ccd28579256195b6b97a3bd23c913c34627115f463e9ad9a970c259f9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.0a5 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page