Skip to main content

connect any ai agents to solana protocols

Project description

Solana Agent Kit

Solana Agent Kit Cover 1 (3)

PyPI Downloads GitHub forks GitHub License

An open-source toolkit for connecting AI agents to Solana protocols. Now, any agent, using any model can autonomously perform 60+ Solana actions:

  • Trade tokens
  • Launch new tokens
  • Lend assets
  • Send compressed airdrops
  • Execute blinks
  • Launch tokens on AMMs
  • And more...

Anyone - whether an SF-based AI researcher or a crypto-native builder - can bring their AI agents trained with any model and seamlessly integrate with Solana.

🔧 Core Blockchain Features

  • Token Operations

    • Deploy SPL tokens by Metaplex
    • Transfer assets
    • Balance checks
    • Stake SOL
    • Zk compressed Airdrop by Light Protocol and Helius
  • NFTs on 3.Land

    • Create your own collection
    • NFT creation and automatic listing on 3.land
    • List your NFT for sale in any SPL token
  • NFT Management via Metaplex

    • Collection deployment
    • NFT minting
    • Metadata management
    • Royalty configuration
  • DeFi Integration

    • Jupiter Exchange swaps
    • Launch on Pump via PumpPortal
    • Raydium pool creation (CPMM, CLMM, AMMv4)
    • Orca Whirlpool integration
    • Manifest market creation, and limit orders
    • Meteora Dynamic AMM, DLMM Pool, and Alpha Vault
    • Openbook market creation
    • Register and Resolve SNS
    • Jito Bundles
    • Pyth Price feeds for fetching Asset Prices
    • Register/resolve Alldomains
    • Perpetuals Trading with Adrena Protocol
    • Drift Vaults, Perps, Lending and Borrowing
  • Solana Blinks

    • Lending by Lulo (Best APR for USDC)
    • Send Arcade Games
    • JupSOL staking
    • Solayer SOL (sSOL)staking

🤖 AI Integration Features

  • LangChain Integration

    • Ready-to-use LangChain tools for blockchain operations
    • Autonomous agent support
    • Memory management for persistent interactions
    • Streaming responses for real-time feedback
  • Autonomous Modes

    • Interactive chat mode for guided operations
    • Autonomous mode for independent agent actions
    • Configurable action intervals
    • Built-in error handling and recovery

📃 Documentation

You can view the full documentation of the kit at docs.solanaagentkit.xyz

📦 Installation

pip install solana-agent-kit

Quick Start

from solana_agent_kit import SolanaAgentKit, create_solana_tools

# Initialize with private key and optional RPC URL
agent = SolanaAgentKit(
    "your-wallet-private-key-as-base58",
    "https://api.mainnet-beta.solana.com",
    "your-openai-api-key"
)

# Create LangChain tools
tools = create_solana_tools(agent)

Usage Examples

Deploy a New Token

from solana_agent_kit import SolanaAgentKit

async def main():
    agent = SolanaAgentKit(
        "your-wallet-private-key-as-base58",
        "https://api.mainnet-beta.solana.com",
        "your-openai-api-key"
    )
    
    result = await agent.deploy_token(
        "my ai token",  # name
        "uri",         # uri
        "token",       # symbol
        9,            # decimals
        1000000       # initial supply
    )
    print("Token Mint Address:", result.mint)

import asyncio
asyncio.run(main())

Create NFT Collection

from solana_agent_kit import SolanaAgentKit

async def main():
    agent = SolanaAgentKit(
        "your-wallet-private-key-as-base58",
        "https://api.mainnet-beta.solana.com",
        "your-openai-api-key"
    )
    
    collection = await agent.deploy_collection({
        "name": "My NFT Collection",
        "uri": "https://arweave.net/metadata.json",
        "royalty_basis_points": 500,  # 5%
        "creators": [
            {
                "address": "creator-wallet-address",
                "percentage": 100
            }
        ]
    })

import asyncio
asyncio.run(main())

Swap Tokens

from solana_agent_kit import SolanaAgentKit
from solders.pubkey import Pubkey

