Code Monkey home page Code Monkey logo

social-protocol's Introduction

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

social-protocol's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.