# @getsafle/vault-polygon-zkevm-controller

> Polygon zkEVM controller for Safle Vault

Latest version **1.0.1** (published 2024-02-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @getsafle/vault-polygon-zkevm-controller
pnpm add @getsafle/vault-polygon-zkevm-controller
yarn add @getsafle/vault-polygon-zkevm-controller
bun add @getsafle/vault-polygon-zkevm-controller
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-02-15 |
| First published | 2023-12-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 33.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | safle |
| Maintainers | subhanshugupta, apoorv31, shubham.3008, sidth |
| Keywords | polygon-zkevm, keyring, polygon, zkEVM |

## Links

- npm: https://www.npmjs.com/package/@getsafle/vault-polygon-zkevm-controller
- Repository: https://github.com/getsafle/vault-polygon-zkevm-controller
- Homepage: https://github.com/getsafle/vault-polygon-zkevm-controller#readme
- Issues: https://github.com/getsafle/vault-polygon-zkevm-controller/issues
- npm.io page: https://npm.io/package/@getsafle/vault-polygon-zkevm-controller

## Dependencies (13)

- [web3](https://npm.io/package/web3.md) ^1.6.0
- [axios](https://npm.io/package/axios.md) ^1.6.2
- [bip39](https://npm.io/package/bip39.md) ^3.0.4
- [hdkey](https://npm.io/package/hdkey.md) ^2.0.1
- [loglevel](https://npm.io/package/loglevel.md) ^1.7.1
- [crypto-js](https://npm.io/package/crypto-js.md) ^4.2.0
- [obs-store](https://npm.io/package/obs-store.md) ^4.0.3
- [eth-sig-util](https://npm.io/package/eth-sig-util.md) ^3.0.1
- [ethereumjs-tx](https://npm.io/package/ethereumjs-tx.md) ^1.3.7
- [eth-hd-keyring](https://npm.io/package/eth-hd-keyring.md) ^3.6.0
- [ethereumjs-util](https://npm.io/package/ethereumjs-util.md) ^7.1.0
- [browser-passworder](https://npm.io/package/browser-passworder.md) ^2.0.3
- [eth-simple-keyring](https://npm.io/package/eth-simple-keyring.md) ^4.2.0

## Recent versions

- 1.0.1 (latest) — 2024-02-15
- 1.0.0 — 2023-12-19

## README

# vault-polygon-zkEVM-controller <code><a href="https://www.docker.com/" target="_blank"><img height="50" src="https://zkevm.polygonscan.com/images/logo.svg?v=23.11.4.0"></a></code>

[![npm version](https://badge.fury.io/js/@getsafle%2Fvault-polygon-zkevm-controller.svg)](https://badge.fury.io/js/@getsafle%2Fvault-polygon-zkevm-controller)    <img alt="Static Badge" src="https://img.shields.io/badge/License-MIT-green">   [![Discussions][discussions-badge]][discussions-link]
 <img alt="Static Badge" src="https://img.shields.io/badge/Polygon zkEVM_controller-documentation-purple">    

A Module written in javascript for managing various keyrings of Polygon-zkEVM accounts, encrypting them, and using them.

- [Installation](#installation)
- [Initialize the Polygon-zkEVM Controller class](#initialize-the-polygon-zkevm-controller-class)
- [Methods](#methods)
  - [Generate Keyring with 1 account and encrypt](#generate-keyring-with-1-account-and-encrypt)
  - [Restore a keyring with the first account using a mnemonic](#restore-a-keyring-with-the-first-account-using-a-mnemonic)
  - [Add a new account to the keyring object](#add-a-new-account-to-the-keyring-object)
  - [Export the private key of an address present in the keyring](#export-the-private-key-of-an-address-present-in-the-keyring)
  - [Sign a transaction](#sign-a-transaction)
  - [Sign a message](#sign-a-message)
  - [Get balance](#get-balance)

## Installation
```
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

### Generate Keyring with 1 account and encrypt

```
const keyringState = await polygon_zkevmController.createNewVaultAndKeychain(password);
```

### Restore a keyring with the first account using a mnemonic

```
const keyringState = await polygon_zkevmController.createNewVaultAndRestore(password, mnemonic);
```

### Add a new account to the keyring object

```
const keyringState = await polygon_zkevmController.addNewAccount(keyringObject);
```

### Export the private key of an address present in the keyring

```
const privateKey = await polygon_zkevmController.exportAccount(address);
```

### Sign a transaction

```
const signedTx = await polygon_zkevmController.signTransaction(polygon-zkevmTx, privateKey);
```

### Sign a message

```
const signedMsg = await polygon_zkevmController.signMessage(msgParams);
```

### Sign a message

```
const signedObj = await polygon_zkevmController.sign(msgParams, pvtKey, web3Obj);
```

### Sign Typed Data (EIP-712)

```
const signedData = await polygon_zkevmController.signTypedMessage(msgParams);
```

### Get balance

```
const balance = await getBalance(address, web3);
```
[discussions-badge]: https://img.shields.io/badge/Code_Quality-passing-rgba
[discussions-link]: https://github.com/getsafle/vault-polygon-zkevm-controller/actions

---
_Source: https://npm.io/package/@getsafle/vault-polygon-zkevm-controller · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
