This is the primary way to use the MEWconnect Protocol client.

new MEWconnect.Provider([options]);

Options

The MEWconnect.Provider can take an options object with the following fields:

  • infuraId (default none)

    Your InfuraId to connect with an infura node.

  • windowClosedError (default false)

    Indicates whether the provider should throw an error when the popup window is closed by the user.

  • subscriptionNotFoundNoThrow (default true)

    Indicates whether the provider should throw an error when the popup window is closed by the user.

  • chainId (default 1)

    Chain ID to use (if supplied here it may be omitted from the makeWeb3Provider call)

  • rpcUrl (default none)

    The Ethereum websocket url to connect to (if supplied here it may be omitted from the makeWeb3Provider call).

    The rpcUrl may also be omitted if an infura ID is supplied.

  • noUrlCheck (default false)

    Check that the url supplied

Events

const mewConnect = new MEWconnect.Provider()
mewConnect.on('[event]')
  • popupWindowClosed

    Emitted when the popup window is closed by the user

  • disconnected

    Emitted when the user becomes disconnected (Both by disconnecting and if the connection is broken)


Methods

makeWeb3Provider([chainId, rpcUrl, noUrlCheck])

Parameters:

  • chainId

    Chain Id, currently only Mainnet is supported

  • rpcUrl

    node url (such as an infura url: wss://mainnet.infura.io/v3/). **Only Websockets are supported.**

  • noUrlCheck

    don’t check the RPC_URL

Returns

  • A web3 provider instance

    Additional methods on the returned web3 provider

isMEWconnect

and Alias:

isMewConnect
name
  • Returns
    close
    
Enable

(Also available on the Web3 provider returned by makeWeb3Provider)

enable()

Returns

  • Promise that resolves with an array of addresses. (At present at most 1 address is returned)

Calling enable() a second time will bring the QRcode pop-up window into focus (as in the case it is attached to a click event. Once created it would not create a second instance, but bring the current instance into focus.)

Calling enable() once a connection is established resolves with the array of addresses.

Disconnect
disconnect()

Returns

  • Boolean (true if successful, false if an error occurs)

Static Getters

mewConnect.Provider.getConnectionState

The present connection state. The values are one of:

  • disconnected
  • connecting
  • connected
mewConnect.Provider.isConnected

Returns

  • True - if connected
  • False - if disconnected or connecting