Skip to content

Instantly share code, notes, and snippets.

@GrandSchtroumpf
Created July 31, 2018 18:59
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/9c1191d26cc6f761bb66faaae2a92d4d to your computer and use it in GitHub Desktop.
Save GrandSchtroumpf/9c1191d26cc6f761bb66faaae2a92d4d to your computer and use it in GitHub Desktop.
The classic way to import web3 in Angular
import { environment } from '../environments/environment';
import { bindNodeCallback, Observable } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class Web3Service {
public web3: Web3;
constructor() {
this.web3 = new Web3(environment.web3Provider);
}
public getAccounts(): Observable<string[]> {
return bindNodeCallback(this.web3.eth.getAccounts)();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment