Skip to main content

elizaOS Solana Plugin - Solana blockchain operations for elizaOS agents

Project description

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

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

elizaos_plugin_solana-2.0.0a4.tar.gz (16.1 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.0a4-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for elizaos_plugin_solana-2.0.0a4.tar.gz
Algorithm Hash digest
SHA256 72716f75e80ca0ae4ed765457ea8fecea2f97f8a9025e39f795dcc6cce99c7a6
MD5 cbcba202ef074ce78cdb76910c8216a4
BLAKE2b-256 9df794e023bf20527e69642a9934e36b7673c5fe4cf7a4724eeae099eb72c61a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elizaos_plugin_solana-2.0.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 1aa3ffeab4cbca9c2b44589555273f856ba957929f7de9f84a0554916142ccbe
MD5 74ca012744f2047a6d46e22910c188e6
BLAKE2b-256 168c04988ac592f1f9f4428b91f1613cd0068f1fed92fd79b94864797302749f

See more details on using hashes here.

Supported by

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