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