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