Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tallyho/keyring-controller

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tallyho/keyring-controller

A module for managing keyrings, encrypting them, and using them across crypto networks.

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

keyring-controller

A module for managing key material for multiple crypto networks, called "keyrings", useful for building and managing wallets.

Originally forked from the library to manage key material in MetaMask, keyring-controller has the additional goals of strict type safety, strong test coverage, and greater cross-chain flexibility.

A KeyringController has two main responsibilities:

  • Generating keyrings and using them to sign messages and transactions
  • Providing encrypted serialization and deserialization of secret material.

Installation

npm install @tallyho/keyring-controller --save

Usage

import KeyringController from "@tallyho/keyring-controller"
import SimpleKeyring from "eth-simple-keyring"

const persistedVaults: string[] = []

const keyringController = new KeyringController({
  keyringTypes: [SimpleKeyring], // optional array of types to support.
  initState: { ... }, // Last emitted persisted state.
  encryptor: {
    // An optional object for defining encryption schemes:
    // Defaults to Browser-native SubtleCrypto.
    encrypt: async (password: string, data: any) => {
      return "encrypted!"
    },
    decrypt: async (password: string, cipherText: string) => {
      return { foo: "bar" }
    },
  },
  persistVault: async (encryptedVault: string) => {
    // toy example, it's up to the consumer to persist vaults somewhere safe!
    persistedVaults.push(encryptedVault)
  }
})

// The KeyringController is also an event emitter:
this.keyringController.on("newAccount", (address: string) => {
  console.log(`New account created: ${address}`)
})
this.keyringController.on("removedAccount", handleThat)

Extension

To add new account types to a KeyringController, just make sure it follows the Keyring class protocol.

Methods

Currently the methods are heavily commented in the source, so it's the best place to look until we aggregate it here as well.

Keywords

FAQs

Package last updated on 20 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc