aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/provider.ts
blob: 49705fd1105b96d60050e71b3a0445e52fac4a97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
import { Provider } from 'ethereum-types';

export const getProvider = (): Provider => {
    const injectedWeb3 = (window as any).web3 || undefined;
    try {
        // Use MetaMask/Mist provider
        return injectedWeb3.currentProvider;
    } catch (err) {
        // Throws when user doesn't have MetaMask/Mist running
        throw new Error(`No injected web3 found: ${err}`);
    }
};