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

@fuel-ts/abi-typegen

v0.103.0

Published

Generates Typescript definitions from Sway ABI Json files

Readme

@fuel-ts/abi-typegen

Generate TypeScript bindings for Sway smart contracts.

See the full ABI-spec here.

Table of contents

Documentation

See Fuels-ts Documentation

Installation

pnpm add @fuel-ts/abi-typegen
# or
npm add @fuel-ts/abi-typegen

Help

$ fuels-typegen -h

Generate Typescript from Sway ABI JSON files

Usage: fuels-typegen [options]

Options:
  -V, --version                output the version number
  -i, --inputs <path|glob...>  Input paths/globals to your ABI JSON files
  -o, --output <dir>           Directory path for generated files
  -c, --contract               Generate types for Contracts [default]
  -s, --script                 Generate types for Scripts
  -p, --predicate              Generate types for Predicates
  -S, --silent                 Omit output messages
  -h, --help                   display help for command

Generating types

When using the package in a standalone fashion, its bin is prefixed with fuels-.

npx fuels-typegen -i ./out/debug/*-abi.json -o ./src/contracts

Programmatic API

import { ProgramTypeEnum, runTypegen } from "@fuel-ts/abi-typegen";

  const cwd = process.cwd();
  const input = './abis/**-abi.json'
  const output = './types'
  const filepaths = [ './abis/a-abi.json', './abis/b-abi.json' ]
  const programType = ProgramTypeEnum.CONTRACT;

  // using input global
  await runTypegen({ cwd, input, output, programType });

  // using filepaths' array
  await runTypegen({ cwd, filepaths, output, programType });
}

Full SDK Installation

Alternatively, we recommend you install the complete SDK using the umbrella package:

pnpm add fuels
# or
npm add fuels

Note that in this example we will interact with the fuels bin directly.

We just need to call it with the typegen command, and the rest feels the same.

npx fuels typegen -i ./out/debug/*-abi.json -o ./src/contracts

Type's Conversion Table

The table below describes how Sway types are converted from/to Typescript.

| Sway | Example | TS:input | TS:output | | ------------------: | :----------------------------- | :---------------------------------: | :---------------------------------: | | u8 | 255 | BigNumberish | number | | u16 | 65535 | BigNumberish | number | | u32 | 4294967295 | BigNumberish | number | | u64 | 0xFFFFFFFFFFFFFFFF | BigNumberish | BN | | str | anything | string | string | | bool | true | boolean | boolean | | b256 | 0x000... | string | string | | b512 | fuel1a7r... | string | string | | tuples | (MyType, MyType) | [MyType, MyType] | [MyType, MyType] | | enums | enum MyEnum { y: (), n: () } | MyEnum = Enum<{ y: [], n: [] }> | MyEnum = Enum<{ y: [], n: [] }> | | structs | MyStruct { a: u8, b: u16 } | MyStruct | MyStruct | | vectors | Vec<MyType> | MyType[] | MyType[] | | options | Option<MyType> | Option<MyType> | Option<MyType> | | raw untyped ptr | 123 | BigNumberish | BN |

For more info on Sway types, click here

Contributing

In order to contribute to @fuel-ts/abi-typegen, please see the main fuels-ts monorepo.

Changelog

The @fuel-ts/abi-typegen changelog can be found at CHANGELOG.

License

The primary license for @fuel-ts/abi-typegen is Apache 2.0, see LICENSE.