Files
semaphore/packages/hardhat
cedoor b2a33eaf58 chore: v3.12.1
Former-commit-id: 38b2eb9e83
2023-10-11 10:48:48 -07:00
..
2023-10-11 10:48:48 -07:00
2023-09-01 12:48:43 +02:00

Semaphore Hardhat plugin

A Semaphore Hardhat plugin to deploy Semaphore contracts.

Github license NPM version Downloads Linter eslint Code style prettier

This Hardhat plugin provides two simple tasks that can be used to deploy Semaphore contracts without any additional configuration.

🛠 Install

npm or yarn

Install the @semaphore-protocol/hardhat package with npm:

npm i @semaphore-protocol/hardhat

or yarn:

yarn add @semaphore-protocol/hardhat

📜 Usage

Import the plugin in your hardhat.config.ts file:

import "@semaphore-protocol/hardhat"
import "./tasks/deploy"

const hardhatConfig: HardhatUserConfig = {
    solidity: "0.8.4"
}

export default hardhatConfig

And use its tasks to create your own deploy task and deploy your contract with a Semaphore address.

import { task, types } from "hardhat/config"

task("deploy", "Deploy a Greeter contract")
    .addOptionalParam("logs", "Print the logs", true, types.boolean)
    .setAction(async ({ logs }, { ethers, run }) => {
        const { semaphore } = await run("deploy:semaphore", {
            logs
        })

        // Or:
        // const { semaphoreVerifier } = await run("deploy:semaphore-verifier", {
        //    logs
        // })

        const Greeter = await ethers.getContractFactory("Greeter")

        const greeter = await Greeter.deploy(semaphore.address)

        await greeter.deployed()

        if (logs) {
            console.log(`Greeter contract has been deployed to: ${greeter.address}`)
        }

        return greeter
    })