Starknet Hardhat Plugin

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):
      • stringToBigIntshortStringToBigInt
      • bigIntToStringbigIntToShortString
    • 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

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

  • Introduced integrated-devnet:
    • experimental feature
    • run Devnet in Hardhat background without having to run it in a separate shell
    • a predefined network configurable through the hardhat.config file
    • activated by using --starknet-network integrated-devnet or specifying network: "integrated-devnet" in the hardhat.config file
  • Introduced starknet.getBlock utility function for block retrieval
  • Fixed hardhat starknet-verify:
    • adapted to to the new Voyager API
    • now logging a link to Voyager where the verified contract can be checked
  • Added deployment options to starknet.deployAccount (whitelistedness token, salt, key)
  • Improved error logging on unsuccessful contract deployment (stopped masking the actual error).
21 Likes

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

  • Account classes use OpenZeppelin v0.1.0 and Argent v0.2.1 (new versions coming soon, but better late than never)
  • Easier getting of account address (account.address)
  • In CLI commands, --signature is fixed and now accepts multiple values
  • url property made optional for hardhat network configs
  • dockerizedVersion defaults to cairo-lang 0.8.2
  • Integrated-devnet uses uses starknet-devnet v0.2.2 by default
  • Voyager has recently updated its verification API, so the starknet-verify command will not work with this and older versions of the plugin
21 Likes

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

  • Introduced timestamp manipulation functions (Devnet only):
    • starknet.devnet.setTime(1000)
    • starknet.devnet.increaseTime(500)
  • Added support for named tuples, nested tuples and type aliases as function arguments.
  • Adapted to cairo-lang/starknet 0.9.0:
    • Introduced the declare method to the StarknetFactory class:
      • const classHash = await contractFactory.declare()
  • Updated the Argent account version used (v0.2.2):
    • BREAKING CHANGES:
      • Guardian not used by default anymore (it’s set to 0).
      • Initialization with a fundedAccount required after deployment:
        • const acc = <ArgentAccount> await starknet.deployAccount("Argent")
        • await acc.initialize({ fundedAccount, maxFee })
    • Useful scripts:
  • Updated the OpenZeppelin account version used (OZ commit b27101eb8).
  • Automatically fetching -arm docker images on arm64 computers.
  • Fixed support for interaction with Devnet on WSL and mac when used with the dockerizedVersion of the plugin.
  • Adapted to the new Voyager verification API.
  • Added support for relative paths as arguments to getContractFactory.
  • integrated-devnet - docs:
    • Not marked as experimental anymore.
    • Added args property to integratedDevnet hardhat config definition to allow passing Devnet CLI arguments (e.g. --lite-mode).
19 Likes

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

  • Fixed error logging (removed duplication and improved newline display)
  • integrated-devnet changes:
    • Fixed error and exit handling
    • Using starknet-devnet v0.2.5 by default
  • Updated used OpenZeppelin account artifacts to v0.2.0
  • Supported event decoding (example):
    const txHash = await contract.invoke("increase_balance", { amount: 10 });
    const receipt = await starknet.getTransactionReceipt(txHash);
    const decodedEvents = contract.decodeEvents(receipt.events);
    // decodedEvents contains hex data array converted to a structured object
    // { name: "increase_balance_called", data: { current_balance: 0n, amount: 10n } }
  • Supported devnet-specific client utility functions:
    • hardhat.starknet.devnet.load - load a devnet instance via HTTP
    • hardhat.starknet.devnet.dump - dump a devnet instance via HTTP
    • hardhat.starknet.devnet.getPredeployedAccounts - get accounts predeployed on Devnet
17 Likes