Skip to main content
This guide walks through building an AI agent that can trade Solana tokens autonomously using LaserSell as its execution layer. The agent handles the decision-making (when to buy, what strategy to use), and LaserSell handles everything else: protocol routing, position monitoring, PnL tracking, and automated exit execution. This pattern works regardless of how your agent is built. Whether you are extending a personal AI assistant like OpenClaw with trading skills, building a standalone trading bot, integrating into a Telegram bot framework, or wiring up an agent built with LangChain, CrewAI, or any other framework, the LaserSell integration is the same. Your agent calls the API, connects to the stream, and signs transactions. The rest is up to you.

What the Agent Will Do

  1. Connect to the Exit Intelligence Stream to begin monitoring.
  2. Buy a token by building and submitting a transaction through the REST API.
  3. Monitor the position automatically via the stream (PnL updates, price tracking).
  4. Exit when strategy conditions are met (target profit, stop loss, trailing stop, or deadline).
The agent does not need to know which DEX or launchpad a token is on. LaserSell resolves the protocol, builds the transaction, and delivers exit signals in real time.

Prerequisites

  • A LaserSell API key (get one here).
  • A Solana keypair (JSON byte array file).
  • Python 3.10+ with the LaserSell SDK installed.
The examples below use Python, but the same flow applies with the TypeScript, Rust, or Go SDKs.

Architecture

Your agent owns the decisions. LaserSell owns the execution. The boundary between them is clean: the agent sends requests and receives events. All transactions are unsigned and signed locally by the agent.

Step 1: Connect the Exit Intelligence Stream

The stream must be connected before the agent buys. The stream detects positions by watching for on-chain token arrivals in real time. If the buy lands before the stream is connected, the position will not be tracked.
The strategy configuration tells LaserSell when to generate exit signals: Your agent can adjust these dynamically based on its own logic. See Strategy Configuration.

Step 2: Build and Submit a Buy

Once the stream is connected, the agent can buy a token. The REST API builds an unsigned transaction that the agent signs locally and submits.
The agent never sends its private key anywhere. LaserSell returns an unsigned transaction, the agent signs it locally, and submits it directly to the Solana network via Helius Sender.

Step 3: Monitor and Exit Automatically

After the buy lands on-chain, the Exit Intelligence Stream detects the new token balance and begins tracking the position. The agent listens for events and acts on exit signals.
The key events:

Step 4: Update Strategy Mid-Session

Your agent can adjust strategy parameters at any time based on its own logic. For example, tightening the trailing stop after a position is profitable, or disabling the deadline if the agent decides to hold longer.
The update takes effect immediately for all tracked positions. No reconnection needed.

Full Working Example

Here is the complete agent loop combining all steps:

Extending This Pattern

This guide shows a single buy-and-exit cycle. A production agent would build on this foundation: Signal integration. The agent receives buy signals from any source: user prompts, on-chain analysis, social feeds, copy-trading leaders, or another AI model. The signal determines when to call build_buy_tx. Multi-position management. The stream tracks multiple positions simultaneously across one or more wallets. An agent can manage a portfolio of active positions, each with its own entry logic, while LaserSell evaluates exit conditions on all of them in parallel. Dynamic strategy. Use update_strategy to adjust parameters based on market conditions, position performance, or agent confidence. An agent that detects high volatility might tighten stops. One that detects a strong trend might widen them. Risk controls. Enforce position sizing, maximum concurrent positions, daily loss limits, or any other risk rules in your agent’s decision layer before calling the API. MCP integration. If your agent runs inside an MCP-compatible client like OpenClaw, Claude, Cursor, or another AI assistant, it can use the LaserSell MCP server to look up documentation, API schemas, and code examples in real time while building or debugging the integration.

Next Steps