npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ethers-tools-nestjs

v0.0.4

Published

NestJS wrapper for ethers-tools. Contains tools for work with EVM contracts.

Downloads

10

Readme

ethers-tools-nestjs

npm version

Click for Example

Description

A lightweight NestJS wrapper around ethers-tools.
This package provides convenient integration of ethers-tools into NestJS applications using standard Nest patterns like decorators and modules. Compatible with TypeScript and pure JavaScript.
JSDoc is provided.

Installation

First, you will need ethers v6 and ethers-tools:

npm i ethers
npm i ethers-tools
npm i ethers-tools-nestjs

or

yarn add ethers
yarn add ethers-tools
yarn add ethers-tools-nestjs

or

pnpm add ethers
pnpm add ethers-tools
pnpm add ethers-tools-nestjs

✨ Features

✅ Validators

@IsEthAddress

@Exclude()
export class GetCoinInfoQuery {
  @Expose()
  @IsOptional()
  @IsEthAddress({ message: 'Invalid user address' })
  userAddress?: string;
}

🛠 Contract & MulticallUnit Factories

The ethers-tools-nestjs package provides built-in support for creating contract instances and MulticallUnit builders dynamically within a NestJS application.

📦 Contract Factory

You can register a contract factory using createContractFactoryProvider:

import { Module } from '@nestjs/common';
import { createContractFactoryProvider } from 'ethers-tools-nestjs';
import { Erc20Contract } from './erc20.contract';
import { Erc20Abi } from './abis';

const erc20factory = createContractFactoryProvider(Erc20Contract, {
  abi: Erc20Abi,
});

@Module({
  providers: [erc20factory],
  exports: [erc20factory],
})
export class ContractsModule {}
constructor(
  @InjectContractFactory(Erc20Contract)
  private readonly token: ContractFactory<Erc20Contract>,
) {}

🤖 Auto Contract Factory

You can register a contract factory without a manual contract creation using createAutoContractFactoryProvider:

import { Module } from '@nestjs/common';
import {
  createAutoContractFactoryProvider,
  createMulticallFactoryProvider,
} from 'ethers-tools-nestjs';
import { Erc721Abi } from '@/contracts/abis';
import { NftService } from './nft.service';

const multicallFactoryProvider = createMulticallFactoryProvider(
  NftService.name,
);
const autoNftFactoryProvider = createAutoContractFactoryProvider(
  NftService.name,
  Erc721Abi,
);

@Module({
  providers: [multicallFactoryProvider, autoNftFactoryProvider, NftService],
  exports: [NftService],
})
export class NftModule {}
constructor(
  @InjectAutoContractFactory(NftService.name)
  private readonly nft: AutoContractFactory,
) {}

⚡ MulticallUnit Factory

The MulticallUnitFactory allows you to batch multiple calls:

import { Module } from '@nestjs/common';
import { createMulticallFactoryProvider } from 'ethers-tools-nestjs';
import { ContractsModule } from '@/contracts';
import { TokenService } from './token.service';

const multicallFactoryProvider = createMulticallFactoryProvider(
  TokenService.name,
);

@Module({
  imports: [ContractsModule],
  providers: [multicallFactoryProvider, TokenService],
  exports: [TokenService],
})
export class TokenModule {}
constructor(
  @InjectMulticallFactory(TokenService.name)
  private readonly multicall: MulticallFactory,
) {}

👀 Example:

import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { InjectPinoLogger, PinoLogger } from 'nestjs-pino';
import { JsonRpcProvider } from 'ethers';
import { Chain } from 'ethers-tools';
import {
  ContractFactory,
  MulticallFactory,
  InjectContractFactory,
  InjectMulticallFactory,
} from 'ethers-tools-nestjs';
import { Erc20Contract } from '@/contracts';
import { TokenInfo } from '@/entities/token';

@Injectable()
export class TokenService {
  constructor(
    private readonly config: ConfigService,
    @InjectPinoLogger(TokenService.name)
    private readonly logger: PinoLogger,
    @InjectContractFactory(Erc20Contract)
    private readonly token: ContractFactory<Erc20Contract>,
    @InjectMulticallFactory(TokenService.name)
    private readonly multicall: MulticallFactory,
  ) {}

  public async getTokenInfo(
    chain: Chain,
    tokenAddress: string,
    userAddress?: string,
  ): Promise<TokenInfo> {
    const driver: JsonRpcProvider = this.config.getOrThrow(
      `providers[${chain}]`,
    );
    const multicall = this.multicall.create({
      driver,
    });
    const contract = this.token.create({
      address: tokenAddress,
      driver,
    });
    multicall.addBatch([
      { call: contract.getNameCall() },
      { call: contract.getSymbolCall() },
      { call: contract.getTotalSupplyCall() },
      { call: contract.getDecimalsCall() },
    ]);
    if (userAddress) multicall.add(contract.getBalancesCall(userAddress));

    await multicall.run();
    const [name, symbol, totalSupply, decimals, balances] =
      multicall.getAllOrThrow<
        [string, string, bigint, bigint, bigint | undefined]
      >();

    return {
      name,
      symbol,
      totalSupply: totalSupply.toString(),
      decimals: Number(decimals),
      balances: balances?.toString(),
    };
  }
}