Skip to content

Instantly share code, notes, and snippets.

@GrandSchtroumpf
Last active August 31, 2018 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GrandSchtroumpf/d9b2a01e0f7538aff692ca6080294ace to your computer and use it in GitHub Desktop.
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
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