Post
Creating a comment will only succeed for a Sui address that has an associated Sage user.
Create a user post
In this case data, description, and title are expected to be a markdown string. This allows for formatting, creating links, and more without causing downstream security risks.
The SDK sanitizes inputs on entry, removing html tags and attributes, as well as escaping text.
import { useSignAndExecuteTransaction } from '@mysten/dapp-kit';
import { useUser } from '@sage-app/sdk/react';
interface UserPostInput {
amounts: number[]; // payment amounts set to [0, 0]
data: string; // markdown string input
description: string; // markdown string input
self: string; // user's wallet address
soulId: string; // address of user's owned soul
title: string; // markdown string input
userId: string; // user object address
}
...
const { mutateAsync: signAndExecuteTransaction } = useSignAndExecuteTransaction();
const { post } = useUser();
...
const createChannelPost = async (data: UserPostInput) => {
const { ok, err, transaction } = await post(data);
const { digest } = await signAndExecuteTransaction({
transaction
});
};Error Codes
User Fees module
370
EIncorrectCoinType
Custom payment type does not match configured custom payment coin.
371
EIncorrectCustomPayment
Incorrect custom payment value.
372
EIncorrectSuiPayment
Incorrect sui payment value.
Querying for New User Post Events
The query API in the SDK sanitizes input from data, description, and title. The contract is not able to sanitizes these values for the developer performantly so that responsibility is placed here.
Developers must ensure for themselves that `data`, `description`, and `title` are safe before they are used.
In this case events will take the shape of an array of UserPostCreatedEvent:
Last updated