This class is used to store keys in the browsers local storage.

See

https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store

Example

import { connect, keyStores } from 'near-api-js';

const keyStore = new keyStores.BrowserLocalStorageKeyStore();
const config = {
keyStore, // instance of BrowserLocalStorageKeyStore
networkId: 'testnet',
nodeUrl: 'https://rpc.testnet.near.org',
walletUrl: 'https://wallet.testnet.near.org',
helperUrl: 'https://helper.testnet.near.org',
explorerUrl: 'https://explorer.testnet.near.org'
};

// inside an async function
const near = await connect(config)

Hierarchy

  • KeyStore
    • BrowserLocalStorageKeyStore

Constructors

Methods

  • Gets the account(s) from local storage

    Parameters

    • networkId: string

      The targeted network. (ex. default, betanet, etc…)

    Returns Promise<string[]>

  • Gets a KeyPair from local storage

    Parameters

    • networkId: string

      The targeted network. (ex. default, betanet, etc…)

    • accountId: string

      The NEAR account tied to the key pair

    Returns Promise<KeyPair>

  • Removes a KeyPair from local storage

    Parameters

    • networkId: string

      The targeted network. (ex. default, betanet, etc…)

    • accountId: string

      The NEAR account tied to the key pair

    Returns Promise<void>

  • Stores a KeyPair in local storage.

    Parameters

    • networkId: string

      The targeted network. (ex. default, betanet, etc…)

    • accountId: string

      The NEAR account tied to the key pair

    • keyPair: KeyPair

      The key pair to store in local storage

    Returns Promise<void>