Skip to main content

Create, Update, And Delete Reactions

This section covers how to create, update and delete reactions on the Subsocial blockchain.

Create a reaction#

substrateApi.tx.reactions.createPostReaction(postId: AnyPostId, kind: ReactionType)

Example:

...
const tx = substrateApi.tx.reactions.createPostReaction('1', 'Upvote')
...

๐Ÿ†ƒ ReactionType: 'Upvote' | 'Downvote'

๐Ÿ†ƒ AnyPostId: PostId | BN

Update a reaction#

Change the type of reaction.

substrateApi.tx.reactions.updatePostReaction(postId: AnyPostId, reactionId: ReactionId, newKind: ReactionType)

Example:

...
const tx = substrateApi.tx.reactions.updatePostReaction('1', '53', 'Downvote')
...

๐Ÿ†ƒ ReactionType: 'Upvote' | 'Downvote'

๐Ÿ†ƒ AnyPostId: PostId | BN

๐Ÿ†ƒ AnyReactionId: ReactionId | BN

Delete a reaction#

substrateApi.tx.reactions.updatePostReaction(postId: AnyPostId, reactionId: ReactionId)

Example:

...
const tx = substrateApi.tx.reactions.deletePostReaction('1', '53')
...

๐Ÿ†ƒ AnyPostId: PostId | BN

๐Ÿ†ƒ AnyReactionId: ReactionId | BN