Simple in-memory keystore for mainly for testing purposes.
https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store
import { connect, keyStores, utils } from 'near-api-js';const privateKey = '.......';const keyPair = utils.KeyPair.fromString(privateKey);const keyStore = new keyStores.InMemoryKeyStore();keyStore.setKey('testnet', 'example-account.testnet', keyPair);const config = { keyStore, // instance of InMemoryKeyStore 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 functionconst near = await connect(config) Copy
import { connect, keyStores, utils } from 'near-api-js';const privateKey = '.......';const keyPair = utils.KeyPair.fromString(privateKey);const keyStore = new keyStores.InMemoryKeyStore();keyStore.setKey('testnet', 'example-account.testnet', keyPair);const config = { keyStore, // instance of InMemoryKeyStore 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 functionconst near = await connect(config)
Removes all KeyPair from in-memory storage
Gets the account(s) from in-memory storage
The targeted network. (ex. default, betanet, etc…)
Gets a KeyPair from in-memory storage
The NEAR account tied to the key pair
Get the network(s) from in-memory storage
Removes a KeyPair from in-memory storage
Stores a KeyPair in in-memory storage item
The key pair to store in local storage
Simple in-memory keystore for mainly for testing purposes.
See
https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store
Example