This is a topic for issues, requests and news on Starknet Hardhat Plugin.
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.
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?
New version (v0.3.3) has been released:
Changes:
- Have an Alpha Mainnet config entry the same way Alpha Testnet is present (i.e.
alphaandalphaMainnetare available without defining in your hardhat config file; it was a bit late when it was realized thatalphaMainnetis not the best choice, and future versions will havealpha-mainnetby default). - Use cairo-lang v0.6.1 by default.
- When waiting for transactions to become
PENDING, also check for theirblock_hashto become NOTpending.
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)
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
New version (v0.3.5) has been released (GitHub):
- Add
starknet-verifytask: - Add
--waitflag tostarknet-deploytask:- Allows waiting until deployment becomes at least
PENDING.
- Allows waiting until deployment becomes at least
- 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.
New version of starknet-hardhat-plugin (v0.3.6) has been released (GitHub):
- Fix interaction with
starknet-devnetwhen usingvenvon macOS. - Adapt to v0.6.2:
- when awaiting transactions, they are resolved when ACCEPTED_ON_L2)
- have both
alphaandgoerli-alphaas predefined network names for Alpha Testnet (on Goerli)
- Use
alpha-mainnetas the predefined network name of Alpha Mainnet. - Improve Readme.
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-devnetif using the Docker option.
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:
stringToBigIntbigIntToString
- Improve Readme.
- Improve deployment logging.
Interaction with pending blocks coming probably next week.
New version of starknet-hardhat-plugin (v0.3.9) has been released:
- Add
starknet-invokeandstarknet-calltasks. - 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.
- With
Interaction with pending blocks coming with the next release (after the next cairo-lang version is released).
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
--inputsoption).
New version of starknet-hardhat-plugin (v0.3.11) has been released:
- Support for Accounts/Wallets:
- configure it in your hardhat.config file: https://github.com/Shard-Labs/starknet-hardhat-plugin/#wallet
-
starknet-deploy-accounttask: https://github.com/Shard-Labs/starknet-hardhat-plugin/#starknet-deploy-account - in Mocha tests: https://github.com/Shard-Labs/starknet-hardhat-example/blob/master/test/wallet-test.ts
-
IMPORTANT: The new developer experience of using
invokeorcallin Mocha is compromised by this (three optional parameters in a row) - this will be changed in 0.4.0.
-
IMPORTANT: The new developer experience of using
- Target pending block by default when making calls.
-
cairo_pathoption used bystarknet-compileis configurable in hardhat.config. - Retry status checking if received 503 response.
- Increase status checking timeout to reduce network load.
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
starknetkey. - Stop using
cairokey:- Rename
versiontodockerizedVersion:- Because the
versionkey affected and affects only the Docker image used (if user opts for dockerized mode).
- Because the
- Rename
- Move
walletskey tostarknet. - Rename
starknetNetworktonetworkand move it frommochatostarknet:- This is because the network wasn’t just
mochaspecific but could be used in any Hardhat script.
- This is because the network wasn’t just
- Use
- Use
optionsobject inStarknetContractmethods 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 = {})
- OLD:
- Rename string utility functions to reflect their real purpose (functionality stays the same, the name changes):
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)
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).
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
Accountclass for invoking/calling contract functions through an Account. CreateAccountusing 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");
New version of starknet-hardhat-plugin (v0.4.3) has been released: GitHub
- Introduce
--starknet-networkflag tohardhat testandhardhat 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.adaptInputandStarknetContract.adaptOutput
- Use hardhat 2.9.0 as a dependency.
- Update
hardhat starknet-verifycommand:- Adapt to the new Voyager API
- Allow multi-file contracts.
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
- Now called
- Fix deploying contracts with empty constructors.
- Remove
--starknet-networkCLI option fromhardhat run:- There are issues with overriding hardhat tasks and introducing new CLI options - however
hardhat testkeeps its--starknet-networkoption - 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
networkproperty ofstarknetinhardhat.config. - Return tx hash on
StarknetContract.invoke.
- There are issues with overriding hardhat tasks and introducing new CLI options - however
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)
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-contractflag tohardhat starknet-compileto allow compiling contracts.
- Introduce
- Introduce
starknet.getTransactionandstarknet.getTransactionReceiptutility functions - Support hex strings as contract function input.
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-validationflag to thehardhat starknet-compilecommand:- Allows compiling contracts with e.g. printing in hints (useful for debugging when deploying and executing on Devnet).
- Introduced
--tokenoption to thehardhat starknet-deploy:- Allows whitelisted deployment on mainnet.