This class is used to store keys on the file system.

See

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

Example

const { homedir } = require('os');
const { connect, keyStores } = require('near-api-js');

const keyStore = new keyStores.UnencryptedFileSystemKeyStore(`${homedir()}/.near-credentials`);
const config = {
keyStore, // instance of UnencryptedFileSystemKeyStore
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
    • UnencryptedFileSystemKeyStore

Constructors

Methods

  • Gets the account(s) files in keyDir/networkId

    Parameters

    • networkId: string

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

    Returns Promise<string[]>

  • Gets a KeyPair from an unencrypted file

    Parameters

    • networkId: string

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

    • accountId: string

      The NEAR account tied to the key pair

    Returns Promise<KeyPair>

  • Deletes an unencrypted file holding a KeyPair

    Parameters

    • networkId: string

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

    • accountId: string

      The NEAR account tied to the key pair

    Returns Promise<void>

  • Store a KeyPair in an unencrypted file

    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>

Generated using TypeDoc