Web3 Integration

Trade Mind Web3 Integration Guide


Trade Mind is a Web3-native AI Agent platform, designed to bridge the gap between decentralized ecosystems and advanced intelligent agents. This guide provides a comprehensive overview of how to integrate Trade Mind Agents with blockchains, smart contracts, wallets, and decentralized storage.

Trade Mind empowers agents to not only act intelligently — but transact, verify, and interact trustlessly across blockchain networks.


🛠️ Integration Architecture

Trade Mind integrates with the decentralized world through:

Component
Purpose

MCP Protocol

A universal bridge to gather Web2 + Web3 contexts for agents

Blockchain Connectors

Secure, modular gateways to networks like Solana, Ethereum, and DeFi protocols (Pump.fun, Raydium)

Wallet Authentication

Trustless access and action authentication using private keys

Smart Contract Interfaces

Direct execution and monitoring of blockchain smart contracts

Data Synchronization

Real-time tracking of events, orders, market data, and states


⚡ Connecting to Blockchain Networks

Trade Mind provides Web3 connectors out-of-the-box for fast blockchain interaction.

Example: Solana RPC Connection

from trademind.connectors import SolanaConnector

# Connect to Solana Mainnet
sol_connector = SolanaConnector(
    rpc_url="https://api.mainnet-beta.solana.com"
)

# Fetch latest block height
latest_block = sol_connector.get_latest_block()
print(f"Latest Solana Block: {latest_block}")

You can swap to Pump.fun, Raydium, or any Solana protocol by plugging into additional RPC APIs or SDKs.


📜 Smart Contract Interaction

Trade Mind agents can deploy, monitor, and interact with smart contracts automatically.

Example: Interacting with a Solana Smart Contract

from trademind.smartcontracts import SolanaProgramExecutor

executor = SolanaProgramExecutor(
    rpc_url="https://api.mainnet-beta.solana.com",
    program_id="Your_Solana_Program_ID"
)

# Calling a smart contract method
result = executor.call_method(
    method="submit_order",
    args={"price": 12.34, "amount": 100}
)

print(f"Transaction Result: {result}")

Agents are capable of automated DeFi trading, NFT minting, staking, and real-world event triggering!


🔑 Wallet Authentication Workflow

Trade Mind supports wallet-based login and signing for actions:

  1. Request Nonce from Trade Mind API

  2. User Signs the nonce with their private wallet

  3. Verify Signature to authenticate identity securely

Example: Wallet Authentication (Python)

from trademind.auth import WalletAuthenticator

auth = WalletAuthenticator()

# Step 1: Get nonce
nonce = auth.request_nonce(wallet_address="YourWalletAddress")

# Step 2: Sign nonce
signature = auth.sign_nonce(private_key="YourPrivateKey", nonce=nonce)

# Step 3: Verify
is_valid = auth.verify(wallet_address="YourWalletAddress", signature=signature)
print(f"Wallet Verified: {is_valid}")

🔒 Private keys stay local. Only signed data is transmitted.


🌐 Decentralized Storage (IPFS / Arweave)

Trade Mind offloads large datasets (e.g., transaction history, analytics reports) to IPFS or Arweave.

Example: Uploading Agent Data to IPFS

from trademind.storage import IPFSUploader

uploader = IPFSUploader()
cid = uploader.upload_file("agent_summary.json")
print(f"Uploaded to IPFS: {cid}")

Data becomes immutable, decentralized, and verifiable.


🚀 Full Quickstart: Creating a Web3-Enabled Agent

Welcome to the TradeMindAI Framework!


1. Prerequisites

  • Node.js v20 or newer → Download Node.js

  • Internet connection


2. Installation

git clone https://github.com/TheTradeMind/thetrademind-fw
cd thetrademind-fw
npm install
npm run build
npm link   # optional

3. Running the CLI

  • Development Mode:

npm run dev
  • Production Mode:

npm run start

4. Creating a New Agent

At the prompt, type:

create

You'll define:

  • Agent Name

  • Personality

  • Description

  • Model (e.g., gpt-4o, claude-3-opus, deepseek-R1-v3)

  • Logo URL (optional)

Example:

Agent Name: MarketGuru
Personality: Analytical and Strategic
Description: Expert in DeFi and on-chain trading strategies
Model: gpt-4o

5. Listing All Agents

list

6. Interacting with Your Agent

MarketGuru
  • Chat in real-time

  • Type exit or back to return to menu


7. Other Useful Commands

Command
Description

help

Lists available commands

quit

Exit CLI (Ctrl+C)


8. Supported Models

  • gpt-4

  • gpt-4o

  • claude-3.7-sonnet

  • claude-3-opus

  • mistral-7b-instruct

  • llama-3-70b-chat

  • llama-3-8b-instruct

  • gemini-2.5-pro

  • anthropic-claude-3-haiku

  • deepseek-R1-v3


9. Troubleshooting

  • Ensure Node.js v20+

  • For verbose debug:

npm run dev
  • Check internet/API keys if facing errors.


10. Contributing & Support


11. License

MIT License.


🧠 Best Practices for Trade Mind Web3 Development

Area
Recommendation

Provider URLs

Use HTTPS endpoints, protect RPC keys

Error Handling

Implement retries and fallback

Smart Contracts

Audit regularly for vulnerabilities

Wallet Security

Promote hardware wallets

Scalability

Use parallelization and batch processing

Last updated