LangChain's tool ecosystem is vast — but most tools are read-only. Web search, Wikipedia lookups, calculators, weather APIs. They help agents answer questions, but they cannot do anything in the economic world. The interesting frontier is write tools: tools that move money, create assets, and generate revenue. Here are the five Purple Flea tools that transform a passive LangChain agent into a genuine economic participant — one that can hold a portfolio, trade derivatives, earn referral income, and even register domain names.
1
PurpleFlecaWalletTool
Every economic agent starts here. PurpleFlecaWalletTool is a LangChain
BaseTool that gives your agent a full non-custodial HD wallet spanning six chains:
Ethereum, Base, Arbitrum, Solana, Bitcoin, and Tron. With a single tool the agent can check
balances across all chains, send native tokens and ERC-20s, execute DEX swaps via aggregated
routing, and bridge assets between networks. Under the hood Purple Flea derives chain-specific
keys from a BIP-39 mnemonic you provide at initialization — the keys are never stored on Purple
Flea servers.
Why it is essential: every economic agent needs a treasury. Without a wallet tool your agent can only observe markets — it cannot participate. PurpleFlecaWalletTool is the foundation on which all other financial tools depend.
from purpleflea.langchain import PurpleFlecaWalletTool from langchain.agents import AgentExecutor, create_openai_functions_agent import os # Initialize with your BIP-39 mnemonic (store in env, never hardcode) wallet_tool = PurpleFlecaWalletTool( api_key=os.environ["PURPLEFLEA_API_KEY"], mnemonic=os.environ["AGENT_MNEMONIC"], ) # The tool exposes these actions to the agent: # - get_balance(chain, token) # - send(chain, to_address, amount, token) # - swap(from_token, to_token, amount, chain) # - bridge(amount, token, from_chain, to_chain) # - get_address(chain) result = wallet_tool.run("get_balance ethereum ETH") print(result) # {"balance": "0.4821", "usd_value": "1529.33"}
2
PurpleFlecaTradingTool
PurpleFlecaTradingTool connects your LangChain agent to 275 perpetual futures markets via the Hyperliquid backend — the highest-liquidity on-chain derivatives exchange. The tool supports market and limit orders, long and short positions, leverage from 1x to 50x, stop-loss and take-profit orders, and real-time position queries. Your agent can reason about macro trends and express views with actual capital in under a second.
What makes this powerful is 24/7 availability across every major asset class. BTC, ETH, SOL, AI tokens, commodities-linked perps — all accessible through a single natural-language tool interface. The agent can go long on $AI when sentiment is positive, hedge with a short on $BTC during risk-off periods, and close positions automatically based on PnL thresholds.
from purpleflea.langchain import PurpleFlecaTradingTool trading_tool = PurpleFlecaTradingTool( api_key=os.environ["PURPLEFLEA_API_KEY"], mnemonic=os.environ["AGENT_MNEMONIC"], default_leverage=3, max_position_usd=500, # risk cap per trade ) # Agent-facing actions: # - open_long(symbol, size_usd, leverage, stop_loss_pct) # - open_short(symbol, size_usd, leverage, stop_loss_pct) # - close_position(symbol) # - get_positions() # - get_market_info(symbol) result = trading_tool.run("open_long ETH 200 3x stop_loss=5%") print(result) # {"order_id": "0xabc...", "symbol": "ETH-PERP", # "side": "long", "size": "0.183 ETH", "leverage": 3}
3
PurpleFlecaCasinoTool
PurpleFlecaCasinoTool gives your agent access to four provably fair casino games: coin flip (48.5% win rate), configurable dice, European roulette (48.65%), and crash. Every game outcome is derived from a server seed hash that is committed before the bet is placed and revealed afterward — your agent can independently verify every result.
Why AI agents can use this wisely: traditional gambling bots lose because they ignore the house edge. A well-designed LangChain agent can implement the Kelly Criterion, track cumulative EV in memory, and refuse to bet when conditions are unfavorable. Cryptographic verification means no manipulation — the only fair game in the blockchain ecosystem. The real value for agents is often the referral layer rather than direct play.
from purpleflea.langchain import PurpleFlecaCasinoTool casino_tool = PurpleFlecaCasinoTool( api_key=os.environ["PURPLEFLEA_API_KEY"], mnemonic=os.environ["AGENT_MNEMONIC"], max_bet_usd=10, # hard cap per bet kelly_fraction=0.25, # quarter-Kelly for variance control ) # Agent-facing actions: # - play_coinflip(side, amount_usd) # - play_dice(target, over_under, amount_usd) # - play_roulette(bet_type, selection, amount_usd) # - play_crash(cashout_multiplier, amount_usd) # - verify_result(game_id) # - get_server_seed_hash() result = casino_tool.run("play_coinflip heads 5") print(result) # {"outcome": "heads", "won": true, "payout": 9.75, # "server_seed_hash": "0x7f3a...", "verify_url": "..."}
4
PurpleFlecaDomainsTool
PurpleFlecaDomainsTool lets your LangChain agent register, transfer, and
manage .ai domains programmatically. Domains are registered as on-chain NFTs
with a Purple Flea-backed resolver, making them fully portable. The tool supports bulk
registration, renewal, DNS record management, and listing domains for sale on secondary
markets.
Use case: an agent that monitors trending AI startup names, product launches, and researcher
identities can build a portfolio of high-value .ai domains and monetize them
through direct sale or parking revenue. The agent pays registration costs in USDC from its
wallet and receives proceeds directly to the same wallet — a fully autonomous domain
investment fund with no human required.
from purpleflea.langchain import PurpleFlecaDomainsTool domains_tool = PurpleFlecaDomainsTool( api_key=os.environ["PURPLEFLEA_API_KEY"], mnemonic=os.environ["AGENT_MNEMONIC"], ) # Agent-facing actions: # - check_availability(domain) # - register(domain, years=1) # - list_owned() # - set_record(domain, record_type, value) # - list_for_sale(domain, price_usd) # - transfer(domain, to_address) available = domains_tool.run("check_availability agentkit.ai") print(available) # {"domain": "agentkit.ai", "available": true, "price_usd": 12.99} reg = domains_tool.run("register agentkit.ai 2") print(reg) # {"domain": "agentkit.ai", "registered": true, "expires": "2028-02-26"}
5
PurpleFlecaReferralTool
PurpleFlecaReferralTool is the passive income layer of the Purple Flea ecosystem. When your agent refers other agents or users to Purple Flea's casino or trading platform, it earns 10% of all fees generated by those referrals — indefinitely. The tool exposes methods to retrieve your agent's unique referral link, check pending and paid commissions, see a breakdown of which referred agents generated the most volume, and trigger a payout to the agent's wallet.
This tool transforms an ordinary agent into a network node. Rather than competing in zero-sum markets, your agent can grow its income base by helping other agents discover the platform — a genuinely positive-sum economic strategy.
from purpleflea.langchain import PurpleFlecaReferralTool referral_tool = PurpleFlecaReferralTool( api_key=os.environ["PURPLEFLEA_API_KEY"], ) # Agent-facing actions: # - get_referral_link() # - get_commissions(period="30d") # - get_referred_agents() # - withdraw_commissions(to_address, chain) link = referral_tool.run("get_referral_link") print(link) # {"referral_link": "https://purpleflea.ai/?ref=agent_0xabc", # "pending_usd": "47.83", "total_earned_usd": "312.50"} commissions = referral_tool.run("get_commissions 30d") print(commissions) # {"period": "30d", "total_usd": "47.83", "from_agents": 12}
Putting It All Together
The real power emerges when you combine all five tools in a single
AgentExecutor. The agent can now run a complete financial operation: check its
portfolio balance, decide whether market conditions favor a trade, place a perpetual position,
use idle capital on referral-optimized casino activity, register a trending domain it spotted
in the news, and report its referral earnings — all in one reasoning cycle.
from langchain_anthropic import ChatAnthropic from langchain.agents import AgentExecutor, create_tool_calling_agent from langchain_core.prompts import ChatPromptTemplate from purpleflea.langchain import ( PurpleFlecaWalletTool, PurpleFlecaTradingTool, PurpleFlecaCasinoTool, PurpleFlecaDomainsTool, PurpleFlecaReferralTool, ) import os API_KEY = os.environ["PURPLEFLEA_API_KEY"] MNEMONIC = os.environ["AGENT_MNEMONIC"] tools = [ PurpleFlecaWalletTool(api_key=API_KEY, mnemonic=MNEMONIC), PurpleFlecaTradingTool(api_key=API_KEY, mnemonic=MNEMONIC, max_position_usd=500), PurpleFlecaCasinoTool(api_key=API_KEY, mnemonic=MNEMONIC, kelly_fraction=0.25), PurpleFlecaDomainsTool(api_key=API_KEY, mnemonic=MNEMONIC), PurpleFlecaReferralTool(api_key=API_KEY), ] llm = ChatAnthropic(model="claude-opus-4-6") prompt = ChatPromptTemplate.from_messages([ ("system", """You are an autonomous financial agent. Your goals: grow portfolio value, earn referral income, and register valuable .ai domains. Always check balances before trading. Never risk more than 5% of portfolio in a single trade. Use Kelly Criterion for casino bets. Prioritize referral income over direct gambling."""), ("human", "{input}"), ("placeholder", "{agent_scratchpad}"), ]) agent = create_tool_calling_agent(llm, tools, prompt) executor = AgentExecutor(agent=agent, tools=tools, verbose=True, max_iterations=10) result = executor.invoke({"input": "Run your daily financial operations."}) print(result["output"])
Security note: Store your mnemonic in a secrets manager (AWS Secrets Manager, Vault, or a hardware enclave) — never in environment variables in production. Purple Flea never stores or transmits your mnemonic.
This five-tool stack covers the complete spectrum of crypto-native financial operations. Wallet management forms the treasury layer. Trading provides market exposure. Casino tools offer variance with cryptographic fairness guarantees. Domain registration creates appreciating digital assets. And referrals build passive income that compounds over time. Together, they make a LangChain agent genuinely economically capable.