GithubHelp home page GithubHelp logo

yetispapa / web3modal-angular Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nach0git/web3modal-angular

0.0 0.0 0.0 2.16 MB

License: MIT License

JavaScript 4.55% TypeScript 47.15% HTML 43.65% CSS 0.12% SCSS 4.51%

web3modal-angular's Introduction

Web3Modal-Angular

Angular's version of https://github.com/Web3Modal/web3modal. Built on top of 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.

Usage

  1. Install Web3Modal-Angular NPM package
npm install --save @mindsorg/web3modal-angular

Or

yarn add @mindsorg/web3modal-angular
  1. Import Web3ModalModule which contains and exports the Web3ModalComponent.

  2. Instantiate the Web3ModalService with the useFactory pattern:

@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 or Web3Modal-TS

The Web3WalletConnector constructors takes an optional configuration argument that matches the original web3modal's configuration object

See Web3Modal's provider options

  1. Declare m-web3-modal tag:
<m-web3-modal
  title="Modal Title"
  description="Modal description"
  descriptionGray="Modal subtitle"
  dismissText="Text that will dismiss modal on click"
></m-web3-modal>
  1. Call open on Web3ModalService
  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.

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

Additionally, it supports:

WalletLink

  1. Install Provider Package
npm install --save walletlink

# OR

yarn add walletlink
  1. Set Provider Options
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

web3modal-angular's People

Contributors

markharding avatar namesty avatar eliobricenov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.