connect_v2
The connect_v2
function supports multi-chain (EVM & Solana) login. It also makes it easier to scale to additional blockchains and parameters in the future.
How to use?
const res = await orbis.connect_v2(options);
Parameters
options
- A JSON object that contains the parameters to use to connect the end-userprovider
- By default it will be usingwindow.ethereum
if available. Can be used to pass any provider.chain
- Must beethereum
orsolana
.lit
- Must betrue
orfalse
. Usingtrue
will generate an additional signature for the end user to allow the usage of encrypted features (token gated posts or direct messages).
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_v2({
provider: window.ethereum,
lit: false
});
WalletConnect connection
/* Import the WalletConnect library */
import { EthereumProvider } from "@walletconnect/ethereum-provider";
/* Initiate the WC 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_v2({
provider: wc_provider
});
Example using Solana Phantom
const res = await orbis.connect_v2({
provider: window.phantom?.solana,
chain: "solana",
lit: true
});