Skip to content

Profanity Detection

By default, the protocol does not include profanity detection to remain neutral and accommodate multi-language communities. This design choice helps avoid potential false positives that can occur with language-specific profanity filters.

Implementing Your Own Filter

You can guard against profane comments in two places:

  1. When the app signer signs the comment — this prevents the comment from being broadcast to the network.
  2. When the comment is returned to the app — this prevents it from being displayed to users.

Taking the comment signing API as an example (see our demo app), you can add profanity detection by filtering the comment content using a zod schema:

const CommentSchema = z.object({
  author: HexSchema,
  content: z
    .string()
    .trim()
    .nonempty()
    .refine((val) => !isProfane(val), "Comment contains profanity"),
});

Use it in your comment signing API to parse the request body:

const parseResult = CommentSchema.safeParse(await req.json());

Popular Profanity Detection Libraries

  1. obscenity
  2. bad-words
  3. leo-profanity
  4. profanity-check

Choose a solution that best fits your community's language and moderation needs. Remember to:

  • Test thoroughly to minimize false positives
  • Consider maintaining custom word lists
  • Allow for cultural and linguistic context
  • Consider implementing an appeals process for false positives