> For the complete documentation index, see [llms.txt](https://docs.agentipy.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.agentipy.fun/core-concepts/solanaagentkit.md).

# SolanaAgentKit

The `SolanaAgentKit` is a fundamental component of AgentiPy, providing the necessary tools and configurations for AI agents to interact with the Solana blockchain. It encapsulates the connection to a Solana RPC endpoint and manages the wallet (private key) required for signing transactions.

## Purpose

* **Blockchain Connection:** Establishes and maintains the connection to a Solana RPC node, enabling communication with the Solana network.
* **Wallet Management:** Securely handles the private key associated with a Solana wallet, which is essential for authorizing transactions and interacting with on-chain programs.
* **Transaction Signing:** Provides methods for signing transactions before they are submitted to the Solana network.
* **Context Provider:** Acts as a central context object that is passed to various AgentiPy tools, giving them access to the blockchain connection and wallet information.

## Usage

To use `SolanaAgentKit`, you need to initialize it with your Solana wallet's private key and the URL of a Solana RPC endpoint.

### Initialization Example

```python
from agentipy.agent import SolanaAgentKit

# !! IMPORTANT SECURITY WARNING !!
# NEVER hardcode your private key directly into your code, ESPECIALLY for Mainnet.
# This is for demonstration purposes ONLY.
# In a real application, use environment variables, secure key vaults, or other
# secure key management practices. Compromising your private key can lead to
# loss of funds.

PRIVATE_KEY = "YOUR_PRIVATE_KEY_HERE"  # ⚠️ REPLACE THIS SECURELY! ⚠️
RPC_URL = "https://api.mainnet-beta.solana.com"  # Mainnet RPC endpoint, change to devnet or testnet as needed

# Initialize the SolanaAgentKit
agent = SolanaAgentKit(
    private_key=PRIVATE_KEY,
    rpc_url=RPC_URL
)

print(f"SolanaAgentKit initialized. Using RPC: {agent.rpc_url}")
# You can now pass this 'agent' object to other AgentiPy tools.
```

**Security Note:** Always handle private keys with extreme care. For production environments, use secure methods like environment variables or dedicated secret management services instead of hardcoding them.
