Polygon zkEVM controller for Safle Vault
npm install @getsafle/vault-polygon-zkevm-controller
 [![Discussions][discussions-badge]][discussions-link]
A Module written in javascript for managing various keyrings of Polygon-zkEVM accounts, encrypting them, and using them.
- Installation
- Initialize the Polygon-zkEVM Controller class
- Methods
- Generate Keyring with 1 account and encrypt
- Restore a keyring with the first account using a mnemonic
- Add a new account to the keyring object
- Export the private key of an address present in the keyring
- Sign a transaction
- Sign a message
- Get balance
npm install --save @getsafle/vault-polygon-zkEVM-controller
`
Initialize the Polygon-zkEVM Controller class
`
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' });
},
},
});
`Methods
$3
`
const keyringState = await polygon_zkevmController.createNewVaultAndKeychain(password);
`$3
`
const keyringState = await polygon_zkevmController.createNewVaultAndRestore(password, mnemonic);
`$3
`
const keyringState = await polygon_zkevmController.addNewAccount(keyringObject);
`$3
`
const privateKey = await polygon_zkevmController.exportAccount(address);
`$3
`
const signedTx = await polygon_zkevmController.signTransaction(polygon-zkevmTx, privateKey);
`$3
`
const signedMsg = await polygon_zkevmController.signMessage(msgParams);
`$3
`
const signedObj = await polygon_zkevmController.sign(msgParams, pvtKey, web3Obj);
`$3
`
const signedData = await polygon_zkevmController.signTypedMessage(msgParams);
`$3
`
const balance = await getBalance(address, web3);
``