web3connect

A single Web3 / Ethereum provider solution for all Wallets

Web3Connect was rebranded and deprecated in favor of Web3Modal. Please visit https://github.com/Web3Modal/web3modal for migration instructions.
Last updated 3 months ago by pedrouid .
LGPL-3.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install web3connect 
SYNC missed versions from official npm registry.

Web3Connect

A single Web3 / Ethereum provider solution for all Wallets

Introduction

Web3Connect is an easy-to-use library to help developers add support for multiple providers in their apps with a simple customizable configuration.

By default Web3Connect Library supports injected providers like (Metamask, Dapper, Gnosis Safe, Web3 Browsers, etc) and WalletConnect, You can also easily configure the library to support Portis, Fortmatic, Squarelink, Torus, Authereum and Arkane.

Preview

You can test the library on: https://web3connect.com/

preview

Projects using web3connect

Open a PR to add your project to the list!

Related Efforts

Usage

  1. Install Web3Connect NPM package
npm install --save web3connect

# OR

yarn add web3connect
  1. Install Provider packages
/* See Provider Options Section */
  1. Then you can add Web3Connect to your Dapp as follows
import Web3 from "web3";
import Web3Connect from "web3connect";

const providerOptions = {
  /* See Provider Options Section */
};

const web3Connect = new Web3Connect.Core({
  network: "mainnet", // optional
  cacheProvider: true, // optional
  providerOptions // required
});

const provider = await web3Connect.connect();

const web = new Web3(provider);

Provider Options

These are all the providers available with Web3Connect and how to configure their provider options

WalletConnect

  1. Install Provider Package
npm install --save @walletconnect/web3-provider

# OR

yarn add @walletconnect/web3-provider
  1. Set Provider Options
import WalletConnectProvider from "@walletconnect/web3-provider";

const providerOptions = {
  walletconnect: {
    package: WalletConnectProvider, // required
    options: {
      infuraId: "INFURA_ID" // required
    }
  }
};

Note: A WalletConnect instance is available on the provider as provider.wc

Portis

  1. Install Provider Package
npm install --save @portis/web3

# OR

yarn add @portis/web3
  1. Set Provider Options
import Portis from "@portis/web3";

const providerOptions = {
  portis: {
    package: Portis, // required
    options: {
      id: "PORTIS_ID" // required
    }
  }
};

Note: A Portis instance is available on the provider as provider._portis

Fortmatic

  1. Install Provider Package
npm install --save fortmatic

# OR

yarn add fortmatic
  1. Set Provider Options
import Fortmatic from "fortmatic";

const providerOptions = {
  fortmatic: {
    package: Fortmatic, // required
    options: {
      key: "FORTMATIC_KEY" // required
    }
  }
};

Note: A Fortmatic instance is available on the provider as provider.fm

Squarelink

  1. Install Provider Package
npm install --save squarelink

# OR

yarn add squarelink
  1. Set Provider Options
import Squarelink from "squarelink";

const providerOptions = {
  squarelink: {
    package: Squarelink, // required
    options: {
      id: "SQUARELINK_ID" // required
    }
  }
};

Note: A Squarelink instance is available on the provider as provider.sqlk

Torus

For more info please refer to Torus documentation

  1. Install Provider Package
npm install --save @toruslabs/torus-embed

# OR

yarn add @toruslabs/torus-embed
  1. Set Provider Options
import Torus from "@toruslabs/torus-embed";

const providerOptions = {
  torus: {
    package: Torus, // required
    options: {
      enableLogging: false, // optional
      buttonPosition: "bottom-left", // optional
      buildEnv: "production", // optional
      showTorusButton: true, // optional
      enabledVerifiers: {
        // optional
        google: false // optional
      }
    }
  }
};

Note: A Torus instance is available on the provider as provider.torus

Arkane

  1. Install Provider Package
npm install --save @arkane-network/web3-arkane-provide

# OR

yarn add @arkane-network/web3-arkane-provide
  1. Set Provider Options
import Arkane from "@arkane-network/web3-arkane-provider";

const providerOptions = {
  arkane: {
    package: Arkane, // required
    options: {
      clientId: "ARKANE_CLIENT_ID" // required, replace
    }
  }
};

Authereum

  1. Install Provider Package
npm install --save authereum

# OR

yarn add authereum
  1. Set Provider Options
import Authereum from "authereum";

const providerOptions = {
  authereum: {
    package: Authereum, // required
    options: {}
  }
};

Note: An Authereum instance is available on the provider as provider.authereum

BurnerConnect

  1. Install Provider Package
npm install --save @burner-wallet/burner-connect-provider

# OR

yarn add @burner-wallet/burner-connect-provider
  1. Set Provider Options
import BurnerConnectProvider from "@burner-wallet/burner-connect-provider";

const providerOptions = {
  burnerconnect: {
    package: BurnerConnectProvider, // required
    options: {}
  }
};

Utils

function checkInjectedProviders(): IInjectedProvidersMap;
function verifyInjectedProvider(check: string): boolean;
function getInjectedProviderName(): string | null;
function getProviderInfoByName(name: string | null): IProviderInfo;
function getProviderInfo(provider: any): IProviderInfo;
function isMobile(): boolean;

