Starknet Hardhat Plugin

This is a topic for issues, requests and news on Starknet Hardhat Plugin.

76 Likes

Hello Fabijan and welcome!
The repo for the Starknet Hardhat plugin is here GitHub - Shard-Labs/starknet-hardhat-plugin: A plugin for integrating Starknet tools into Hardhat projects
An example can be found here GitHub - Shard-Labs/starknet-hardhat-example: Examples of how Starknet Hardhat plugin can be used.

48 Likes

For developers using this plugin on Windows, have you been getting weird logs lately (might be docker related)? Or maybe getting assert failure when running the test task?

42 Likes

New version (v0.3.3) has been released:

Changes:

  • Have an Alpha Mainnet config entry the same way Alpha Testnet is present (i.e. alpha and alphaMainnet are available without defining in your hardhat config file; it was a bit late when it was realized that alphaMainnet is not the best choice, and future versions will have alpha-mainnet by default).
  • Use cairo-lang v0.6.1 by default.
  • When waiting for transactions to become PENDING, also check for their block_hash to become NOT pending.

Feature requests on hold, but hopefully one of them will be supported in the next version:

  • usage of an existing venv instead of necessarily running a docker container
  • verification task (voyager)
35 Likes

New version (v0.3.4) has been released:

Changes:

  • Allow user to use existing or active Python environment (avoids using Docker).
  • Improve error reporting on non-existence of artifacts directory.

Example 1 (hardhat.config.ts):

module.exports = {
  cairo: {
    // if created with python -m venv path/to/my-venv
    venv: "path/to/my-venv"
  }
}

Example 2 (hardhat.config.ts):

module.exports = {
  cairo: {
    // use the already activated env
    venv: "active"
  }
}

admin: refresh syntax highlighting

26 Likes

New version (v0.3.5) has been released (GitHub):

  • Add starknet-verify task:
    • Enables verifying contracts on Voyager through CLI instead of just through UI
    • Suggested by @maciejka.
  • Add --wait flag to starknet-deploy task:
    • Allows waiting until deployment becomes at least PENDING.
  • Handle error arising on using Python virtual environment without cairo-lang.
  • Improve getContractFactory (the function that creates a contract factory from the provided contract):
    • Handle ambiguous input.
    • Allow specifying the contract by the path of its source.
26 Likes

New version of starknet-hardhat-plugin (v0.3.6) has been released (GitHub):

  • Fix interaction with starknet-devnet when using venv on macOS.
  • Adapt to v0.6.2:
    • when awaiting transactions, they are resolved when ACCEPTED_ON_L2)
    • have both alpha and goerli-alpha as predefined network names for Alpha Testnet (on Goerli)
  • Use alpha-mainnet as the predefined network name of Alpha Mainnet.
  • Improve Readme.
28 Likes

Yesterday’s version of starknet-hardhat-plugin (v0.3.6) contains an issue, so this is a new version (v0.3.7) that fixes it:

  • Fix interaction with starknet-devnet if using the Docker option.
23 Likes

New version of starknet-hardhat-plugin (v0.3.8) has been released (GitHub):

  • Add utility functions for converting short string literals to BigInt and vice versa:
    • stringToBigInt
    • bigIntToString
  • Improve Readme.
  • Improve deployment logging.

Interaction with pending blocks coming probably next week.

25 Likes

New version of starknet-hardhat-plugin (v0.3.9) has been released:

  • Add starknet-invoke and starknet-call tasks.
  • Improved error logging:
    • If invalid number of arguments or keys passed to Starknet functions.
    • Log available networks.
  • Improve Readme.
  • Support specifying salt when deploying contracts:
    • With npx hardhat starknet-deploy.
    • With ContractFactory.deploy.

Interaction with pending blocks coming with the next release (after the next cairo-lang version is released).

25 Likes

New version of starknet-hardhat-plugin (v0.3.10) has been released:

  • Use cairo-lang v0.7.0 as the default Docker image (if using the Docker mode).
  • Support arrays of structs in function input/output.
  • Fix parsing negative BigInt.
  • Improve error message on invalid CLI input to deploy/invoke/call (the --inputs option).
27 Likes

New version of starknet-hardhat-plugin (v0.3.11) has been released:

23 Likes

New major version of starknet-hardhat-plugin (v0.4.0) has been released:

  • Expand tilde (~) to homedir in venv path.
  • Add Docker issue fix to Readme.
  • BREAKING changes:
    • Rename string utility functions to reflect their real purpose (functionality stays the same, the name changes):
      • stringToBigInt → shortStringToBigInt
      • bigIntToString → bigIntToShortString
    • Change the expected config file structure (check here for an example):
      • Use starknet key.
      • Stop using cairo key:
        • Rename version to dockerizedVersion:
          • Because the version key affected and affects only the Docker image used (if user opts for dockerized mode).
      • Move wallets key to starknet.
      • Rename starknetNetwork to network and move it from mocha to starknet:
        • This is because the network wasn’t just mocha specific but could be used in any Hardhat script.
    • Use options object in StarknetContract methods instead of using optional function arguments; e.g.:
      • OLD: StarknetContract.call(functionName: string, args?: StringMap, signature?: Array<Numeric>, wallet?: Wallet, blockNumber?: string)
      • NEW: StarknetContract.call(functionName: string, args?: StringMap, options: CallOptions = {})

