@unlock-protocol/hardhat-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

Unlock Hardhat plugin

Unlock hardhat plugin provides a set of tasks and scripts to interact directly with the Unlock Protocol

Check the example repo for a working example.

Installation

yarn install @unlock-protocol/hardhat-plugin

Import the plugin in your hardhat.config.js:

require('@unlock-protocol/hardhat-plugin')

Or if you are using TypeScript, in your hardhat.config.ts:

import '@unlock-protocol/hardhat-plugin'

Configuration (optional)

Networks

Info about already deployed Unlock contracts (on mainnet, rinkeby, optimism, bsc,xdai/gnosis, etc.) are added to the unlock param of the hardhat config. You can pass custom info about your own Unlock deployments directly in hardhat.config.js - following the NetworkConfig type in @unlock-protocol/types.

Config example

import '@unlock-protocol/hardhat-plugin'

const config: HardhatUserConfig = {
  solidity: '0.8.7',
  unlock: {
    31337: {
      name: 'Custom Localhost Name',
    },
    12345: {
      name: 'My New Network',
      unlockAddress: '0x...', // your own unlock deployment address
    },
  },
}

Usage

There are no additional steps you need to take for this plugin to work.

Install it and access ethers through the Hardhat Runtime Environment anywhere you need it (tasks, scripts, tests, etc).

import { unlock } from 'hardhat'

// deploy the Unlock contract
await unlock.deployUnlock()

// deploy the template
await unlock.deployPublicLock()

// deploy the entire protocol (localhost only)
await unlock.deployProtocol()

// create a lock
const lockArgs = {
  expirationDuration: 60 * 60 * 24 * 7, // 7 days
  currencyContractAddress: null, // null for ETH or erc20 address
  keyPrice: '100000000', // in wei
  maxNumberOfKeys: 10,
  name: 'A Demo Lock',
}
await unlock.createLock(lockArgs)

Package Sidebar

Install

npm i @unlock-protocol/hardhat-plugin

Weekly Downloads

111

Version

0.2.3

License

MIT

Unpacked Size

58.3 kB

Total Files

49

Last publish

Collaborators

  • unlock-dev
  • ops-unlock
  • clemsos
  • julien51