@sero-singlemind/sdk
v0.1.0
Published
SingleMind SDK for interacting with Serotonin's portfolio and wallet services
Readme
SingleMind SDK
A React SDK for interacting with Serotonin's SingleMind wallet and portfolio services.
Features
- 🔌 Easy integration with React applications
- 💼 Fetch wallet portfolio data
- 🔒 Secure API communication
- 🎛️ TypeScript support
Installation
npm install @serotonin/single-mind-sdk
# or
yarn add @serotonin/single-mind-sdkUsage
Provider Setup
Wrap your application with the SingleMindProvider:
import { SingleMindProvider } from '@serotonin/single-mind-sdk';
function App() {
return (
<SingleMindProvider
clientId="YOUR_CLIENT_ID"
apiEndpoint="https://api.your-service.com/graphql"
>
<YourApp />
</SingleMindProvider>
);
}Using the Wallet Profile Hook
import { useSingleMindWalletProfile } from '@serotonin/single-mind-sdk';
function WalletProfile() {
const { fetchWalletProfile, isLoading } = useSingleMindWalletProfile();
useEffect(() => {
const loadProfile = async () => {
try {
const profile = await fetchWalletProfile("WALLET_ADDRESS");
console.log('Wallet Profile:', profile);
} catch (error) {
console.error('Error fetching wallet profile:', error);
}
};
loadProfile();
}, []);
if (isLoading) return <div>Loading...</div>;
return (
<div>
{/* Render your wallet profile data here */}
</div>
);
}API Reference
SingleMindProvider
| Prop | Type | Required | Description |
|------|------|----------|-------------|
| clientId | string | Yes | Your application's client ID |
| apiEndpoint | string | Yes | The GraphQL API endpoint |
| children | ReactNode | Yes | Your application components |
useSingleMindWalletProfile
A hook to fetch wallet profile data.
Returns
| Property | Type | Description |
|----------|------|-------------|
| fetchWalletProfile | (address: string) => Promise<WalletPortfolio> | Function to fetch wallet profile |
| isLoading | boolean | Loading state |
| error | Error | null | Error object if request fails |
Development
- Clone the repository
- Install dependencies:
npm install - Start development server:
npm run dev - Build for production:
npm run build
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT © Serotonin
