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