Skip to main content

daocafe-sdk

The official TypeScript SDK for DAO.CAFE - providing type-safe access to governance data from the CreateDAO protocol.

Features

FeatureDescription
🔍 Type-safeFull TypeScript support with generated types
⚛️ React HooksTanStack Query integration with caching and refetching
🚀 Tree-shakableOnly bundle what you use
📦 Zero ConfigPre-configured to work with the DAO.CAFE endpoint
🔄 Real-time ReadyBuilt-in caching and background refetching

Installation

npm install daocafe-sdk

Peer Dependencies (for React hooks)

If you plan to use the React hooks, install these peer dependencies:
npm install @tanstack/react-query react

Quick Start

With React Hooks

import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { useDAOs } from 'daocafe-sdk';

const queryClient = new QueryClient();

function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <DAOList />
    </QueryClientProvider>
  );
}

function DAOList() {
  const { data, isLoading, error } = useDAOs({ limit: 10 });

  if (isLoading) return <div>Loading DAOs...</div>;
  if (error) return <div>Error: {error.message}</div>;

  return (
    <ul>
      {data?.items.map(dao => (
        <li key={dao.id}>
          <strong>{dao.name}</strong> - {dao.proposalCount} proposals
        </li>
      ))}
    </ul>
  );
}

With Async Functions (Node.js / Vanilla JS)

import { getDAOs, getActiveProposals } from 'daocafe-sdk';

// Fetch all DAOs
const { items: daos } = await getDAOs({ limit: 10 });
console.log(`Found ${daos.length} DAOs`);

// Fetch active proposals across all DAOs
const { items: proposals } = await getActiveProposals();
console.log(`${proposals.length} active proposals`);

Supported Networks

NetworkChain IDStatus
Base Mainnet8453✅ Supported
Sepolia Testnet11155111✅ Supported

ID Formats

The SDK uses composite IDs for all entities:
EntityID FormatExample
DAOchainId_governorAddress11155111_0xf51C4b7b...
ProposalchainId_governor_proposalId11155111_0xf51C4b7b..._12345
VotechainId_governor_proposalId_voter11155111_0xf51C...._12345_0xAbc...
DelegatechainId_tokenAddress_delegatorAddress11155111_0xcfCf..._0xAbc...
TokenHolderchainId_tokenAddress_holderAddress11155111_0xcfCf..._0xAbc...

What’s Next?