yarn
- Install JS packagesanchor build && anchor test
cd usedispatch_client/ && npm install
npm run test
anchor build && anchor test
cd usedispatch_client/ && npm run test && cd ..
Here is some example code on how you might interact with the library. For more details, see the [postbox docs].
import { Postbox, DispatchConnection } from '@usedispatch/msg';
const targetKey = new web.PublicKey(DEGEN_APE_COLLECTION_KEY);
const dispatchConn = new DispatchConnection(web3Conn, wallet);
const postbox = new Postbox({key: targetKey});
// Interact with the postbox
// Get all of the topics
const topics = await postbox.fetchPosts();
const firstTopic = topics[0];
// Get the posts in that topic
const postsInTopic = await postbox.fetchReplies(firstTopic);
// Check that the wallet we used is allowed to write to this topic
if (postbox.canPost(firstTopic)) {
// Add a new post
await postbox.createPost({
subj: 'This topic is amazing',
body: 'Thank you so much for creating it',
}, firstTopic);
// Vote up on the first post in the topic
await postbox.vote(postsInTopic[0], true);
}