0.6.0 • Published 3 years ago

@giacomo.licari/safe-apps-web3-react v0.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Safe Apps Web3-react connector

A connector to be used with web3-react package

Installation

yarn add @giacomo.licari/safe-apps-web3-react

npm install @giacomo.licari/safe-apps-web3-react

Usage

import { SafeAppConnector } from '@giacomo.licari/safe-apps-web3-react';

The connector follows web3-react's connectors API convention. Visit web3-react repo for more details

Helper hook

You can use our helper hook to automatically connect to a safe, it will automatically connect to the Safe if it detects that it's loaded in Safe App context:

import { useSafeAppConnection, SafeAppConnector } from '@giacomo.licari/safe-apps-web3-react';

const safeMultisigConnector = new SafeAppConnector();

const App = () => {
  const triedToConnectToSafe = useSafeAppConnection(safeMultisigConnector);

  React.useEffect(() => {
    if (triedToConnectToSafe) {
      // fallback to other providers
    }
  }, [triedToConnectToSafe]);
};

More scenarios

For the SDK overview documentation, please refer to the safe-apps-sdk documentation