Manifold for Developers

Manifold Ethereum Provider

This section is for advanced users only. If you are just working on frontend integration, you can skip right to the Connect Widget documentation.


The Manifold Ethereum Provider is a wrapper around ethers that provides a number of convenience APIs for chain detection, wallet detection and automated provider switching (it will use the injected browser provider whenever possible).
The Manifold Ethereum Provider is typically instantiated by the Connect Widget and injected into your window as window.ManifoldEthereumProvider.
The Manifold Ethereum Provider uses ethers.js

Built-in Provider Functions

The Manifold Ethereum Provider provides the following functions to interact with the blockchain


  • async initialize(network?: number, fallbackWebsocketHost?: string) this initializes an instance of the the Manifold Ethereum Provider. If you are using the Connect Widget, there is no need to call this function, as it is automatically initiated by the widget.
    • network - specify which network (by chainId) your dApp works on. If you do not provide a network, means your dApp works on any network.
      • IMPORTANT: Make sure every call to initialize uses the same network. If you are using the Connect Widget or any other Manifold Widgets, they call initialize with the network prop provided.
    • fallbackWebsocketHost - used when there is no detected browser provider.
  • async setSigningProvider(signingProvider: ethers.Provider) explicitly set a provider for any contract interactions that require signing.

Connection Information

  • chainId() gets the chain of currently connection
  • chainIsCorrect() if you specified a network on initialization, tells you if the wallet is connected to the right network
  • network() returns the network that was configured on initialization
  • hasBrowserProvider() returns whether or not a browser provider was detected (e.g. Metamask, Coinbase Wallet, Brave, etc.)
  • provider(withSigner=false) returns an ethers.Provider instance. The library will try to use the browser provider whenever possible.
    • withSigner - indicate if you want an ethers.Provider instance that can sign transactions. By default, it will give you a provider that can do read only operations.
  • selectedAddress() returns the current connected wallet address
  • selectedENSName() returns the ENS name of the current connected wallet address

Wallet and Contract Interaction

  • async switchToCorrectChain() if you specified a network on initialization, triggers the browser provider to switch to the configured network
  • async connect() trigger a prompt for the user to allow connection to your dApp. The Connect Widget calls this function when 'Connect' is clicked
  • async disconnect() disconnects the user from the dApp.
  • contractInstance(address, abi, signer=false) get an ethers.Contract instance that is automatically connected to the most optimal ethers.Provider available.
    • address - the address of the smart contract
    • abi - the abi of the smart contract
    • signer - whether or not you need to perform read only (signer=false) or write (signer=true) operations on the smart contract
  • contractFactoryInstance(abi, bytecode) gets an ethers.ContractFactory instance
    • abi - the abi of the smart contract
    • bytecode - the bytecode of the smart contract you wish to deploy
  • getOAuth(options: OAuthOptions) get an authenticated session. Used for server-to-server authentication and to access Data Client API's via the Connect Widget (only need to be called if you are using the data-delay-auth prop)
    • options - OAuthOptions consisting of: { grantType: <one of token or signature>; appName: string; clientId: string; }

Observable Events

Additionally, there are a number of events the Manifold Ethereum Provider will emit. You can listen to these events with a standard listener like this:
window.addEventListener(manifoldEthereumProvider.ADDRESS_CHANGED, (event) => {
// do something here
Here is a list of all events the provider emits:
  • ethereum-address-changed - emitted when the user's address changes (including from undefined to 0x...)
  • ethereum-provider-chain-changed - emitted when the user changes chain
  • ethereum-provider-changed - emitted when the user's provider changes