async def main():
    agent = SolanaAgentKit(
        "your-wallet-private-key-as-base58",
        "https://api.mainnet-beta.solana.com",
        "your-openai-api-key"
    )
    
    signature = await agent.trade(
        output_mint=Pubkey.from_string("target-token-mint"),
        input_amount=100,  # amount
        input_mint=Pubkey.from_string("source-token-mint"),
        slippage_bps=300  # 3% slippage
    )

import asyncio
asyncio.run(main())

Lend Tokens

from solana_agent_kit import SolanaAgentKit

from solders.pubkey import Pubkey

async def main():
agent = SolanaAgentKit(
    "your-wallet-private-key-as-base58",
    "https://api.mainnet-beta.solana.com",
    "your-openai-api-key"
)
signature = await agent.lend_assets(
    amount=100  # amount
)

import asyncio
asyncio.run(main())

Stake SOL

from solana_agent_kit import SolanaAgentKit

from solders.pubkey import Pubkey

async def main():
agent = SolanaAgentKit(
    "your-wallet-private-key-as-base58",
    "https://api.mainnet-beta.solana.com",
    "your-openai-api-key"
)

signature = await agent.stake(
    amount=1  # amount in SOL
)

import asyncio
asyncio.run(main())

Request Faucet Funds

from solana_agent_kit import SolanaAgentKit

async def main():
    agent = SolanaAgentKit(
        "your-wallet-private-key-as-base58",
        "https://api.mainnet-beta.solana.com",
        "your-openai-api-key"
    )

    response = await agent.request_faucet_funds()
    print(response)

import asyncio
asyncio.run(main())

Fetch Current TPS

from solana_agent_kit import SolanaAgentKit

async def main():
    agent = SolanaAgentKit(
        "your-wallet-private-key-as-base58",
        "https://api.mainnet-beta.solana.com",
        "your-openai-api-key"
    )

    tps = await agent.get_tps()
    print(f"Current TPS: {tps}")

import asyncio
asyncio.run(main())

Get Token Data by Ticker

from solana_agent_kit import SolanaAgentKit

async def main():
    agent = SolanaAgentKit(
        "your-wallet-private-key-as-base58",
        "https://api.mainnet-beta.solana.com",
        "your-openai-api-key"
    )

    token_data = await agent.get_token_data_by_ticker("SOL")
    print(token_data)

import asyncio
asyncio.run(main())

Get Token Data by Address

from solana_agent_kit import SolanaAgentKit
from solders.pubkey import Pubkey

async def main():
    agent = SolanaAgentKit(
        "your-wallet-private-key-as-base58",
        "https://api.mainnet-beta.solana.com",
        "your-openai-api-key"
    )

    token_data = await agent.get_token_data_by_address("your-token-mint-address")
    print(token_data)

import asyncio
asyncio.run(main())

Launch Pump Fun Token

from solana_agent_kit import SolanaAgentKit
from solana_agent_kit.types import PumpfunTokenOptions

async def main():
    agent = SolanaAgentKit(
        "your-wallet-private-key-as-base58",
        "https://api.mainnet-beta.solana.com",
        "your-openai-api-key"
    )

    options = PumpfunTokenOptions(
        # Add your options here
    )

    response = await agent.launch_pump_fun_token(
        token_name="MyToken",
        token_ticker="MTK",
        description="This is a fun token",
        image_url="https://example.com/image.png",
        options=options
    )
    print(response)

Create Meteora DLMM Pool

from solana_agent_kit import SolanaAgentKit
from solders.pubkey import Pubkey
from solana_agent_kit.utils.meteora_dlmm.types import ActivationType

async def main():
    agent = SolanaAgentKit(
        "your-wallet-private-key-as-base58",
        "https://api.mainnet-beta.solana.com",
        "your-openai-api-key"
    )

    response = await agent.create_meteora_dlmm_pool(
        bin_step=1,
        token_a_mint=Pubkey.from_string("token-a-mint"),
        token_b_mint=Pubkey.from_string("token-b-mint"),
        initial_price=1.0,
        price_rounding_up=True,
        fee_bps=30,
        activation_type=ActivationType.Timestamp,
        has_alpha_vault=True,
        activation_point=None
    )
    print(response)

import asyncio
asyncio.run(main())

Buy Tokens with Raydium

