Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@catalist-nestjs/contracts

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@catalist-nestjs/contracts

NestJS Contracts Module for Catalist Finance projects. Part of [Catalist NestJS Modules](https://github.com/blockarchivelabs/catalist-nestjs-modules/#readme)

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Contracts Module

NestJS Contracts Module for Catalist Finance projects. Part of Catalist NestJS Modules

Install

yarn add @catalist-nestjs/contracts

Usage

Basic usage

// Import
import { Module } from '@nestjs/common';
import { CatalistContractModule } from '@catalist-nestjs/contracts';
import { getDefaultProvider } from '@ethersproject/providers';
import { MyService } from './my.service';

@Module({
  imports: [
    CatalistContractModule.forFeature({
      provider: getDefaultProvider('mainnet'),
    }),
  ],
  providers: [MyService],
  exports: [MyService],
})
export class MyModule {}

// Usage
import { CATALIST_CONTRACT_TOKEN, Catalist } from '@catalist-nestjs/contracts';
import { Inject } from '@nestjs/common';

export class MyService {
  constructor(@Inject(CATALIST_CONTRACT_TOKEN) private contract: Catalist) {}

  async myMethod() {
    return await this.contract.decimals();
  }
}

Specify a different address:

CatalistContractModule.forFeature({
  address: '0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84',
});

Global usage

import { Module } from '@nestjs/common';
import { CatalistContractModule } from '@catalist-nestjs/contracts';

@Module({
  imports: [CatalistContractModule.forRoot()],
})
export class MyModule {}

Async usage

import { Module } from '@nestjs/common';
import { CatalistContractModule } from '@catalist-nestjs/contracts';
import { ConfigModule, ConfigService } from './config.service';

@Module({
  imports: [
    CatalistContractModule.forRootAsync({
      async useFactory(testService: TestService) {
        return { address: testService.address };
      },
      inject: [TestService],
    }),
  ],
})
export class MyModule {}

Use global provider

import { Module } from '@nestjs/common';
import { CatalistContractModule } from '@catalist-nestjs/contracts';
import { ProviderModule } from './provider.service';

@Module({
  imports: [ProviderModule.forRoot(), CatalistContractModule.forRoot()],
})
export class MyModule {}

How to add new abi

  1. Put ABI into packages/contracts/abi folder
  2. Set up packages/contracts/<your name of abi>: module, contracts
  3. Nice to have: add test for ABI: packages/contracts/test/contracts.spec.ts
  4. Go through install FAQ
  5. Enjoy

Keywords

FAQs

Package last updated on 30 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc