Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
EthModule with web3 provider
import { NgModule, ModuleWithProviders, Type } from '@angular/core';
import { CommonModule } from '@angular/common';
// Web3
import { WEB3 } from './tokens';
const Web3 = require('web3');
// Services
import { AccountsService } from './eth.services';
@NgModule({
imports: [CommonModule],
declarations: [],
providers: [ AccountsService , {
provide: WEB3,
useFactory: (provider: any) => 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