@ngeth/eth
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

@ngeth/eth

The eth module of web3 rebuild for Angular

Setup

npm install @ngeth/eth --save

Import EthModule

import { AppComponent } from './app.component';
import { EthModule } from '@ngeth/eth';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    EthModule.forRoot(/* Provider */),  // You can add a custom Provider here
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

EthService

The EthService map the web3-eth methods into Observable.

import { Component, OnInit } from '@angular/core';
import { EthService } from '@ngeth/eth';
import { Observable } from 'rxjs';

@Component({
  selector: 'app-root',
  template: `
    <p>Current Block: {{ block$ | async }}</p>
    <ul>
        <li *ngFor="let account of accounts$ | async">
            {{ account }}
        </li>
    </ul>
    `,
  styles: []
})
export class AppComponent implements OnInit {
  public assets$: Observable<number>;
  public accounts$: Observable<string>;

  constructor(private eth: EthService) {}

  ngOnInit() {
    this.block$ = this.eth.getBlockNumber();
    this.accounts$ = this.eth.getAccounts();
  }

}

Contracts

The main strength of @ngeth/eth is the way it instanciate contract :

Package Sidebar

Install

npm i @ngeth/eth

Weekly Downloads

1

Version

0.0.5

License

MIT

Unpacked Size

295 kB

Total Files

27

Last publish

Collaborators

  • gabrielleh
  • phylante
  • grandschtroumpf