The Plug Controller is a package that provides utility & logic to the Plug browser wallet extension, as well as the account creation and management. It handles the interactions between the extension and the Internet Computer as users interact with accounts, balances, canisters, and the network.
npm install @psychedelic/plug-controller
To install the package you need to be authenticated to Github via npm login
, ensure that you have:
- A personal access token (create one here) with the
public_repo
andread:packages
scopes to login to the GitHub Package Registry.
- Run the following command:
npm login --registry=https://npm.pkg.github.com --scope=@Psychedelic
- Use your Github username as username, then as password use your recently created personal access token and for public email your email associated with your Github account.
Plug Keyring is a class that manages the user's accounts and allows you to create/import a mnemonic and its keypair.
import PlugController from '@psychedelic/plug-controller';
const keyRing = new PlugController.PlugKeyRing();
// Initialize keyring and load state from extension storage
await keyRing.init();
// Creates the keyring and returns the default wallet
const wallet: PlugWallet = await keyRing.create(password);
// Creates the keyring using the provided mnemonic and returns the default wallet
const wallet: PlugWallet = await keyRing.importFromMnemonic(mnemonic, password);
Interface and Type definitions documents for the @Psychedelic/plug-controller implementation is provided in the following location.
These are based in the main release branch
and provide a good overview of the whole package (modules, IDL's, utils, etc).