Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

@dfinity/nns

Package Overview
Dependencies
Maintainers
9
Versions
1233
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dfinity/nns

A library for interfacing with the Internet Computer's Network Nervous System.

latest
Source
npmnpm
Version
12.1.0
Version published
Weekly downloads
20K
16.9%
Maintainers
9
Weekly downloads
 
Created
Source

nns-js

A library for interfacing with the Internet Computer's Network Nervous System.

npm version GitHub license

[!TIP] Still using @dfinity/nns? Upgrade to @icp-sdk/canisters/nns!

Table of contents

Installation

You can use nns-js by installing it in your project.

npm i @dfinity/nns

The bundle needs peer dependencies, be sure that following resources are available in your project as well.

npm i @icp-sdk/core @dfinity/utils

Usage

Most features are provided through the use of classes. For example, querying the list of neurons controlled by the caller with the governance canister:

import { NnsGovernanceCanister } from "@dfinity/nns";
import { createAgent } from "@dfinity/utils";

const agent = await createAgent({
  identity,
  host: HOST,
});

const { listNeurons } = NnsGovernanceCanister.create({
  agent,
  canisterId: MY_GOVERNANCE_CANISTER_ID,
});

const myNeurons = await listNeurons({ certified: false });

To execute this on a local environment, you will need to fetch the root key when initializing the agent. Additionally, you might need to adapt the port. The following snippet also demonstrates how you can inline a canister ID as well.

import { NnsGovernanceCanister } from "@dfinity/nns";
import { Principal } from "@icp-sdk/core/principal";
import { createAgent } from "@dfinity/utils";

const agent = await createAgent({
  identity,
  host: "http://localhost:8000",
  fetchRootKey: true,
});

const { listNeurons } = NnsGovernanceCanister.create({
  agent,
  canisterId: Principal.fromText("rrkah-fqaaa-aaaaa-aaaaq-cai"),
});

const myNeurons = await listNeurons({ certified: false });

Documentation

You can find the API docs here.

Keywords

internet computer

FAQs

Package last updated on 19 Dec 2025

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