near-social-sdk
v1.0.0
Published
npm Package - near-social-sdk
Downloads
23
Readme
near-social-sdk
A lightweight npm package for interacting with NEAR Protocol accounts and NEAR Social profiles.
Installation
npm install near-social-sdk
API & Usage
createWallet(accountId: string): Promise<NearKeyPair>
Generate a new key pair for a NEAR account.
import { createWallet } from 'near-social-sdk';
const wallet = await createWallet('alice.near'); console.log(wallet.publicKey, wallet.secretKey);
getProfile(accountId: string): Promise<SocialProfile | null>
Fetch a NEAR Social profile.
import { getProfile } from 'near-social-sdk';
const profile = await getProfile('alice.near'); console.log(profile?.name, profile?.image);
getBalance(accountId: string): Promise<string>
Retrieve the NEAR token balance for an account.
import { getBalance } from 'near-social-sdk';
const balance = await getBalance('alice.near'); console.log(balance); // e.g. "10.5"
getPosts(accountId: string, limit = 10): Promise<SocialPost[]>
Get posts from a NEAR Social account.
import { getPosts } from 'near-social-sdk';
const posts = await getPosts('alice.near', 5); posts.forEach(post => console.log(post));
getAccessKeys(accountId: string): Promise<Array<{ public_key: string; access_key: { nonce: number; permission: unknown } }>>
List all access keys associated with an account.
import { getAccessKeys } from 'near-social-sdk';
const keys = await getAccessKeys('alice.near'); keys.forEach(k => console.log(k.public_key, k.access_key.nonce));
License
MIT
