SDK

Getting Started with the SDK

Once installed, you can import the SDK and initialize the orbis object which will give you access to all of the SDK’s features:

/** Import Orbis SDK */
import { Orbis } from "@orbisclub/orbis-sdk";

/** Initialize the Orbis class object */
let orbis = new Orbis();

Connecting to Orbis

The first step is to get users to connect to their did which is created / retrieved using the wallet as a provider. This provider can in theory be any wallet from any chain, we are supporting all EVM based chains as well as Solana and will soon support additional chains such as Tezos or Cosmos.

To get users to connect to Ceramic with Orbis you need to call the orbis.connect() function, here is how to use it:

import React, { useState, useEffect } from 'react';

/** Import Orbis SDK */
import { Orbis } from "@orbisclub/orbis-sdk";

/**
 * Initialize the Orbis class object:
 * You can make this object available on other components
 * by passing it as a prop or by using a context.
 */
let orbis = new Orbis();

export default function App() {

	/** The user object */
	const [user, setUser] = useState();

	/** Calls the Orbis SDK and handle the results */
	async function connect() {
    let res = await orbis.connect();

		/** Check if connection is successful or not */
		if(res.status == 200) {
			setUser(res.did);
		} else {
			console.log("Error connecting to Ceramic: ", res);
			alert("Error connecting to Ceramic.");
		}
	}

	return(
		<div>
			{user ?
				<p>Connected with: {user}</p>
			:
				<button onClick={() => connect()}>Connect</button>
			}
		</div>
	)
}

The orbis.connect() function returns the user details of the did getting connected, here are the full details of the results returned.