Skip to content

A module for managing groups of Ethereum accounts and using them.

License

Notifications You must be signed in to change notification settings

Lohsea/KeyringController

 
 

Repository files navigation

Eth Keyring Controller CircleCI

A module for managing groups of Ethereum accounts called "Keyrings", defined originally for MetaMask's multiple-account-type feature.

To add new account types to a KeyringController, just make sure it follows The Keyring Class Protocol.

The KeyringController has three main responsibilities:

  • Initializing & using (signing with) groups of Ethereum accounts ("keyrings").
  • Keeping track of local nicknames for those individual accounts.
  • Providing password-encryption persisting & restoring of secret information.

Installation

yarn install eth-keyring-controller --save

Usage

const KeyringController = require('eth-keyring-controller')
const SimpleKeyring = require('eth-simple-keyring')

const keyringController = new KeyringController({
  keyringTypes: [SimpleKeyring], // optional array of types to support.
  initState: initState.KeyringController, // Last emitted persisted state.
  encryptor: { // An optional object for defining encryption schemes:
               // Defaults to Browser-native SubtleCrypto.
    encrypt (password, object) {
      return new Promise('encrypted!')
    },
    decrypt (password, encryptedString) {
      return new Promise({ foo: 'bar' })
    },
  },
})

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

Running tests

yarn test

Methods

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

About

A module for managing groups of Ethereum accounts and using them.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.4%
  • Shell 0.6%