connect
⚠️
connect
has been deprecated in favor of connect_v2
which comes with multi-chain support and more.
The connect
function will create a new Ceramic session that will be used to write streams. Sessions will stay valid for 31 days by default.
We recommend developers also use the orbis.isConnected()
on each app mount/load to check if there is an active session for the user visiting your app website.
How to use?
const res = await orbis.connect(provider?, lit?);
Parameters
provider
- (optional) By default it tries to usewindow.ethereum
. Can be used to pass the WalletConnect provider for example.lit
- (optional) Generates Lit Authsig which requires an additional signature from the user. Usefalse
if you don't need encryption (such as encrypted posts or direct messages). Default istrue
.
Returns
{
status: 200,
did: "did:pkh:..",
details: {
did: "did:pkh:..",
profile: {
pfp: "https://...",
username: "Baptiste",
description: "..."
}
},
result: "Success connecting to the DiD."
}
Examples
Metamask connection without Lit Protocol
const res = await orbis.connect(window.ethereum, false);
WalletConnect with Lit enabled
import { EthereumProvider } from "@walletconnect/ethereum-provider";
const wc_provider = await EthereumProvider.init({
projectId: PROJECT_ID,
chains: ["1"]
});
/** Enable session (triggers QR Code modal) */
await wc_provider.enable();
/** Connect to Orbis using WalletConnect as a provider */
const res = await orbis.connect(wallet_connect_provider);