social.near that stores social data on the NEAR blockchain: profiles, posts, follows, likes, comments and more. It powers near.social and is widely used across the ecosystem.
While the BOS framework (components/widgets) is deprecated, the social graph stored in SocialDB is still live and maintained. This page covers how to read and write that data directly, independently of BOS.
social.near is through the near-social-js SDK, which wraps the contract with helper methods for common social features.
Add the SDK to a project
npm2yarn
Social— high-level helpers for profiles, posts, follows, likes and notifications.Graph— low-level access to the rawsocial.nearcontract (custom keys, storage, permissions).SocialextendsGraph.
Reading (no wallet)
Reads are free and require no signer:Writing (requires a signer)
Writes return a transaction builder that you send with a signer. Pass a configurednear-kit instance:
Profile
A profile is stored under the<account>/profile/** key and holds the user’s name, description, image and links.
Get a profile
Set a profile
Only the account itself (the signer) can update its own profile:Posts
Posts live under the<account>/post/main key and are addressed by the block height at which they were created.
Create a post
createPost automatically extracts @mentions and #hashtags and indexes them so other users get notified:
Get posts from a user
Interactions
Indexer
SocialDB exposes an index API: writes can be tagged with anaction and key, and anyone can later query all entries for that pair, ordered by block height. This is how feeds and notifications are built — there is no off-chain indexer to run.
Index an action
High-level methods (createPost, follow, like, repost) write index entries for you. To write a custom one, send a notification with notify:
Retrieve indexed actions
Query the raw index byaction + key with the low-level index method:
Get notifications
getNotifications reads the notify index for an account and returns mentions, likes, comments, follows and reposts:
Additional resources
- near-social-js SDK docs — full API reference
- near-social-js on GitHub — SDK source code
- social-db contract — the
social.nearsmart contract - near.social — the live social network