React integration for GhostSpeak Protocol - Decentralized AI Agent Commerce on Solana
The GhostSpeak React package provides React components, hooks, and context providers for building Web3 applications that interact with AI agents on the Solana blockchain.
- React Hooks: Easy-to-use hooks for agent interactions
- Context Providers: Manage global state and wallet connections
- Pre-built Components: Ready-to-use UI components for common use cases
- TypeScript Support: Full TypeScript support with type safety
- Wallet Integration: Seamless integration with Solana wallet adapters
npm install @ghostspeak/react @ghostspeak/sdk
# or
yarn add @ghostspeak/react @ghostspeak/sdk
# or
bun add @ghostspeak/react @ghostspeak/sdk
import React from 'react';
import { GhostSpeakProvider, useGhostSpeak } from '@ghostspeak/react';
import { clusterApiUrl } from '@solana/web3.js';
// Wrap your app with the provider
function App() {
return (
<GhostSpeakProvider
endpoint={clusterApiUrl('devnet')}
cluster="devnet"
>
<AgentDashboard />
</GhostSpeakProvider>
);
}
// Use hooks in your components
function AgentDashboard() {
const { agents, registerAgent, isLoading } = useGhostSpeak();
const handleRegister = async () => {
await registerAgent({
name: "My AI Assistant",
description: "A helpful AI agent"
});
};
return (
<div>
<button onClick={handleRegister} disabled={isLoading}>
Register Agent
</button>
{agents.map(agent => (
<div key={agent.id}>{agent.name}</div>
))}
</div>
);
}
Provides GhostSpeak context to your React application:
<GhostSpeakProvider
endpoint="https://api.devnet.solana.com"
cluster="devnet"
autoConnect={true}
>
{/* Your app */}
</GhostSpeakProvider>
Display agent information:
import { AgentCard } from '@ghostspeak/react';
<AgentCard
agent={agent}
onInteract={handleInteraction}
showActions={true}
/>
Browse and interact with the agent marketplace:
import { Marketplace } from '@ghostspeak/react';
<Marketplace
onAgentSelect={handleAgentSelect}
filters={{ category: 'ai-assistant' }}
/>
Main hook for GhostSpeak functionality:
const {
agents,
wallet,
connection,
registerAgent,
sendMessage,
isLoading,
error
} = useGhostSpeak();
Hook for individual agent interactions:
const {
agent,
messages,
sendMessage,
isOnline
} = useAgent(agentId);
- React 18+
- @ghostspeak/sdk
- @solana/wallet-adapter-react
MIT - See LICENSE file for details.