Last active
January 27, 2020 21:59
-
-
Save alexytiger/fb00b187cd90250e5f3b5360217d50ad to your computer and use it in GitHub Desktop.
e-book
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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