SAM Framework provides 15+ production-ready tools organized into categories for comprehensive Solana ecosystem operations. The tool system is built on a plugin architecture that supports both built-in tools and external extensions.
Wallet & Balance
Complete wallet management and balance tracking
Trading
Pump.fun and Jupiter DEX trading operations
Market Data
Real-time market data and pair information
Plugin System
Custom tools via entry points and SDK
from sam.core.tools import Tool, ToolRegistry # Define tool handler async def my_tool_handler(args: dict) -> dict: """Custom tool implementation.""" # Tool logic here return {"result": "success", "data": args} # Create tool specification tool = Tool( name="my_custom_tool", description="Description of what the tool does", input_schema={ "type": "object", "properties": { "param": { "type": "string", "description": "Parameter description" } }, "required": ["param"] }, handler=my_tool_handler ) # Register with agent registry.register(tool)
Tools execute through a configurable middleware pipeline:
# Middleware configuration middleware_config = { "logging": { "include_args": True, "include_result": False }, "rate_limit": { "enabled": True, "map": { "my_custom_tool": {"type": "custom"} } }, "retry": [{ "only": ["my_custom_tool"], "max_retries": 3, "base_delay": 0.25 }] }
All tools follow consistent error handling patterns:
{ "success": false, "error": { "category": "validation", "title": "Invalid Address", "message": "The provided address is not a valid Solana address", "solutions": [ "Check the address format", "Ensure the address is 32 bytes when base58 decoded" ] } }
get_balance
Get complete wallet overview including SOL and all SPL token balances.
Parameters:
address
(optional): Solana address to check (uses configured wallet if not provided)Returns:
{ "address": "wallet_address", "sol_balance": 1.234, "sol_balance_lamports": 1234000000, "sol_usd": 245.67, "tokens": [ { "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "amount": 1000000, "uiAmount": 1.0, "decimals": 6 } ], "total_portfolio_usd": 1245.67 }
Examples:
"check my wallet balance" "show balance for [address]" "get SOL balance"
transfer_sol
Transfer SOL between addresses with automatic transaction handling.
Parameters:
to_address
: Recipient Solana addressamount
: Amount of SOL to transfer (float)Returns:
{ "success": true, "transaction_id": "signature_hash", "from_address": "sender_address", "to_address": "recipient_address", "amount_sol": 0.5, "amount_lamports": 500000000 }
Examples:
"send 0.1 SOL to [recipient_address]" "transfer 1 SOL to my other wallet"
get_token_data
Get comprehensive token metadata and supply information.
Parameters:
address
: Token mint addressReturns:
{ "success": true, "mint": "token_address", "name": "Token Name", "symbol": "TOKEN", "description": "Token description", "supply": {"uiAmount": 1000000}, "image": "https://...", "creators": [...], "mutable": false, "burnt": false }
Examples:
"get token data for EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" "show USDC token information"
pump_fun_buy
Execute token purchases on Pump.fun with automatic slippage protection.
Parameters:
mint
: Token mint addressamount
: Amount of SOL to spend (float)slippage
: Slippage tolerance percentage (default: 5)Returns:
{ "success": true, "transaction_id": "signature_hash", "action": "buy", "token_address": "mint_address", "sol_spent": 0.01, "tokens_received": 1000000 }
Examples:
"buy 0.01 SOL worth of BONK on pump.fun" "purchase 0.1 SOL of [token_address] with 10% slippage"
Risk Warning: Pump.fun tokens are highly volatile. Always start with small amounts and research tokens before trading.
pump_fun_sell
Sell Pump.fun tokens with configurable percentage amounts.
Parameters:
mint
: Token mint addresspercentage
: Percentage of holdings to sell (1-100)slippage
: Slippage tolerance percentage (default: 5)Returns:
{ "success": true, "transaction_id": "signature_hash", "action": "sell", "token_address": "mint_address", "percentage_sold": 50, "sol_received": 0.05 }
Examples:
"sell 50% of my DOGE position" "sell 100% of [token_address] with 3% slippage"
get_pump_token_info
Get detailed Pump.fun token information and trading data.
Parameters:
mint
: Token mint addressReturns:
{ "success": true, "mint": "token_address", "name": "Token Name", "symbol": "TOKEN", "description": "Token description", "market_cap": 50000, "current_price": 0.00001, "liquidity": 1000, "holders": 150 }
Examples:
"get info for [token_address]" "show pump.fun token details"
get_token_trades
View recent trading activity for a Pump.fun token.
Parameters:
mint
: Token mint addresslimit
: Number of trades to retrieve (default: 10, max: 100)Returns:
{ "trades": [ { "signature": "tx_signature", "timestamp": 1640995200, "type": "buy", "amount": 1000000, "price": 0.00001, "user": "wallet_address" } ], "total_trades": 25 }
Examples:
"show recent trades for [token_address]" "get trading history for BONK"
get_swap_quote
Get optimized swap quotes across Jupiter DEX aggregator.
Parameters:
input_mint
: Input token mint addressoutput_mint
: Output token mint addressamount
: Amount to swap (in smallest units)slippage_bps
: Slippage tolerance in basis points (default: 50 = 0.5%)Returns:
{ "quote": { "inputMint": "input_address", "outputMint": "output_address", "inAmount": "1000000", "outAmount": "980000", "priceImpactPct": 0.01, "routePlan": [...] }, "input_amount": 1000000, "output_amount": 980000, "price_impact_pct": 0.01 }
Examples:
"get swap quote for 1 SOL to USDC" "quote 0.1 SOL to BONK with 1% slippage"
jupiter_swap
Execute token swaps through Jupiter DEX aggregator.
Parameters:
input_mint
: Input token mint addressoutput_mint
: Output token mint addressamount
: Amount to swap (in smallest units)slippage_bps
: Slippage tolerance in basis points (default: 50 = 0.5%)Returns:
{ "success": true, "transaction_id": "signature_hash", "input_mint": "input_address", "output_mint": "output_address", "input_amount": 1000000, "output_amount": 980000, "price_impact_pct": 0.01 }
Examples:
"swap 1 SOL to USDC on Jupiter" "exchange 100 USDC to SOL with 0.5% slippage"
search_pairs
Search for trading pairs by query string.
Parameters:
query
: Search query (token name, symbol, or address)limit
: Maximum results to return (default: 20)Returns:
{ "pairs": [ { "pairAddress": "pair_address", "baseToken": { "address": "token_address", "name": "Token Name", "symbol": "TOKEN" }, "quoteToken": { "address": "WSOL_address", "name": "Wrapped SOL", "symbol": "SOL" }, "priceUsd": "0.00001234", "liquidity": { "usd": 50000 } } ] }
Examples:
"search for BONK trading pairs" "find pairs containing DOGE"
get_token_pairs
Get all trading pairs for a specific token.
Parameters:
token_address
: Token mint addresslimit
: Maximum results to return (default: 20)Returns:
{ "token_address": "input_address", "pairs": [...], // Same format as search_pairs "total_pairs": 15 }
Examples:
"get pairs for EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" "show all trading pairs for USDC"
get_solana_pair
Get detailed information for a specific trading pair.
Parameters:
pair_address
: Trading pair addressReturns:
{ "pairAddress": "pair_address", "baseToken": {...}, "quoteToken": {...}, "priceUsd": "0.00001234", "priceChange": { "h1": 2.34, "h24": -1.23 }, "liquidity": { "usd": 50000 }, "volume": { "h24": 10000 }, "marketCap": 100000 }
Examples:
"get detailed info for pair [pair_address]" "show pair information"
get_trending_pairs
Get trending trading pairs by chain and time period.
Parameters:
chain
: Blockchain network (default: "solana")limit
: Maximum results to return (default: 20)Returns:
{ "pairs": [ { "pairAddress": "pair_address", "baseToken": {...}, "quoteToken": {...}, "priceUsd": "0.00001234", "priceChange": { "h1": 15.67, "h24": 45.23 }, "volume": { "h24": 50000 } } ] }
Examples:
"show trending pairs on Solana" "get trending tokens"
search_web
Search the internet using Brave Search API.
Parameters:
query
: Search query stringcount
: Number of results to return (default: 4, max: 10)Returns:
{ "results": [ { "title": "Result Title", "url": "https://example.com", "description": "Result description...", "age": "2 days ago" } ], "query": "search query", "total_results": 4 }
Examples:
"search for Solana ecosystem news" "find information about new DEX launches"
search_news
Search for news articles using Brave Search API.
Parameters:
query
: News search querycount
: Number of results to return (default: 4, max: 10)Returns:
{ "results": [ { "title": "News Article Title", "url": "https://news.example.com", "description": "Article summary...", "age": "1 hour ago", "source": "News Source" } ], "query": "news query", "total_results": 4 }
Examples:
"search for Solana news" "find crypto market updates"
Smart Execution: SAM automatically selects the most appropriate tool for your request. You don't need to specify tool names manually.
To add a new tool to SAM:
async def handle_new_tool(args: Dict[str, Any]) -> Dict[str, Any]: """New tool implementation.""" # Implementation here return {"result": "success"} tool_spec = ToolSpec( name="new_tool", description="What the tool does", input_schema={ "name": "new_tool", "description": "Tool description", "parameters": { "type": "object", "properties": { "param": {"type": "string", "description": "Parameter description"} }, "required": ["param"] } } )
SAM supports extending its capabilities through a comprehensive plugin system. You can create custom tools for specialized trading strategies, additional DEX integrations, or domain-specific operations.
# my_trading_tools.py from sam.core.tools import Tool from typing import Dict, Any async def custom_arbitrage_scanner(args: Dict[str, Any]) -> Dict[str, Any]: """Scan for arbitrage opportunities across DEXs.""" # Your custom logic here opportunities = [ { "token": "BONK", "buy_dex": "Raydium", "sell_dex": "Orca", "profit_percent": 2.5 } ] return { "success": True, "opportunities": opportunities, "timestamp": "2024-01-01T12:00:00Z" } def register_tools(registry, agent=None): """Register custom tools with SAM.""" arbitrage_tool = Tool( name="arbitrage_scanner", description="Scan for arbitrage opportunities across DEXs", input_schema={ "type": "object", "properties": { "min_profit_percent": { "type": "number", "description": "Minimum profit percentage to report", "default": 1.0 }, "max_results": { "type": "integer", "description": "Maximum opportunities to return", "default": 10 } } }, handler=custom_arbitrage_scanner ) registry.register(arbitrage_tool)
Add to your pyproject.toml
:
[project.entry-points."sam.plugins"] my_trading_tools = "my_package.tools:register_tools"
export SAM_PLUGINS="my_package.tools,vendor.tools"
# custom_llm.py from sam.core.llm_provider import LLMProvider class CustomLLMProvider(LLMProvider): async def chat_completion(self, messages, tools=None): # Custom LLM integration return ChatResponse(...) def create_provider(settings=None): return CustomLLMProvider(api_key=settings.CUSTOM_API_KEY)
# redis_memory.py from sam.core.memory import MemoryManager class RedisMemoryManager(MemoryManager): async def save_session(self, session_id: str, messages): # Redis implementation pass def create_backend(): return RedisMemoryManager()
# Configure middleware for custom tools middleware_config = { "rate_limit": { "enabled": True, "map": { "arbitrage_scanner": {"type": "arbitrage"} } }, "retry": [{ "only": ["arbitrage_scanner"], "max_retries": 2, "base_delay": 1.0 }] }
See examples/plugins/
in the SAM repository for complete examples:
simple_plugin/
- Basic tool registrationmemory_mock/
- Custom memory backendsecure_storage_dummy/
- Custom key storage