Keyring Controller

All the wallet management & Chain Interactions executing on the client side is managed by this class.

Create an instance

const keyring = new KeyringController({ 
    baseUrl: 'http://localhost:8000',
    walletType: {
        embedded: true, // for external wallet it should be false
        supportAa: true, // false if dapp only wants EOA wallets
    },
    sentryDns, // string
    environment, // ENV
    sessionSignatures, //[OPTIONAL] SESSION SIG FROM litController.initSession
    currentAccount, //[OPTIONAL] fetch PKPs FROM litController.fetchPKPs
    customAuthMethod,
    accessToken,
    aa,
    selectedWallet,
} as TriaArgs);

export type TriaArgs = {
  baseUrl: string;
  sentryDns?: string;
  walletType?: WalletType;
  selectedChainName?: ChainName;
  environment?: ENV;
  currentAccount?: IRelayPKP;
  sessionSignatures?: string;
  customAuthMethod?: LitCustomAuthMethod;
  accessToken?: string;
  aa?: AaDetails;
  selectedWallet?: "EOA" | "AA";
};

export type ENV = 'testnet' | 'mainnet-staging' | 'mainnet';

To maintain the integrity of the keyring object that stores decrypted vaults in memory, it is crucial to preserve its context. This implies that the keyring object should not be recreated, but rather instantiated only once.

Functions

Reconstruction of Vault

The ideal moment to invoke this method is immediately after a successful user login. This timing ensures that we have access to the user's password and pin, which are essential for decrypting and reconstructing the vault.

To ensure smooth functioning and optimal performance of the KeyringController, it is essential to call the following method as the first step before invoking any other methods. This method initializes the persist storage and in-memory data, laying the foundation for subsequent operations.

Additionally, it should be called only once during the application startup process. Repeated invocations of this method may result in unnecessary overhead, affecting efficiency.

Social Login [v2]

Create Account [v2]

Get Vault [v2]

Add Wallet

Export Mnemonic

Export Private Key

Update SubName

Remove Address

  • For Choose Asset or Assets display

  • filter - chainNames - makes sense only when sending to a subName i.e. only available on one chain

  • triaName- for fetching userDoc (vault with public keys) from db

  • Available now for -

Detect Logged in Account

Example implementation

Add this in auth.tria.so/detect and open this as a invisible iframe in the onboarding SDK to send events to the SDK, and read events with const {account} = useDetectAccount();

Last updated