A Semaphore Hardhat plugin to deploy verifiers and Semaphore contracts.
This Hardhat plugin provides two simple tasks that can be used to deploy verifiers and Semaphore contracts without any additional configuration. |
---|
Install the @semaphore-protocol/hardhat
package with npm:
npm i @semaphore-protocol/hardhat
or yarn:
yarn add @semaphore-protocol/hardhat
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 { address: verifierAddress } = await run("deploy:verifier", { logs, merkleTreeDepth: 20 })
const { address: semaphoreAddress } = await run("deploy:semaphore", {
logs,
verifiers: [
{
merkleTreeDepth: 20,
contractAddress: verifierAddress
}
]
})
const Greeter = await ethers.getContractFactory("Greeter")
const greeter = await Greeter.deploy(semaphoreAddress)
await greeter.deployed()
if (logs) {
console.log(`Greeter contract has been deployed to: ${greeter.address}`)
}
return greeter
})