# @johnny2022/web3-provider

> Web3 provider

Latest version **0.0.38** (published 2022-11-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @johnny2022/web3-provider
pnpm add @johnny2022/web3-provider
yarn add @johnny2022/web3-provider
bun add @johnny2022/web3-provider
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.38 |
| Published | 2022-11-17 |
| First published | 2022-09-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 383.9 KB |
| Known vulnerabilities | 0 (+24 in 1 direct dependencies) |
| Install scripts | no |
| Author | johnnycheungq@gmail.com |
| Maintainers | johnny2022 |
| Keywords | etheruem, hd, mnemonic, provider, wallet |

## Links

- npm: https://www.npmjs.com/package/@johnny2022/web3-provider
- Repository: https://github.com/
- npm.io page: https://npm.io/package/@johnny2022/web3-provider

## Dependencies (11)

- [web3](https://npm.io/package/web3.md) ^1.7.4
- [axios](https://npm.io/package/axios.md) ^0.27.2
- [@ethereumjs/tx](https://npm.io/package/@ethereumjs/tx.md) ^3.3.0
- [ethereumjs-util](https://npm.io/package/ethereumjs-util.md) ^7.1.5
- [ethereum-protocol](https://npm.io/package/ethereum-protocol.md) ^1.0.1
- [ethereumjs-wallet](https://npm.io/package/ethereumjs-wallet.md) ^1.0.2
- [@ethereumjs/common](https://npm.io/package/@ethereumjs/common.md) ^2.4.0
- [web3-provider-engine](https://npm.io/package/web3-provider-engine.md) 16.0.3
- [ethereum-cryptography](https://npm.io/package/ethereum-cryptography.md) 1.1.2
- [@metamask/eth-sig-util](https://npm.io/package/@metamask/eth-sig-util.md) ^4.0.1
- [@metamask/browser-passworder](https://npm.io/package/@metamask/browser-passworder.md) ^3.0.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.0.38 (latest) — 2022-11-17
- 0.0.36 — 2022-11-16
- 0.0.35 — 2022-11-14
- 0.0.34 — 2022-11-14
- 0.0.33 — 2022-11-11
- 0.0.32 — 2022-11-11
- 0.0.31 — 2022-11-11
- 0.0.30 — 2022-11-11
- 0.0.29 — 2022-11-11
- 0.0.28 — 2022-11-04
- 0.0.27 — 2022-11-02
- 0.0.26 — 2022-09-27
- 0.0.25 — 2022-09-25
- 0.0.24 — 2022-09-19
- 0.0.23 — 2022-09-19
- … 4 more at https://npm.io/package/@johnny2022/web3-provider/versions

## README

# @johnny2022/web3-provider
A commonplace web3 provider. Use it to sign and send transactions, to retrieve data, and generate accounts.

## Install

```
$ npm install @johnny2022/web3-provider --save
```

## Examples

Initialize with mnemonic
```javascript
const Web3 = require("web3");
const Web3Provider = require("@johnny2022/web3-provider");

const chainId = 1
const mnemonicPhrase = "mountains supernatural bird..."; // 12 word mnemonic
let provider = new Web3Provider({
  mnemonic: {
    phrase: mnemonicPhrase
  },
  providerOrUrl: "http://localhost:8545",
  chainSettings: { chainId }
});
```

Initialize with private key
```javascript
const Web3 = require("web3");
const Web3Provider = require("@johnny2022/web3-provider");

const chainId = 1
const privateKey = "0x000111......"; 
let provider = new Web3Provider({
  privateKeys: [
    privateKey
  ],
  providerOrUrl: "http://localhost:8545",
  chainSettings: { chainId }
});
```


Initialize with public key
```javascript
const Web3 = require("web3");
import { InitializeEthereumWithPublicKey } from "@johnny2022/web3-provider"

const chainId = 1
const publicKey = "0x000111......"; 
InitializeEthereumWithPublicKey("http://localhost:8545", chainId, publicKey);
```


Create your account and output mnemonic, private key and public key
```javascript
import { Web3Wallet } from "@johnny2022/web3-provider"

const chainId = 1
let password = "123456"
new Web3Wallet().createAccount(chainId, password)
.then(acc => {
  console.log(acc)
  // It will be output the {mnemonic: "hello world ...", publicKey: "0x0...", privateKey: "0x1..."}
})
```

---
_Source: https://npm.io/package/@johnny2022/web3-provider · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
