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-starknetjs

v1.0.3

Published

Hardhat plugin to integrate StarkNet.js

Downloads

3

Readme

NPM Package

hardhat-starknetjs

Hardhat plugin for integration with StarkNet.js.

What

This plugin brings to Hardhat the StarkNet library StarkNet.js, which allows you to interact with StarkNet via javascript in a simple way.

NOTE: This plugin doesn't compile your StarkNet contracts or manage artifacts, it's intended to be used in conjunction with another plugin such as hardhat-starknet-compile.

Installation

npm install --save-dev @playmint/hardhat-starknetjs starknet

And add the following to your hardhat.config.ts:

import "@playmint/hardhat-starknetjs";

Or if you're using Javascript, add this to hardhat.config.js:

require("@playmint/hardhat-starknetjs");

Config extensions

This plugin adds a field starknetArtifacts to ProjectPathsConfig which contains the path to where the plugin should look for artifacts (compiled StarkNet contracts). This defaults to artifacts-starknet.

It also adds a starknetjs object to HardhatConfig which contains networks, a mapping of network name to network config (as defined by the constructor of StarkNet.js's Provider object). The default networks populated are goerli-alpha and mainnet-alpha, you can add any additional ones you need or change the default networks as you see fit.

const config: HardhatUserConfig = {
    paths: {
        starknetArtifacts: "artifacts-starknet"
    },
    starknetjs: {
        networks: {
            "goerli-alpha": { network: "goerli-alpha" },
            "mainnet-alpha": { network: "mainnet-alpha" },
            "devnet": { baseUrl: "http://localhost:5000" }
        }
    }
};

Selecting a network

You can select the network you want by either:

  • setting the environment variable STARKNETJS_NETWORK, or
  • using the --starknetjs-network argument when running a script or test, e.g. npx hardhat run scripts/deploy.ts --starknetjs-network devnet

Environment extensions

This plugin adds an object called starknetjs to the Hardhat Runtime Environment.

NetworkId

A networkId field is added to starknetjs which is a string, and contains the key of the selected network from hre.config.starknetjs.networks.

Provider object

A provider field is added to starknetjs, which is a StarkNet.js Provider automatically connected to the selected network.

Helpers

function getContractFactory(
    contractName: string,
    providerOrAccount?: Provider | Account | undefined,
    abi?: Abi | undefined): Promise<ContractFactory>;

function getContractFactoryFromArtifact(
    artifact: CompiledContract,
    providerOrAccount?: Provider | Account | undefined,
    abi?: Abi | undefined): ContractFactory;

function getContractAt(
    contractName: string,
    address: string,
    providerOrAccount?: Provider | Account | undefined,
    abi?: Abi | undefined): Promise<Contract>;

function getContractAtFromArtifact(
    artifact: CompiledContract,
    address: string,
    providerOrAccount?: Provider | Account | undefined,
    abi?: Abi | undefined): Contract;

function getAccount(
    address: string,
    keyPairOrSigner: KeyPair | SignerInterface,
    provider?: Provider): Account;

function readArtifact(searchPath: string): Promise<CompiledContract>;

Usage

Example deploy.ts:

import hre from "hardhat";


async function main() {
    // these paths will all resolve to the same artifact
    let factory = await hre.starknetjs.getContractFactory("test");
    factory = await hre.starknetjs.getContractFactory("artifacts-starknet/test");
    factory = await hre.starknetjs.getContractFactory("test.cairo");
    factory = await hre.starknetjs.getContractFactory("test.cairo/test.json");

    const instance = await factory.deploy();

    await instance.invoke_some_func(42);

    console.log(await instance.get_some_value());
}

main().catch(err => console.error(err));