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

@fluentxyz/hardhat-compile-to-wasm

v0.1.0

Published

A Hardhat plugin to compile Rust contracts to WebAssembly (WASM) and generate Hardhat artifacts.

Downloads

5

Readme

hardhat-compile-to-wasm

A Hardhat plugin to compile Rust contracts to WebAssembly (WASM) and generate Hardhat artifacts.

What

This plugin simplifies the process of compiling Rust contracts to WebAssembly (WASM) and generating corresponding Hardhat artifacts, allowing seamless integration of Rust-based smart contracts in your Hardhat project. As simple as running npx hardhat compile, this plugin will compile your Solidity contracts as usual and automatically compile your Rust contracts to WASM, generating the corresponding artifacts in the Hardhat artifacts directory.

Installation

Follow these steps to install the plugin:

npm install hardhat-compile-to-wasm

Import the plugin in your hardhat.config.js:

require("hardhat-compile-to-wasm");

Or if you are using TypeScript, in your hardhat.config.ts:

import "hardhat-compile-to-wasm";

Required plugins

This plugin requires the following Hardhat plugins:

Tasks

This plugin adds the compile-to-wasm subtask and extends the compile task to include Rust contracts compilation:

  • compile-to-wasm: Compiles the Rust contracts to WebAssembly and generates Hardhat artifacts.

To see the help run: npx hardhat help compile-to-wasm;

Environment extensions

This plugin does not extend the Hardhat Runtime Environment.

Configuration

This plugin extends the HardhatUserConfig with an optional compileToWasmConfig field, which is an array of objects, each representing a contract compile configuration.

Each configuration object should have the following fields:

  • contractDir: The relative path to the Rust contract directory from the project root. For example, "contracts/my_contract". Keep in mind that the Rust contract directory should contain a Cargo.toml file. And contract name should be the same as the rust package name in the Cargo.toml file.
  • interfacePath: The relative path to the Solidity interface that corresponds to the Rust contract. For example, "contracts/IMyContract.sol".

Here is an example of how to set it:

import { HardhatUserConfig } from "hardhat/config";
import "hardhat-compile-to-wasm";

const config: HardhatUserConfig = {
  compileToWasmConfig: [
    {
      contractDir: "./contracts/rust/contract",
      interfacePath: "./contracts/IRustContract.sol",
    },
  ],
};

export default config;

Usage

To use this plugin, simply run the compile task, and it will automatically compile your Rust contracts to WASM and generate the corresponding artifacts:

npx hardhat compile

The plugin will look for the compileToWasmConfig field in your hardhat.config.js or hardhat.config.ts and compile the specified Rust contracts, generating artifacts in the Hardhat artifacts directory.

Example Usage

Here is an example of a hardhat.config.ts that includes the plugin configuration:

import { HardhatUserConfig } from "hardhat/types";
import "hardhat-compile-to-wasm";

const config: HardhatUserConfig = {
  solidity: "0.8.4",
  compileToWasmConfig: [
    {
      contractDir: "contracts/my_contract",
      interfacePath: "contracts/IMyContract.sol"
    }
  ]
};

export default config;

This configuration will ensure that your Rust contracts are compiled to WASM and the corresponding artifacts are generated whenever you run npx hardhat compile.