Types

interface IInjectedProvidersMap {
  injectedAvailable: boolean;
  [isProviderName: string]: boolean;
}

interface IProviderInfo {
  id: string;
  name: string;
  type: string;
  logo: string;
  check: string;
  package: IProviderPackageOptions;
  styled: IProviderStyledOptions;
}

interface IProviderPackageOptions {
  required: string[];
}

interface IProviderStyledOptions {
  [prop: string]: any;
}

interface IProviderOptions {
  [id: string]: {
    package: any;
    options: any;
  };
}

interface IProviderMappingEntry {
  id: string;
  name: string;
  connector: any;
  package: IProviderPackageOptions;
}

Connect to specific provider

In case you want to connect a specific provider, you can use the method connectTo and use the specific id. Example:

import Web3 from "web3";
import Web3Connect from "web3connect";

const providerOptions = {
  /* See Provider Options Section */
};

const web3Connect = new Web3Connect.Core({
  network: "mainnet", // optional
  cacheProvider: true, // optional
  providerOptions // required
});

const provider = await web3Connect.connectTo("walletconnect");

const web = new Web3(provider);

Optional Flags

Disable Injected Provider

By default is set to false and Web3Connect always displays InjectedProvider as an option to the user if available. However you can disable it as an optional flag if you desire:

const web3Connect = new Web3Connect.Core({ disableInjectedProvider: true });

Cache Provider

By default is set to false and Web3Connect will always require the user to choose a provider option before triggering the onConnect event. However you can enable caching the last chosen provider. Example:

const web3Connect = new Web3Connect.Core({ cacheProvider: true });

If you wish to reset the cached provider you can call the following method:

web3Connect.clearCachedProvider();

If you wish to connect to the cachedProvider you can simply do the following:

if (web3Connect.cachedProvider) {
  await web3Connect.connect();
}

Adding a new provider

Do you want to add your provider to Web3Connect? All logic for supported providers lives inside the src/providers directory. To add a new follow the following steps here

Collaboration

Code contributions are welcome ❤️❤️❤️!

If you wish to support a new provider submit a issue to the repo or fork this repo and create a pull request.

You can join to our discord to further discuss https://discordapp.com/invite/YGnSX9y

Current Tags

  • 1.0.0-beta.21                                ...           dev (9 months ago)
  • 1.0.0-beta.33                                ...           latest (3 months ago)

34 Versions

  • 1.0.0-beta.33 [deprecated]           ...           3 months ago
  • 1.0.0-beta.32 [deprecated]           ...           4 months ago
  • 1.0.0-beta.31 [deprecated]           ...           4 months ago
  • 1.0.0-beta.30 [deprecated]           ...           4 months ago
  • 1.0.0-beta.29 [deprecated]           ...           4 months ago
  • 1.0.0-beta.28 [deprecated]           ...           4 months ago
  • 1.0.0-beta.27 [deprecated]           ...           4 months ago
  • 1.0.0-beta.26 [deprecated]           ...           4 months ago
  • 1.0.0-beta.25 [deprecated]           ...           6 months ago
  • 1.0.0-beta.24 [deprecated]           ...           7 months ago
  • 1.0.0-beta.23 [deprecated]           ...           8 months ago
  • 1.0.0-beta.22 [deprecated]           ...           9 months ago
  • 1.0.0-beta.21 [deprecated]           ...           9 months ago
  • 1.0.0-beta.20 [deprecated]           ...           9 months ago
  • 1.0.0-beta.19 [deprecated]           ...           10 months ago
  • 1.0.0-beta.18 [deprecated]           ...           10 months ago
  • 1.0.0-beta.17 [deprecated]           ...           10 months ago
  • 1.0.0-beta.16 [deprecated]           ...           10 months ago
  • 1.0.0-beta.15 [deprecated]           ...           10 months ago
  • 1.0.0-beta.14 [deprecated]           ...           10 months ago
  • 1.0.0-beta.13 [deprecated]           ...           a year ago
  • 1.0.0-beta.12 [deprecated]           ...           a year ago
  • 1.0.0-beta.11 [deprecated]           ...           a year ago
  • 1.0.0-beta.10 [deprecated]           ...           a year ago
  • 1.0.0-beta.9 [deprecated]           ...           a year ago
  • 1.0.0-beta.8 [deprecated]           ...           a year ago
  • 1.0.0-beta.7 [deprecated]           ...           a year ago
  • 1.0.0-beta.6 [deprecated]           ...           a year ago
  • 1.0.0-beta.5 [deprecated]           ...           a year ago
  • 1.0.0-beta.4 [deprecated]           ...           a year ago
  • 1.0.0-beta.3 [deprecated]           ...           a year ago
  • 1.0.0-beta.2 [deprecated]           ...           a year ago
  • 1.0.0-beta.1 [deprecated]           ...           a year ago
  • 1.0.0-beta [deprecated]           ...           a year ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 35
Dependencies (8)
Dev Dependencies (26)

Copyright 2014 - 2017 © taobao.org |