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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@playmint/hardhat-starknet-compile

v1.0.3

Published

Hardhat plugin for compiling starknet contracts.

Downloads

5

Readme

NPM Package

hardhat-starknet-compile

A plugin for hardhat which compiles your StarkNet contracts for you.

How it Works

When you run a script with Hardhat (e.g. npx hardhat run scripts/deploy.ts), Hardhat automatically runs the compile task which compiles any Solidity contracts which have changed since the last time compilation occurred. This plugin creates a new task called starknet-compile which does the same thing for your StarkNet contracts (compiles them, but only the ones which have changed since the last time the task was run). It also extends Hardhat's compile task so that it runs starknet-compile straight after, this means that whenever you run a script with Hardhat, both your Solidity and StarkNet contracts will be compiled.

Installation

Install with npm:

npm i --save-dev @playmint/hardhat-starknet-compile

Then import in your hardhat.config file:

import "@playmint/hardhat-starknet-compile";

How to use

  • run a script and your StarkNet contracts will be automatically compiled if necessary (e.g. npx hardhat run scripts/deploy.ts), or
  • run the compile task (npx hardhat compile), or
  • run the starknet-compile task (npx hardhat starknet-compile)

The artifacts created can be used with StarkNet.js, or with starknet-hardhat-plugin.

Only contracts which have changed (or their dependencies have) will be compiled, if you want to force a contract to recompile you can delete its .json files which will be in the Starknet artifacts directory, or delete the cairo files cache.

If you use a python venv for your starknet development environment, make sure you launch vscode from your venv.

Using with starknet-hardhat-plugin

This plugin can be used alongside starknet-hardhat-plugin, the artifacts it outputs are in a compatible layout such that starknet-hardhat-plugin will find them for contract factories etc. The only thing to know is that you should import hardhat-starknet-compile after starknet-hardhat-plugin, this is because both of these plugins define a task called starknet-compile, so if you import them in the wrong order then the version of starknet-compile that is executed will be the one from starknet-hardhat-plugin which compiles all StarkNet contracts regardless of whether they've changed or not.

Configuration

By default the plugin will look for Starknet contracts in Hardhat's sources path (by default this is contracts). You can change this in your Hardhat config by setting starknetSources in paths.

By default the plugin will save build artifacts of Starknet contracts to artifacts-starknet, you can change this in your Hardhat config by setting starknetArtifacts in paths.

When the starknet compiler is invoked, the working directory used is the root directory of the project. The plugin passes the Starknet sources path as --cairo_path, but you can add extra paths to this in your Hardhat config by adding them to cairoPath in paths.

import { HardhatUserConfig } from "hardhat/types";
import "@playmint/starknet-hardhat-compile";


const config: HardhatUserConfig = {
    paths: {
        starknetSources: "starknetContracts",
        starknetArtifacts: "artifactsDir",
        cairoPath: ["starknet-libs", "thirdparty-starknet-libs"]
    }
}

export default config;