Skip to main content
SocialDB is a smart contract deployed at 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.
The easiest way to interact with 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
The SDK exposes two classes:
  • Social — high-level helpers for profiles, posts, follows, likes and notifications.
  • Graph — low-level access to the raw social.near contract (custom keys, storage, permissions). Social extends Graph.

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 configured near-kit instance:
To target testnet, point the SDK at the testnet contract:

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

Other feed helpers are available for broader queries:

Interactions


Indexer

SocialDB exposes an index API: writes can be tagged with an action 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 by action + 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