{"id":13407856,"url":"https://github.com/multiversx/mx-sdk-nestjs","last_synced_at":"2026-05-11T13:11:58.141Z","repository":{"id":40688643,"uuid":"507946518","full_name":"multiversx/mx-sdk-nestjs","owner":"multiversx","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-26T13:45:44.000Z","size":3948,"stargazers_count":13,"open_issues_count":11,"forks_count":14,"subscribers_count":18,"default_branch":"main","last_synced_at":"2025-04-02T08:06:33.815Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/multiversx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-27T14:39:48.000Z","updated_at":"2025-03-26T13:42:34.000Z","dependencies_parsed_at":"2024-01-16T14:42:08.049Z","dependency_job_id":"8615a6dd-0471-4b96-9e27-97416f848e14","html_url":"https://github.com/multiversx/mx-sdk-nestjs","commit_stats":{"total_commits":229,"total_committers":19,"mean_commits":"12.052631578947368","dds":0.6200873362445415,"last_synced_commit":"93c94508469f1c4564170919fe575578b55197a4"},"previous_names":["elrondnetwork/erdnest"],"tags_count":166,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiversx%2Fmx-sdk-nestjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiversx%2Fmx-sdk-nestjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiversx%2Fmx-sdk-nestjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiversx%2Fmx-sdk-nestjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/multiversx","download_url":"https://codeload.github.com/multiversx/mx-sdk-nestjs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247647488,"owners_count":20972875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:00:49.040Z","updated_at":"2026-05-11T13:11:58.134Z","avatar_url":"https://github.com/multiversx.png","language":"TypeScript","funding_links":[],"categories":["MultiversX official"],"sub_categories":["SDKs and dev tools"],"readme":"\u003ca href=\"https://www.npmjs.com/package/@multiversx/sdk-nestjs-common\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@multiversx/sdk-nestjs-common.svg\" alt=\"NPM Version\" /\u003e\u003c/a\u003e\n\n# MultiversX NestJS Microservice Utilities\n\nThis package contains a set of utilities commonly used in the MultiversX Microservice ecosystem.\n\nIt relies on the following peer dependencies which must be installed in the parent package:\n\n- @multiversx/sdk-core\n- @nestjs/common v11\n- @nestjs/swagger v11\n\n`ContractLoader` was removed in v7; load contracts in your application code and pass them to the query and transaction helpers directly.\n\n## Documentation\n\n- [Multiversx Docs](https://docs.multiversx.com/sdk-and-tools/sdk-nestjs)\n\n## CHANGELOG\n\n[CHANGELOG](CHANGELOG.md)\n\n## Packages\n\nThis monorepo contains the source code for the following packages:\n\n- @multiversx/sdk-nestjs-common [npm](https://www.npmjs.com/package/@multiversx/sdk-nestjs-common)\n- @multiversx/sdk-nestjs-auth [npm](https://www.npmjs.com/package/@multiversx/sdk-nestjs-auth)\n- @multiversx/sdk-nestjs-http [npm](https://www.npmjs.com/package/@multiversx/sdk-nestjs-http)\n- @multiversx/sdk-nestjs-monitoring [npm](https://www.npmjs.com/package/@multiversx/sdk-nestjs-monitoring)\n- @multiversx/sdk-nestjs-elastic [npm](https://www.npmjs.com/package/@multiversx/sdk-nestjs-elastic)\n- @multiversx/sdk-nestjs-redis [npm](https://www.npmjs.com/package/@multiversx/sdk-nestjs-redis)\n- @multiversx/sdk-nestjs-rabbitmq [npm](https://www.npmjs.com/package/@multiversx/sdk-nestjs-rabbitmq)\n- @multiversx/sdk-nestjs-cache [npm](https://www.npmjs.com/package/@multiversx/sdk-nestjs-cache)\n\n\n## Installation\n\n`sdk-nestjs-${package}` is delivered via **npm** and it can be installed as follows:\n\n```\nnpm install @multiversx/sdk-nestjs-${package}\n```\n\n## Code examples\n\nIn this section we will provide some code examples of how these packages can be used in your microservice.\n\nThese examples requires basic knowledge of NestJS framework, if you are not familiar with some of the key concepts like (Modules, Providers, Guards, Incerceptors, etc.) please make sure to check their documentation before proceeding with these examples. [NestJS Docs](https://docs.nestjs.com/#introduction)\n\nAs a rule of thumb, we recommend to import these modules everytime you use them, do not try to import them just once in the application root module.\n\nAlso, if you discover a feature that is missing and might be useful, we would appreciate if you open a PR to integrate it.\n\n### Caching\n\nCaching is one of the most important components when talking about high scalable applications that needs to serve thousands of requests per second.\n`sdk-nestjs-cache` uses both remote (redis) and local (in-memory) cache.\n\n#### Import\n\nIn your module:\n\n```\n@Module({\n  imports: [\n    CacheModule.forRootAsync({\n      imports: [ApiConfigModule],\n      useFactory: (apiConfigService: ApiConfigService) =\u003e new CacheModuleOptions({\n        url: apiConfigService.getRedisUrl(),\n        poolLimit: apiConfigService.getPoolLimit(),\n        processTtl: apiConfigService.getProcessTtl(),\n      }),\n      inject: [ApiConfigService],\n    });\n  ],\n  providers: [FeatureService]\n})\nexport class FeatureModule{}\n```\n\nIn your provider:\n\n```\nimport { CacheService } from \"@multiversx/sdk-nestjs-cache\";\n\n@Injectable()\nexport class FeatureService {\n  constructor(\n    private readonly cacheService: CacheService,\n  ) { }\n```\n\n#### Main Features\n\n`get`\n\nReturns a Promise with the value stored in cache at a specific key or undefined if key isn't in cache.\nIt searches the key first in local and then in remote cache.\n\n```\nconst value = await this.cacheService.get\u003cExpectedType\u003e(key);\n```\n\n`set`\n\nSet both local and remote cache keys with the value you provided. It also accepts a ttl value which represents the persistence time in seconds, if no value is provided it will use default ttl of 6 seconds.\n\n```\nawait this.cacheService.set(key, value, ttl);\n```\n\n`getOrSet`\n\nReturns a Promise with the value stored in cache at a specific key or set that key with the value you provided.\nIf you don't provide a remote ttl, it will use the default value of 6 seconds.\nIf you don't provide a local ttl, it will use half of the remote ttl value.\nIt also accepts a forceRefresh (boolean) parameter for situations you explicitly need to update the cache.\n\n```\nconst value = await this.cacheService.getOrSet(\n      key,\n      async () =\u003e await rawValue,\n      remoteCacheTtl,\n      localCacheTtl\n    );\n```\n\nThese are the most used features of the CacheModule, there are some more advanced features related to batch processing.\nIf you need something else please make sure to check our [CacheService](packages/cache/src/cache/cache.service.ts).\n\n### Smart Contract Interactions\n\nThis package is for dApps that interacts with smart contracts.\n\n`ContractLoader` is no longer part of this release line.\n\n#### Contract Query Runner\n\nExecute contract queries using a multiversx proxy provider (api/gateway).\n\n```\nconst cRunner = new ContractQueryRunner(new ApiNetworkProvider(this.apiConfigService.getApiUrl()));\n\nconst query = smartContract.methodsExplicit.getTotalLockedAssetSupply([]);\n\nconst queryResponse = await cRunner.runQuery(query, chainId, abi);\n```\n\n`smartContract` is created in your application code from `@multiversx/sdk-core`; the helper only needs the query, chain ID, and optional ABI.\n\n#### Contract Transaction Generator\n\nCreate transactions from smart contract interactions using and multiversx proxy provider (api/gateway).\n\n```\nconst txGenerator = new ContractTransactionGenerator(provider);\n\nconst tx = await this.transactionGenerator.createTransaction(interaction, signer.getAddress());\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultiversx%2Fmx-sdk-nestjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmultiversx%2Fmx-sdk-nestjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultiversx%2Fmx-sdk-nestjs/lists"}