Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »


0.12.3-beta • Public • Published

Endpass Connect

Compatible with web3.js@0.37.0beta and below

Table of contents


Install library via npm of yarn.

npm i --save @endpass/connect
yarn add @endpass/connect

You don't need any dependencies like web3, Endpass Connect includes it out of the box.


Create instance of class and use it in your application. You can know about options and methods in the API section.

import Web3 from 'web3';
import EndpassConnect from '@endpass/connect';
const web3 = new Web3('https://network.url');
const connect = new EndpassConnect({
  appUrl: 'http://connect.url',
const provider = connect.extendProvider(web3);

Next, you can try to authentificate user.

try {
  const res = await connect.auth();
  // Now, you have active account address and network id
} catch (err) {
  // Something goes wrong! User is not authorized

Provider creating

If you want to use this library and process web3 requests through endpass services you should complete these conditions.

Install web3 library if you want to use it manually in you application. Create instance of web3 and create provider based on it:

import { HttpProvider } from 'web3-providers';
import Connect from '@endpass/connect';
const web3 = new Web3('https://network.url');
const connect = new Connect();
const provider = connect.extendProvider(HttpProvider);
// If you are using old versions of web3 (0.30.0-beta and below) you should call
// setProvider
// If you are using new versions of web3 (1.0.0 and more) you can reassign
// global property ethereum in application window object
window.ethereum = provider;
// We highly recommend to use both methods for more stability and compatibility
window.ethereum = provider;

If web3 can be found in application window object you can not install web3 manually, extendProvider also should try to find it.


Instance options

Property Type Default Description
authUrl string https://auth.endpass.com Url of Endpass Connect application.

Instance methods

Method Params Returns Description
auth Promise<{ status: boolean, message?: string }> Open Endpass Connect application for user authorization, return promise, which returns object with auth status. See Errors handling for more details.
logout Promise<Boolean> Makes logout request and returns status or throw error
getAccountData Promise<{ activeAccount: string, activeNet: number }> Returns authorized user active account.
extendProvider provider: Web3.Provider Web3Provider Creates Web3 provider for injection in Web3 instance.
setProviderSettings { activeAccount: string, activeNet: number } Set user settings to the injected web3 provider.
openAccount Promise<{ type: string, payload?: { activeAccount: string, activeNet: number } }> Open Endpass Connect application for change user active address, network or logout

Interactions with current account

If you use openAccount method connect application will open screen with user base settings: current account and network. You also can makes logout here. This method will return object with type field. This field determines response type. There is two types of response:

  • logout – means user makes logout from his account.
  • update – means user update account settings. Response also contains payload field with updated settings object.

At the same time update will set new account settings to injected provider. After this, you can refresh browser page or something else.


import Connect from '@endpass/connect';
const connect = new Connect();
connect.openAccount().then(res => {
  if (res.type === 'logout') {
    // User have logout here
  } else if (res.type === 'update') {
    // Account settings was updated by user
    console.log(res); // { activeAccount: "0x0", activeNet: 1 }


Command Description
build Builds application and library.
dev:app Starts application dev server.
build:app Builds application.
dev:lib Starts library development environment.
build:lib Builds library.
test:unit Runs unit tests.
format Formats code of packages with eslint and prettier.




npm i @endpass/[email protected]





Unpacked Size

2.33 MB

Total Files


Last publish


  • avatar
  • avatar
  • avatar
  • avatar