from solana_agent_kit import SolanaAgentKit
from solders.pubkey import Pubkey

async def main():
    agent = SolanaAgentKit(
        "your-wallet-private-key-as-base58",
        "https://api.mainnet-beta.solana.com",
        "your-openai-api-key"
    )

    confirmed = await agent.buy_with_raydium(
        pair_address=Pubkey.from_string("target-pair-address"),  # The pair you want to buy from
        sol_in=1,  # Amount of SOL or input token to spend
        slippage=300  # Maximum slippage in basis points (3% here)
    )
    print(f"Transaction confirmed: {confirmed}")

import asyncio
asyncio.run(main())

Sell Tokens with Raydium

from solana_agent_kit import SolanaAgentKit
from solders.pubkey import Pubkey

async def main():
    agent = SolanaAgentKit(
        "your-wallet-private-key-as-base58",
        "https://api.mainnet-beta.solana.com",
        "your-openai-api-key"
    )

    confirmed = await agent.sell_with_raydium(
        input_mint=Pubkey.from_string("source-token-mint"),  # The token you want to sell
        percentage=100,
        slippage_bps=250  # Maximum slippage in basis points (2.5% here)
    )
    print(f"Transaction confirmed: {confirmed}")

import asyncio
asyncio.run(main())

Burn and Close Token Account

from solana_agent_kit import SolanaAgentKit

async def main():
    agent = SolanaAgentKit(
        "your-wallet-private-key-as-base58",
        "https://api.mainnet-beta.solana.com",
        "your-openai-api-key"
    )

    response = await agent.burn_and_close_accounts("token-account-address")
    print("Account burned and closed:", response)

import asyncio
asyncio.run(main())

Batch burn and Close Token Account

from solana_agent_kit import SolanaAgentKit

async def main():
    agent = SolanaAgentKit(
        "your-wallet-private-key-as-base58",
        "https://api.mainnet-beta.solana.com",
        "your-openai-api-key"
    )

    token_accounts = ["token-account-address-1", "token-account-address-2"]
    responses = await agent.multiple_burn_and_close_accounts(token_accounts)
    print("Accounts burned and closed:", responses)

import asyncio
asyncio.run(main())

Dependencies

The toolkit relies on several key Solana and Metaplex libraries:

  • solana-py
  • spl-token-py
  • metaplex-python-sdk

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. Refer to CONTRIBUTING.md for detailed guidelines on how to contribute to this project.

License

Apache-2 License

Funding

If you wanna give back any tokens or donations to the OSS community -- The Public Solana Agent Kit Treasury Address:

Solana Network : EKHTbXpsm6YDgJzMkFxNU1LNXeWcUW7Ezf8mjUNQQ4Pa

Security

This toolkit handles private keys and transactions. Always ensure you're using it in a secure environment and never share your private keys.

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

solana_agent_kit_py-1.3.5.tar.gz (70.6 kB view details)

Uploaded Source

Built Distribution

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

solana_agent_kit_py-1.3.5-py3-none-any.whl (90.9 kB view details)

Uploaded Python 3

File details

Details for the file solana_agent_kit_py-1.3.5.tar.gz.

File metadata

  • Download URL: solana_agent_kit_py-1.3.5.tar.gz
  • Upload date:
  • Size: 70.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for solana_agent_kit_py-1.3.5.tar.gz
Algorithm Hash digest
SHA256 ef79d35cf4ee6e442bcc7ea97457262aee0de98f0250670eec208c4fdf6cea0d
MD5 cd1f181aa027f1d9ccf1340a82807378
BLAKE2b-256 3229a6ccae2ba8b7ee4806aab4aefe5331f09628d91a6d1c8db58d9c99caa3d2

See more details on using hashes here.

File details

Details for the file solana_agent_kit_py-1.3.5-py3-none-any.whl.

File metadata

File hashes

Hashes for solana_agent_kit_py-1.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 70f65c343417d3feb521e56560bcd1e8f2bcc9cec351af47b94def428e338b41
MD5 f1b8586d0f3084458819bb964d5be0fc
BLAKE2b-256 fc1d5a71e0b64aae5b888d3154e76dd2c12c30b7e806f81d0d5cbe38c176eefe

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