![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@atixlabs/hardhat-time-n-mine
Advanced tools
This plugin will help you manipulate time and mine blocks while testing and while using the hardhat node
to develop any type of DApp.
Hardhat plugin example.
This plugins adds some tasks to manipulate the timestamp in the future blocks if you are using hardhat node
, it will help you develop DApps that are time dependent without waiting time to actually elapse.
As well as adding said tasks it also extends the HardhatRuntimeEnvironment with the same tasks in a function format so to let you use it in a JS/TS environment(being it automated tests, or your own scripts and tasks).
To install it you just need
npm install @atixlabs/hardhat-time-n-mine hardhat
Import the plugin in your hardhat.config.js
:
require("@atixlabs/hardhat-time-n-mine");
Or if you are using TypeScript, in your hardhat.config.ts
:
import "@atixlabs/hardhat-time-n-mine";
This plugin does not require any other plugin, it just needs you to install Hardhat ^2.0.0(has been tested with 2.4.0).
This plugin adds the tasks explained in the following subsections.
Note that you MUST use the --network localhost
if you are running the node locally(or any other network with a defined url that points to your node).
Usage: hardhat [GLOBAL OPTIONS] mine [--amount <INT>]
OPTIONS:
--amount amount of blocks to be mined (default: 1)
mine: mines a single block
For global options help run: hardhat help
Usage: hardhat [GLOBAL OPTIONS] increaseTime delta
POSITIONAL ARGUMENTS:
delta difference to add to the current time tracker. Can be a number representing the seconds or a string representing the delta
increaseTime: adds the given delta. NOTICE: this counts 'real' ellapsing time and is not idempotent, we recommend you user setTimeIncrease
For global options help run: hardhat help
We are using ms to parse the delta if it is not a number, so you can use any of those formats.
Examples:
hardhat increaseTime 10
: Increases ten secondshardhat increaseTime 1d
: Increases a dayhardhat increaseTime "1 week"
: Increases a weekhardhat increaseTime 1y
: Increases a yearUsage: hardhat [GLOBAL OPTIONS] setTimeIncrease delta
POSITIONAL ARGUMENTS:
delta difference between the current timestamp and the next. Can be a number representing the seconds or a string representing the delta
setTimeIncrease: makes the next block timestamp increase the given delta with respect to the current block timestamp
For global options help run: hardhat help
We are using ms to parse the delta if it is not a number, so you can use any of those formats.
Examples:
hardhat setTimeIncrease 10
: Increases ten secondshardhat setTimeIncrease 1d
: Increases a dayhardhat setTimeIncrease "1 week"
: Increases a weekhardhat setTimeIncrease 1y
: Increases a yearUsage: hardhat [GLOBAL OPTIONS] setTimeNextBlock time
POSITIONAL ARGUMENTS:
time timestamp of the next block
setTimeNextBlock: set the timestamp of the next block(does not actually mine)
For global options help run: hardhat help
Usage: hardhat [GLOBAL OPTIONS] setTime time
POSITIONAL ARGUMENTS:
time timestamp of the next block
setTime: mines a single block with a given time, effectively setting the time of the blockchain
For global options help run: hardhat help
This plugin extends the Hardhat Runtime Environment by adding an timeAndMine
field
which is an object with five functions, namely:
mine
setTime
setTimeNextBlock
increaseTime
setTimeIncrease
Each of the previously mentioned functions behave like the previously mentioned tasks(but having all of its parameters required) and can be used within your tests/scripts.
This plugin does not need any type of extra configuration.
Once you have the plugin installed and imported in your hardhat.config.js/hardhat.config.ts, you don't have to do anything else, just use the functions in the timeAndMine
object or use the defined tasks.
Once you installed the repo, you will be able to test the tasks using
npm run test:tasks
(you will have to have a node running for that)
To test the hre methods, you will have to run:
npm run test:hreMethods
You can test all of it using
npm test
You can lint it using:
npm run lint
or
npm run lint:fix
ms
to parse time deltasFAQs
Hardhat plugin to manipulate time and mine blocks
We found that @atixlabs/hardhat-time-n-mine demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.