Skip to content

Instantly share code, notes, and snippets.

@alexytiger
Last active January 27, 2020 21:59
Show Gist options
  • Save alexytiger/fb00b187cd90250e5f3b5360217d50ad to your computer and use it in GitHub Desktop.
Save alexytiger/fb00b187cd90250e5f3b5360217d50ad to your computer and use it in GitHub Desktop.
e-book
import { InjectionToken} from '@angular/core';
export const MetamaskEthereumToken = new InjectionToken(
'MetaMask Web3 provider',
{
providedIn: 'root',
factory: () => {
const ethereum = (window as any).ethereum;
// Returns true or false, representing whether the user has MetaMask installed.
if (!ethereum || !ethereum.isMetaMask) {
throw new Error('Please install MetaMask.');
}
return ethereum;
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment