A Module written in javascript for managing various keyrings of Avalanche accounts, encrypting them, and using them.
npm install --save @getsafle/vault-avalanche-controller
const { KeyringController, getBalance } = require('@getsafle/vault-avalanche-controller');
const avalancheController = new KeyringController({
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' });
},
},
});
const keyringState = await avalancheController.createNewVaultAndKeychain(password);
const keyringState = await avalancheController.createNewVaultAndRestore(password, mnemonic);
const keyringState = await avalancheController.addNewAccount(keyringObject);
const privateKey = await avalancheController.exportAccount(address);
const signedTx = await avalancheController.signTransaction(rawTx, privateKey);
const signedMsg = await avalancheController.signMessage(msgParams);
const signedObj = await avalancheController.sign(msgParams, pvtKey, web3Obj);
const signedData = await avalancheController.signTypedMessage(msgParams);
const balance = await getBalance(address, web3);