2025-09-25 21:52:40 +05:30
|
|
|
|
# Opchan
|
2025-06-20 05:08:48 +05:30
|
|
|
|
|
2025-09-25 21:58:56 +05:30
|
|
|
|
TypeScript libraries for building decentralized, Waku-powered forums.
|
2025-06-20 05:08:48 +05:30
|
|
|
|
|
2025-09-25 21:58:56 +05:30
|
|
|
|
## Packages
|
2025-08-30 18:34:50 +05:30
|
|
|
|
|
2025-09-25 21:58:56 +05:30
|
|
|
|
- `@opchan/core` – Core browser library: Waku messaging, local database, identity/ENS & Ordinals resolution, delegation, and forum actions.
|
|
|
|
|
|
- `@opchan/react` – React provider and hooks on top of `@opchan/core`.
|
2025-06-20 05:08:48 +05:30
|
|
|
|
|
2025-09-25 21:58:56 +05:30
|
|
|
|
## Install
|
2025-08-30 18:34:50 +05:30
|
|
|
|
|
2025-09-25 21:52:40 +05:30
|
|
|
|
```bash
|
2025-09-25 21:58:56 +05:30
|
|
|
|
# core only
|
|
|
|
|
|
npm i @opchan/core
|
2025-06-20 05:08:48 +05:30
|
|
|
|
|
2025-09-25 21:58:56 +05:30
|
|
|
|
# react integration
|
|
|
|
|
|
npm i @opchan/react @opchan/core react react-dom
|
2025-09-25 21:52:40 +05:30
|
|
|
|
```
|
2025-08-30 18:34:50 +05:30
|
|
|
|
|
2025-09-25 21:58:56 +05:30
|
|
|
|
## Quickstart
|
|
|
|
|
|
|
|
|
|
|
|
### React
|
|
|
|
|
|
|
|
|
|
|
|
```tsx
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
|
import { createRoot } from 'react-dom/client';
|
|
|
|
|
|
import { OpChanProvider, useForum } from '@opchan/react';
|
|
|
|
|
|
|
|
|
|
|
|
const config = { ordiscanApiKey: 'YOUR_ORDISCAN_API_KEY' };
|
|
|
|
|
|
|
|
|
|
|
|
function NewPostButton({ cellId }: { cellId: string }) {
|
|
|
|
|
|
const { content, permissions } = useForum();
|
|
|
|
|
|
return (
|
|
|
|
|
|
<button
|
|
|
|
|
|
disabled={!permissions.canPost}
|
|
|
|
|
|
onClick={() => content.createPost({ cellId, title: 'Hello', content: 'World' })}
|
|
|
|
|
|
>
|
|
|
|
|
|
New post
|
|
|
|
|
|
</button>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function App() {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<OpChanProvider config={config}>
|
|
|
|
|
|
<NewPostButton cellId="general" />
|
|
|
|
|
|
</OpChanProvider>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
createRoot(document.getElementById('root')!).render(<App />);
|
2025-09-25 21:52:40 +05:30
|
|
|
|
```
|
2025-08-30 18:34:50 +05:30
|
|
|
|
|
2025-09-25 21:58:56 +05:30
|
|
|
|
More details:
|
|
|
|
|
|
- React API docs: `packages/react/README.md`
|
2025-06-20 05:08:48 +05:30
|
|
|
|
|
2025-09-25 21:58:56 +05:30
|
|
|
|
## Development
|
2025-06-20 05:08:48 +05:30
|
|
|
|
|
2025-09-25 21:58:56 +05:30
|
|
|
|
This is an npm workspace. From the repo root:
|
2025-06-20 05:08:48 +05:30
|
|
|
|
|
2025-09-25 21:52:40 +05:30
|
|
|
|
```bash
|
2025-09-25 21:58:56 +05:30
|
|
|
|
# install all deps
|
|
|
|
|
|
npm install
|
2025-06-20 05:08:48 +05:30
|
|
|
|
|
2025-09-25 21:58:56 +05:30
|
|
|
|
# build all packages
|
|
|
|
|
|
npm run build
|
2025-06-20 05:08:48 +05:30
|
|
|
|
|
2025-09-25 21:58:56 +05:30
|
|
|
|
# build a specific package
|
|
|
|
|
|
npm run build --workspace=@opchan/core
|
|
|
|
|
|
npm run build --workspace=@opchan/react
|
2025-06-20 05:08:48 +05:30
|
|
|
|
|
2025-09-25 21:58:56 +05:30
|
|
|
|
# watch mode during development
|
|
|
|
|
|
npm run dev --workspace=@opchan/core
|
|
|
|
|
|
npm run dev --workspace=@opchan/react
|
2025-06-20 05:08:48 +05:30
|
|
|
|
|
2025-09-25 21:58:56 +05:30
|
|
|
|
# test & lint
|
|
|
|
|
|
npm test
|
|
|
|
|
|
npm run lint
|
2025-09-25 21:52:40 +05:30
|
|
|
|
```
|
2025-06-20 05:08:48 +05:30
|
|
|
|
|
2025-09-25 21:52:40 +05:30
|
|
|
|
## License
|
2025-06-20 05:08:48 +05:30
|
|
|
|
|
2025-09-25 21:52:40 +05:30
|
|
|
|
MIT
|