Guest User

Untitled

a guest
Dec 10th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import { Component, Inject, OnInit } from '@angular/core';
  2. import { WEB3 } from './web3';
  3. import Web3 from 'web3';
  4.  
  5. @Component({
  6. selector: 'app-root',
  7. templateUrl: './app.component.html',
  8. styleUrls: ['./app.component.css']
  9. })
  10. export class AppComponent implements OnInit {
  11. constructor(@Inject(WEB3) private web3: Web3) {}
  12.  
  13. async ngOnInit() {
  14. if ('enable' in this.web3.currentProvider) {
  15. await this.web3.currentProvider.enable();
  16. }
  17. const accounts = await this.web3.eth.getAccounts();
  18. console.log(accounts);
  19. }
  20. }
Add Comment
Please, Sign In to add comment