API Reference
Classes
Social
High-level class with convenience methods for common social features.
Methods:
getProfile(accountId)— Get a user's profilesetProfile(signerId, profile)— Update profile datagetPost(accountId, blockHeight)— Get a postcreatePost(signerId, post)— Create a new postgetFollowers(accountId)— Get accounts following a usergetFollowing(accountId)— Get accounts a user followsfollow(signerId, accountId)— Follow an accountunfollow(signerId, accountId)— Unfollow an accountlike(signerId, item)— Like an itemgetLikes(item)— Get likes for an item
Graph
Low-level class for direct contract interaction. Social extends this class.
Methods:
get(options)— Read data by key patternskeys(options)— Query key structureindex(options)— Query indexed dataset(options)— Store datagetVersion()— Get contract versiongetAccount(options)— Get account infogetAccounts(options)— List accountsisWritePermissionGranted(options)— Check write permissionsgrantWritePermission(options)— Grant write accessstorageBalanceOf(accountId)— Check storage balancestorageDeposit(options)— Deposit for storagestorageWithdraw(options)— Withdraw storage balancestorageUnregister(options)— Unregister account from storage (requires 1 yoctoNEAR)
Errors
| Code | Error | Description |
|---|---|---|
| 2000 | InvalidAccountIdError | Account ID is invalid |
| 3000 | KeyNotAllowedError | Key access not permitted |
| 4000 | UnknownNetworkError | Network ID not recognized |
InvalidAccountIdError
Thrown when an account ID doesn't match NEAR's account format.
{
code: 2000,
accountId: string, // The invalid account ID
message: string
}
KeyNotAllowedError
Thrown when attempting to write to a key without permission.
{
code: 3000,
key: string, // The disallowed key
message: string
}
UnknownNetworkError
Thrown when initializing with an unrecognized network ID.
{
code: 4000,
networkId: string, // The unknown network
message: string
}