# ngweb3modal

> Angular's version of https://github.com/Web3Modal/web3modal. Built on top of [web3modal-ts](https://gitlab.com/minds/web3modal-ts/).

Latest version **1.0.3** (published 2022-02-03) · 0 weekly downloads

## Install

```sh
npm install ngweb3modal
pnpm add ngweb3modal
yarn add ngweb3modal
bun add ngweb3modal
```

## 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.3 |
| Published | 2022-02-03 |
| First published | 2022-02-02 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 14 |
| Unpacked size | 85.3 KB |
| Known vulnerabilities | 0 (+16 in 3 direct dependencies) |
| Install scripts | no |
| Maintainers | papiesz |

## Links

- npm: https://www.npmjs.com/package/ngweb3modal
- npm.io page: https://npm.io/package/ngweb3modal

## Dependencies (14)

- [rxjs](https://npm.io/package/rxjs.md) ~6.6.0
- [tslib](https://npm.io/package/tslib.md) ^2.0.0
- [zone.js](https://npm.io/package/zone.js.md) ^0.11.4
- [ngweb3modal](https://npm.io/package/ngweb3modal.md) ^1.0.3
- [@portis/web3](https://npm.io/package/@portis/web3.md) ^2.0.0-beta.59
- [@angular/forms](https://npm.io/package/@angular/forms.md) ^12.1.3
- [@angular/common](https://npm.io/package/@angular/common.md) ^12.1.3
- [@angular/router](https://npm.io/package/@angular/router.md) ^12.1.3
- [@angular/compiler](https://npm.io/package/@angular/compiler.md) ^12.1.3
- [@angular/animations](https://npm.io/package/@angular/animations.md) ^12.1.3
- [@toruslabs/torus-embed](https://npm.io/package/@toruslabs/torus-embed.md) ^1.11.0
- [@angular/platform-browser](https://npm.io/package/@angular/platform-browser.md) ^12.1.3
- [@walletconnect/web3-provider](https://npm.io/package/@walletconnect/web3-provider.md) ^1.3.1
- [@angular/platform-browser-dynamic](https://npm.io/package/@angular/platform-browser-dynamic.md) ^12.1.3

## Recent versions

- 1.0.3 (latest) — 2022-02-03
- 1.0.2 — 2022-02-03
- 1.0.1 — 2022-02-02
- 1.0.0 — 2022-02-02
- 0.0.0 — 2022-02-02

## README

# Web3Modal-Angular

Angular's version of https://github.com/Web3Modal/web3modal. Built on top of [web3modal-ts](https://gitlab.com/minds/web3modal-ts/).

## Motivation

Web3Modal is a very useful and easy to use library, that allows developers to add support for multiple providers in their apps with a simple customizable configuration. 

This project aims to provide the same ease of use as the original Web3Modal, in Angular, by leveraging the connectors/providers layer that the original Web3Modal implemented and was abstracted into [web3modal-ts](https://gitlab.com/minds/web3modal-ts/).

## Usage

1. Install Web3Modal-Angular NPM package

```bash
npm install --save @mindsorg/web3modal-angular
```

Or

```bash
yarn add @mindsorg/web3modal-angular
```

2. Import `Web3ModalModule` which contains and exports the `Web3ModalComponent`.

3. Instantiate the `Web3ModalService` with the `useFactory` pattern:

```ts
@NgModule({
  imports: [Web3ModalModule],
  providers: [
    {
      provide: Web3ModalService,
      useFactory: () => {
        return new Web3ModalService({
          network: "mainnet", // optional
          cacheProvider: true, // optional
          providerOptions // required
        });
      },
    },
  ]
})
```

For more information about the `Web3ModalService` constructor argument, see: [Web3Modal]((https://github.com/Web3Modal/web3modal#usage)) or [Web3Modal-TS](https://gitlab.com/minds/web3modal-ts/)

The `Web3WalletConnector` constructors takes an optional configuration argument that matches the [original web3modal's configuration object](https://github.com/Web3Modal/web3modal#usage)

See [Web3Modal's provider options](https://github.com/Web3Modal/web3modal#provider-options)

4. Declare `m-web3-modal` tag:

```html
<m-web3-modal
  title="Modal Title"
  description="Modal description"
  descriptionGray="Modal subtitle"
  dismissText="Text that will dismiss modal on click"
></m-web3-modal>
```

5. Call `open` on `Web3ModalService`

```ts
  const provider = await this.web3modalService.open();

```

This method returns a promise that resolves on connection and rejects on modal dismissal or connection errors.

The provider object resolved by the promise can be seamlessly consumed by a web3 library, like `Web3JS` or `EthersJS`.

```ts
import { Web3Provider } from '@ethersproject/providers';

const provider = await this.web3modalService.open();
const web3provider = new Web3Provider(provider)
```

## Provider Options

Web3Modal-TS supports the original Web3modal's Metamask WalletConnect, Fortmatic, Torus, Authereum, UniLogin, BurnerConnect, Portis, Squarelink, Arkane, Mew Connect protocol, D'CENT Wallet and Bitski. See [Web3Modal's provider options](https://github.com/Web3Modal/web3modal#provider-options)

Additionally, it supports:

### WalletLink

1. Install Provider Package

```bash
npm install --save walletlink

# OR

yarn add walletlink
```

2. Set Provider Options

```typescript
import WalletLink from "walletlink";

const providerOptions = {
  walletlink: {
    package: WalletLink,
    options: {
      infuraUrl: 'https://mainnet.infura.io/v3/PROJECT_ID',
      appName: "My Awesome DApp",
      appLogoUrl: "https://example.com/logo.png",
      darkMode: false
    },
  },
};
```

### Development Troubleshooting

If you experience issues using `npm link` for development, you can manually create a symbolic link in the node_modules folder.

```
# In your project front-end - e.g. minds/front
cd node_modules/@mindsorg

# Optional - make a copy of the existing module to save having to reinstall later. 
mv web3modal-angular .web3modal-angular

# Adjust the path below to point to the dist folder
ln -s ../../../web3modal-angular/dist/web3modal/ web3modal-angular
```

Now when you go into the web3modal-angular's folder, you can run `npm build` and changes to the web3 modal will be be built.

## License

MIT

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