Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zhixian001/alchemy-api

Alchemy API module for Nest framework
https://github.com/zhixian001/alchemy-api

alchemy alchemyapi nest nestjs nodejs typescript web3

Last synced: 27 days ago
JSON representation

Alchemy API module for Nest framework

Awesome Lists containing this project

README

        


Nest Logo

# Nest Alchemy API module

## Description

[Alchemy Web3 API](https://www.npmjs.com/package/@alch/alchemy-web3) module for [Nest](https://github.com/nestjs/nest).

## Installation

```bash
$ npm i -s @darrenyeom/alchemy-api @alch/alchemy-web3
```

## Quickstart

> app.module.ts

```typescript
import { Module } from '@nestjs/common';
import { AlchemyApiModule } from '@darrenyeom/alchemy-api';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
imports: [
AlchemyApiModule.forRoot({
alchemyUrl:
'wss://eth-mainnet.alchemyapi.io/v2/',
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
```

> app.service.ts
```typescript
import { Injectable } from '@nestjs/common';
import { AlchemyApiService } from '@darrenyeom/alchemy-api';

@Injectable()
export class AppService {
constructor(private readonly alchemyApiService: AlchemyApiService) {}

async getBlockNumber() {
return this.alchemyApiService.client.eth.getBlockNumber();
}
}
```

## License

[MIT](LICENSE).