Last active
August 31, 2018 12:02
-
-
Save GrandSchtroumpf/d9b2a01e0f7538aff692ca6080294ace to your computer and use it in GitHub Desktop.
The old way to build an Ethereum module that exposes the WEB3 Token
This file contains 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'; | |
import { CommonModule } from '@angular/common'; | |
import Web3 from 'web3'; | |
// Create an Injection Token with web3 inside | |
export const WEB3 = new InjectionToken<Web3>('web3'); | |
@NgModule({ | |
imports: [ | |
CommonModule, | |
], | |
providers: [{ | |
provide: WEB3, | |
useFactory: () => new Web3(Web3.givenProvider || "ws://localhost:8546"), | |
}] | |
}) | |
export class EthereumModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment