@c-forge/typechain-compiler

1.0.0 • Public • Published

Typechain-Compiler


Utility package for compiling smart contracts, and generating TypeScript definitions & runtime code for them.

Usage

In your project install this package:

pnpm i -D @c-forge/typechain-compiler

Now you can use it to compile smart contracts, and generate TS definitions & runtime code for them. To use typechain-compiler you need to create a config file, and pass it to the compiler.

Config file

We need to create a config file, that will contain all the information about the project, and the contracts that we want to compile. Config file should be in .json format, and should contain the following fields:

export interface Config {
  projectFiles: string[];
  lint: boolean;
  artifactsPath: string;
  typechainGeneratedPath: string;
}

Also you can override the config value via CLI arguments.

Compiler

To compile your project, and generate TS definitions & runtime code for it, run the following command:

npx @c-forge/typechain-compiler --config path/to/config.json

Also you can provide additional arguments to the compiler:

Options:
      --version            Show version number                         [boolean]
  -c, --config             Config file path
                                  [string] [default: "./config.json"]
  -r, --release            Compile with release
                                           [boolean] [required] [default: false]
      --noCompile, --nc    Compile         [boolean] [required] [default: false]
      --noTypechain, --nt  Compile typechain code
                                           [boolean] [required] [default: false]
      --toolchain          Force toolchain you want to use (nightly, stable)
                                                           [string] [default: ""]
      --files              Files to compile                            [array]
      --lint       Enable cargo contract linting                               [boolean]
      --artifactsPath      Artifacts path                             [string]
      --typechainGeneratedPath  Typechain generated path               [string]
      --contractsRoot      Contracts root path                         [string]
      --regex              Regex to filter contract names             [string]
      --verifiable        Use verifiable (docker) build              [boolean]

  -h, --help               Show help                                   [boolean]

Note about verifiable builds

  1. If you want to use verifiable builds, you need to have Docker installed on your machine. To use verifiable builds, you need to pass --verifiable flag to the compiler or set verifiable field in the config file to true. Note, that verifiable flag overrides release flag as verifiable builds are always compiled in release mode.
  2. The image's version is determined by cargo contract - should correlate with its version.

Readme

Keywords

none

Package Sidebar

Install

npm i @c-forge/typechain-compiler

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

19.2 kB

Total Files

9

Last publish

Collaborators

  • nradko
  • wookashwackomy