Identity
The Identity Module is a crucial component of the Honeycomb system that enables users to manage their identities and profiles on the Solana blockchain. It facilitates secure authentication, transaction signing, and interaction with various decentralized applications (dApps) on the Solana network. The Identity Module allows users to create, store, and manage cryptographic keys, also known as identities, which are essential for conducting secure transactions and interactions on the blockchain.
Getting Started
By default, the guestIdentity
method is used, which creates a guest identity with a default public key and an empty secret key. Let's go through different types of identities.
Dependencies
import * as web3 from "@solana/web3.js";
import {
Honeycomb,
guestIdentity,
keypairIdentity,
walletIdentity,
} from "@honeycomb-protocol/web3.js";
const honeycomb = new Honeycomb(
new web3.Connection("https://api.mainnet-beta.solana.com")
);
Guest Identity
guestIdentity is the default identity which is used as a placeholder until a keypair or wallet is registered with the Honeycomb Instance.
honeycomb.use(guestIdentity());
Keypair Identity
Use keypairIdentity to register a Solana Keypair as identity.
const keypair = web3.Keypair.generate();
honeycomb.use(keypairIdentity(keypair));
Wallet Identity
Use walletIdentity to register a Wallet object ( i.e. Wallet Adapter ) as identity.
const wallet = ... // Any Solana Wallet having sign methods
honeycomb.use(
walletIdentity(wallet)
);
Properties
// Address/PublicKey of the identity (Keypair, Wallet)
honeycomb.identity().address: PublicKey;
// Signer is the original object of either Keypair or Wallet
honeycomb.identity().signer: Signer;
// Flag to indicate if currently the signer is guest (default) or not
honeycomb.identity().isGuest: boolean;
// Auth token for honeycomb auth driver
honeycomb.identity().authToken: string;
API References
Authentication
honeycomb.identity().signMessage(message: Uint8Array): Promise<Uint8Array>;
honeycomb.identity().signTransaction<T = web3.Transaction | web3.VersionedTransaction>(transaction: T): Promise<T>;
honeycomb.identity().signAllTransactions<T = web3.Transaction | web3.VersionedTransaction>(transactions: T[]): Promise<T[]>;