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

near2ts

v0.4.1

Published

Effortlessly create TypeScript types for your NEAR smart contracts.

Readme

near2ts

Effortlessly create TypeScript types for your NEAR smart contracts.

Within the NEAR ecosystem, the ABI is depicted as a JSON schema outlining the contract's interface. Utilizing this library enables you to quickly generate TypeScript types by simply providing the contract name or the path to the ABI, streamlining your development process.

| Note: This only works for contracts that have generated ABI's | | --- |

Generate an ABI by following these instructions or read below

Example

Generate the types for the devhub.near contract and add them to your root

npx near2ts devhub.near

or

npx near2ts ./devhub.near_abi.json

Use the type ContractCallArgs to be able to accept arguments for any of the methods or reference the specific type for each call (in this case AddLike)

import { AddLike, ContractCallArgs } from "./contract_types";

interface AddLikeCall {
    contractId: 'devhub.near',
    methodName: 'add_like',
    args: AddLike
}

const contractCall: AddLikeCall = {
    contractId: 'devhub.near',
    methodName: 'add_like',
    args: {post_id: 20}
}

const receipt = await account.functionCall(contractCall)
interface DevHubContractCall {
    contractId: 'devhub.near',
    methodName: string,
    args: ContractCallArgs
}

const contractCall: DevHubContractCall = {
    contractId: 'devhub.near',
    methodName: 'add_member',
    args: {
        ....
    }
}

You can also install it as a dev dependency for you project


npm i near2ts --save-dev

Then add the script to your package.json and run it!

package.json

  "scripts": {
    "near2ts": "near2ts"
  },
npm run near2ts ./abi.json

Generating ABI

(taken from https://github.com/near/abi)

Rust

Ensure you have cargo-near installed

To generate an ABI for a contract within the directory containing contract's Cargo.toml

$ cargo near abi

Ensure that the project you are generating an ABI for depends on a version of near-sdk of 4.1.0 or later and has the abi feature enabled.

near-sdk = { version = "4.1.0", features = ["abi"] }

TypeScript

Ensure you have a near-sdk-js (version 0.7.0 or later) contract

To generate an ABI for a contract within the directory containing contract's package.json

$ npx near-sdk-js build --generateABI path/to/contract.ts

The ABI will be put in build/contract-abi.json

TODO

  • generate types in a way that are more compatible with near-api-js (whole function call object?)
  • dev dependency uses local version before node modules so if you have near cli js installed its using that one instead of rs, making it fail