Upcoming changes (with v0.4.1 or later):

  • Account class that allows executing invokes/calls as a Starknet account instead of having to provide the Account/Wallet as an invoke/call option.
  • Utility functions to handle devnet-specific calls (for Postman, i.e. L1-L2 communication)
25 Likes

New version of starknet-hardhat-plugin (v0.4.1) has been released:

  • Use cairo-lang 0.7.1 by default.
  • Make hardhat a peerDependency (and devDependency).
23 Likes

New starknet-hardhat-plugin version (v0.4.2) has been released: Github

  • Introduce utility functions for handling L1-L2 communication (postman message exchange with Devnet):

    • starknet.devnet.loadL1MessagingContract - for loading an L1 contract that exchanges messages between L1 and L2
    • starknet.devnet.flush - for propagating messages to the other layer
    • Basic example
    • Complex example
  • Introduce an Account class for invoking/calling contract functions through an Account. Create Account using utility functions:

    • starknet.deployAccountFromABI - for new Account deployment
    • starknet.getAccountFromAddress - for loading a predeployed Account
    • Basic example
    • Complex example

L1-L2 communication:

await starknet.devnet.loadL1MessagingContract(...);
const l1contract = ...;
const l2contract = ...;

await l1contract.send(...); // depending on your L1 contract interaction library
await starknet.devnet.flush();

await l2contract.invoke(...);
await starknet.devnet.flush();

Account interaction:

const contractFactory = await starknet.getContractFactory("MyContract");
const contract = await contractFactory.deploy()
const account = await starknet.deployAccountFromABI("Account", "OpenZeppelin");
await account.invoke(contract, "increase_balance", { amount: 10 });
const { res } = account.call(contract, "get_balance");
22 Likes

New version of starknet-hardhat-plugin (v0.4.3) has been released: GitHub

  • Introduce --starknet-network flag to hardhat test and hardhat run
  • Properly adapt input before passing to account:
    • Fixes BigNumber, Array, Struct, Tuple support (for the case of interacting through an account)
    • Also exposes StarknetContract.adaptInput and StarknetContract.adaptOutput
  • Use hardhat 2.9.0 as a dependency.
  • Update hardhat starknet-verify command:
    • Adapt to the new Voyager API
    • Allow multi-file contracts.
23 Likes

New starknet-hardhat-plugin (v0.5.0) has been released (BREAKING CHANGES) - tagging users who reported problems:

  • Change deployAccountFromABI (breaking):
    • Now called deployAccount
    • First parameter (specifying file name) not needed anymore:
      • Fetching of Account files done automatically - fetches the latest account version compatible with plugin
  • Fix deploying contracts with empty constructors.
  • Remove --starknet-network CLI option from hardhat run:
    • There are issues with overriding hardhat tasks and introducing new CLI options - however hardhat test keeps its --starknet-network option
    • One might argue that this is a breaking change, but this feature was never available at all because v0.4.3 made deploying in hardhat scripts impossible - this is now fixed.
    • Specifying the network can still be done through the network property of starknet in hardhat.config.
    • Return tx hash on StarknetContract.invoke.
22 Likes

Hotfix of v0.5.0 of starknet-hardhat-plugin has been released (v0.5.1):

  • Fix account resource handling; resolves errors of the type Error: ENOENT: no such file or directory, scandir '.../starknet-artifacts/account-contract-artifacts'
  • Account.invoke also returns txHash (previously didn’t)
21 Likes

New version of starknet-hardhat-plugin (v0.5.2) has been released:

  • Introduce Argent account implementation.
  • Use updated OpenZeppelin and Argent accounts that support multicall/multiinvoke - docs.
  • Adapt to cairo-lang 0.8.0:
    • Introduce contract.estimateFee - example.
    • Allow specifying maxFee and nonce in contract interaction.
    • Introduce hardhat starknet-estimate-fee.
    • Introduce --account-contract flag to hardhat starknet-compile to allow compiling contracts.
  • Introduce starknet.getTransaction and starknet.getTransactionReceipt utility functions
  • Support hex strings as contract function input.
21 Likes

New version of starknet-hardhat-plugin (v0.5.3) has been released:

  • Adapted to cairo-lang v0.8.1:
    • If using the dockerizedVersion, you might notice improvement because the underlying docker image has been optimized since v0.8.1.
  • Introduced --disable-hint-validation flag to the hardhat starknet-compile command:
    • Allows compiling contracts with e.g. printing in hints (useful for debugging when deploying and executing on Devnet).
  • Introduced --token option to the hardhat starknet-deploy:
    • Allows whitelisted deployment on mainnet.
21 Likes