near-kit provides several KeyStore implementations to suit different environments, from temporary testing to secure production servers.
1. InMemoryKeyStore (Testing & Scripts)
- Best for: Unit tests, CI/CD, and short-lived scripts.
2. FileKeyStore (Dev & Servers)
- Best for: Local development and simple server deployments.
- Requires: Node.js or Bun.
~/.near-credentials directory. This makes it compatible with the NEAR CLI.
3. NativeKeyStore (Maximum Security)
- Best for: Production servers, desktop apps, and CLI tools.
- Requires: Node.js/Bun and
@napi-rs/keyring.
Note: OS Keyrings do not allow listing all keys for security reasons. You must know the accountId you want to retrieve.
4. RotatingKeyStore (High Throughput)
- Best for: Trading bots, faucets, and high-traffic relayers.
InvalidNonce errors.
RotatingKeyStore solves this by managing multiple keys for a single account and rotating through them round-robin.
Permissions
When you add a key to an account (using.addKey), you define what that key can do.
Full Access
Can do anything: transfer NEAR, delete the account, deploy code, add more keys.- Use case: Your main admin key.
Function Call Access
Can only call specific methods on a specific contract. It cannot transfer NEAR.- Use case: “Log in with NEAR”, limited session keys, automated agents.