@spling/social-protocol
TypeScript icon, indicating that this package has built-in type declarations

1.5.9 • Public • Published

Social Protocol

Docs Version Downloads License

Spling Labs - Social Protocol for building a solana on-chain social media platform.

If you have any questions about the SDK, join our Discord to get help!

Quick Setup

Install

Install these dependencies over:

npm:

npm install @spling/social-protocol

If you plan to install the package in your react.js or next.js project, keep in mind that you need to install this package with the --no-optiona flag:

npm install @spling/social-protocol --no-optional

Setup (React Example)

import React, { useEffect } from 'react'
import * as anchor from '@project-serum/anchor'
import { SocialProtocol } from '@spling/social-protocol'
import { AnchorWallet, useWallet, Keypair } from '@solana/wallet-adapter-react'

export default function SocialProtocol() {
  const wallet = useWallet()

  useEffect(() => {
    ;(async () => {
      if (wallet?.publicKey) {
        const payerWallet: Keypair = Keypair.generate()
        const options = { 
          rpcUrl: "https://api.mainnet-beta.solana.com/", 
          useIndexer: true
        } as ProtocolOptions

        // Initialize the social protocol
        const socialProtocol = await new SocialProtocol(wallet, payerWallet, options).init()

        // You can call now functions like:
        const user = await socialProtocol.getUser(42) 
      }
    })()
  }, [wallet?.publicKey])
  return <div></div>
}

Setup (React Native Example)

import React, { useEffect } from 'react'
import { SocialProtocol } from '@spling/social-protocol'
import { Keypair } from "@solana/web3.js";

export default function SocialProtocol() {
  useEffect(() => {
    ;(async () => {
      const wallet: Keypair = Keypair.generate()
      const payerWallet: Keypair = Keypair.generate()
      const options = { 
        rpcUrl: "https://api.mainnet-beta.solana.com/", 
        useIndexer: true
      } as ProtocolOptions

      // Initialize the social protocol
      const socialProtocol = await new SocialProtocol(wallet, payerWallet, options).init()

      // You can call now functions like:
      const user = await socialProtocol.getUser(42) 
    })()
  }, [])
  
  return <View></View>;
}

Setup (NodeJS Example)

import { SocialProtocol } from '@spling/social-protocol'
const wallet: Keypair = Keypair.generate()
const payerWallet: Keypair = Keypair.generate()
const options = { 
  rpcUrl: "https://api.mainnet-beta.solana.com/", 
  useIndexer: true
} as ProtocolOptions

// Initialize the social protocol
const socialProtocol = await new SocialProtocol(wallet, payerWallet, options).init()

// You can call now functions like:
const user = await socialProtocol.getUser(42) 

Starter templates

The starter template makes it easier for all developers to get started with their first on-chain social app. With the template you can directly start to develop your next social app based on our social protocol! @spling/social-protocol

package description
next.js Next.js - Starter Template
react.js React.js - Starter Template
react-native React Native - Starter Template

Package Sidebar

Install

npm i @spling/social-protocol

Weekly Downloads

0

Version

1.5.9

License

MIT

Unpacked Size

838 kB

Total Files

258

Last publish

Collaborators

  • tmcyrix
  • spling-protocol