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

@datavoid/hardhat-plugin

v0.2.1

Published

Hardhat plugin to deploy your smart contracts via DataVoid Compression Engine across multiple EVM chains while saving on gas fees.

Downloads

6

Readme

DataVoid Hardhat Plugin

A hardhat plugin to deploy your smart contracts via DataVoid Compression Engine across multiple Ethereum Virtual Machine (EVM) chains to save on gas fees.

Required Plugins

Supported networks

The current available networks are:

  • Local
    • hardhat
    • localhost
  • EVM-Based Test Networks
    • arbitrumSepolia
    • optimismSepolia

Installation

With npm versions >=7:

npm i --save-dev @datavoid/hardhat-plugin

With npm version 6:

npm install --save-dev @datavoid/hardhat-plugin @nomicfoundation/hardhat-ethers ethers

With yarn:

yarn add --dev @datavoid/hardhat-plugin @nomicfoundation/hardhat-ethers ethers

Import the plugin in your hardhat.config.ts:

import '@datavoid/hardhat-plugin'

Or if you are using plain JavaScript, in your hardhat.config.js:

require('@datavoid/hardhat-plugin')

Use in a deploy script

Use await hardhat.datavoid.deployContract(contractName, constructorArgs, options) in your deploy scripts to deploy a contract.

Options

All the options are optional.

  • mode: 'create' | 'create2' (default: 'create')
  • salt: a 12-byte hex-string (required for mode create2)
  • gasLimit: a gas limit (default 1_500_000)
  • value: a deploy tx value
  • provider: a custom provider
  • signer: a custom signer
  • verbose: enable internal logs

Example deploy script

import hardhat, { ethers } from 'hardhat'

async function main() {
  const currentTimestampInSeconds = Math.round(Date.now() / 1000)
  const unlockTime = currentTimestampInSeconds + 60
  const lockedAmount = ethers.parseEther('0.0001')

  const result = await hardhat.datavoid.deployContract('Lock', [unlockTime], {
    mode:     'create2',
    salt:     '0xf53ec45060bd4d7b7a93f81c',
    value:    lockedAmount,
    gasLimit: 1_200_000,
    verbose:  true,
  })
  console.log(`Deployed to ${result.address} with L1 cost ${result.l1Cost}`)

  const owner = await result.contract.owner()
  console.log('Deployed with owner:', owner)
}

main().catch((error) => {
  console.error(error)
  process.exitCode = 1
})

Use as a task

For the simpliest case when you have just one smart contract, this plugin provides the dvdeploy task, which allows you to deploy the contract via DataVoid compression engine across multiple EVM chains using a simple configuration:

npx hardhat dvdeploy

Configuration

In case you want to use the dvdeploy task, you need to add the following configuration to your hardhat.networks.ts file:

const config: HardhatUserConfig = {
  // ...
  dvdeploy: {
    contract: 'YOUR_CONTRACT_NAME_TO_BE_DEPLOYED',
    constructorArgsPath: 'PATH_TO_CONSTRUCTOR_ARGS_FILE', // optional
    mode: 'DEPLOYMENT_MODE', // 'create' | 'create2'
    salt: 'HEX_SALT', // required if mode is 'create2'
    signer: 'SIGNER_PRIVATE_KEY',
    networks: ['LIST_OF_NETWORKS'],
    rpcUrls: ['LIST_OF_RPC_URLS'],
    gasLimit: 1_500_000, // optional; default value is 1_500_000
  },
}

Or if you are plain JavaScript, in your hardhat.config.js:

module.exports = {
  // ...
  dvdeploy: {
    contract: 'YOUR_CONTRACT_NAME_TO_BE_DEPLOYED',
    constructorArgsPath: 'PATH_TO_CONSTRUCTOR_ARGS_FILE', // optional
    mode: 'DEPLOYMENT_MODE', // 'create' | 'create2'
    salt: 'HEX_SALT', // required if mode is 'create2'
    signer: 'SIGNER_PRIVATE_KEY',
    networks: ['LIST_OF_NETWORKS'],
    rpcUrls: ['LIST_OF_RPC_URLS'],
    gasLimit: 1_500_000, // optional; default value is 1_500_000
  },
}

The parameters constructorArgsPath and gasLimit are optional.

The salt parameter is a 12-byte hex-string used to create the contract address. If you have previously deployed the same contract with the identical salt and constructor arguments, the contract creation transaction will fail due to EIP-684.

Example config

import { HardhatUserConfig } from 'hardhat/config'
import '@nomicfoundation/hardhat-toolbox'
import '@datavoid/hardhat-plugin'

const config: HardhatUserConfig = {
  solidity: '0.8.24',
  dvdeploy: {
    contract: 'MyContract',
    constructorArgsPath: './constructor-args.ts',
    mode: 'create2',
    salt: '0xf53ec45060bd4d7b7a93f81c',
    signer: vars.get('PRIVATE_KEY', ''),
    networks: [
      'hardhat',
      'localhost',
      'optimismSepolia',
    ],
    rpcUrls: [
      'hardhat',
      'http://127.0.0.1:8545/',
      'https://sepolia.optimism.io/',
    ],
    gasLimit: 1_200_000,
  },
}

export default config

[!NOTE] We recommend using Hardhat configuration variables introduced in Hardhat version 2.19.0 to set the private key of your signer.

Constructor arguments

The constructor arguments file must export an array of constructor arguments:

export default [
  'arg1',
  'arg2',
  // ...
]

BigInt literals (e.g. 100_000_000_000_000_000_000n) can be used for the constructor arguments if you set target: ES2020 in your tsconfig.json file. See also here for an example.

If you are using common JavaScript:

module.exports = [
  'arg1',
  'arg2',
  // ...
]

Caveats

msg.sender

When deploying with this plugin, msg.sender will not be the deployer address in a contract constructor as you might expect, but a DataVoid Factory Contract address.

Be careful if you have code like this:

contract Lock {
  address payable public owner;

  constructor() payable {
    owner = payable(msg.sender);
  }
}