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

deployment-tool

v0.1.6

Published

Tool to deploy and upgrade contracts on Ethereum Mainnet

Downloads

118

Readme

license npm version

deployment-tool


    888                888                                             888        888                   888 
    888                888                                             888        888                   888 
    888                888                                             888        888                   888 
.d88888 .d88b. 88888b. 888 .d88b. 888  88888888b.d88b.  .d88b. 88888b. 888888     888888 .d88b.  .d88b. 888 
d88" 888d8P  Y8b888 "88b888d88""88b888  888888 "888 "88bd8P  Y8b888 "88b888        888   d88""88bd88""88b888 
888  88888888888888  888888888  888888  888888  888  88888888888888  888888  888888888   888  888888  888888 
Y88b 888Y8b.    888 d88P888Y88..88PY88b 888888  888  888Y8b.    888  888Y88b.      Y88b. Y88..88PY88..88P888 
"Y88888 "Y8888 88888P" 888 "Y88P"  "Y88888888  888  888 "Y8888 888  888 "Y888      "Y888 "Y88P"  "Y88P" 888 
               888                     888                                                                  
               888                Y8b d88P                                                                  
               888                 "Y88P"                                                                   

This Hardhat plugin add 4 tasks and 3 functions to deploy and upgrade smart contracts.

Step include :

  • Compile your contracts
  • Verify storage layout, deploy a proxy admin if non existent, deploy implementation contract if non existent
  • Get last commit id (8 first characters)
  • Deploy a Transparent Upgradeable Proxy OR Upgrade Proxy using implementation contract
  • Save address of the Proxy, Proxy Admin address and initialize arguments
  • Verify contract on etherscan.io (if selected)
  • Commit new storage layout file and address file with Contract Name and CommitId in commit msg
  • Git Pull & Push

How to install this package

1. Install this package

With NPM

npm install deployment-tool

Or with Yarn

yarn add deployment-tool

2. Import/Require this package in your hardhat.config.js/.ts

Inside inside hardhat.config.js

require("deployment-tool");

or inside hardhat.config.ts (Typescript)

import 'deployment-tool'

Directories

Other option

git clone https://github.com/marc-aurele-besner/deployment-tool

cd deployment-tool

npm install

npm run build

npm link

in the hardhat project, you want to use this plugin

npm link deployment-tool

Tasks

npx hardhat deployment
npx hardhat deploy-contract
npx hardhat upgrade-contract
npx hardhat deploy-contract-static
npx hardhat test-deploy-then-upgrade-contract

Task: deploy-contract

Usage: hardhat [GLOBAL OPTIONS] deploy-contract [--contract-name ] [--extra ] [--initialize-arguments ] [--initialize-signature ] [--skip-git ] [--tag ] [--verify-contract ]

OPTIONS:

  • --contract-name The name of the contract to deploy (default: "")
  • --extra Extra data to save with this deployment (default: "")
  • --initialize-arguments The initialize() argument (default: "")
  • --initialize-signature Function signature of the initialize function (default: "")
  • --skip-git Skit git commit, pull & push (default: "false")
  • --tag Add a extra tag to this version of the contract (default: "")
  • --verify-contract Validate the contract on Etherscan.io (default: "false")

deploy-contract: Deploy a proxy contract, initialize it, save the address, commit, pull and push

Task: upgrade-contract

Usage: hardhat [GLOBAL OPTIONS] upgrade-contract [--contract-name ] [--extra ] [--skip-git ] [--tag ] [--verify-contract ]

OPTIONS:

  • --contract-name The name of the contract to deploy (default: "")
  • --extra Extra data to save with this deployment (default: "")
  • --skip-git Skit git commit, pull & push (default: "false")
  • --tag Add a extra tag to this version of the contract (default: "")
  • --verify-contract Validate the contract on Etherscan.io (default: "false")

upgrade-contract: Upgrade a proxy contract, save the address, commit, pull and push

Task: deploy-contract-static

Usage: hardhat [GLOBAL OPTIONS] deploy-contract-static [--contract-name ] [--extra ] [--constructor-arguments ] [--skip-git ] [--tag ] [--verify-contract ]

OPTIONS:

  • --contract-name The name of the contract to deploy (default: "")
  • --extra Extra data to save with this deployment (default: "")
  • --constructor-arguments The constructor() argument (default: "")
  • --skip-git Skit git commit, pull & push (default: "false")
  • --tag Add a extra tag to this version of the contract (default: "")
  • --verify-contract Validate the contract on Etherscan.io (default: "false")

deploy-contract-static: Deploy a static contract, save the address, commit, pull and push

Task: test-deploy-then-upgrade-contract

Usage: hardhat [GLOBAL OPTIONS] test-deploy-then-upgrade-contract [--contract-name ] [--extra ] [--initialize-arguments ] [--initialize-signature ] [--skip-git ] [--tag ] [--verify-contract ]

OPTIONS:

  • --contract-name The name of the contract to deploy (default: "")
  • --extra Extra data to save with this deployment (default: "")
  • --initialize-arguments The initialize() argument (default: "")
  • --initialize-signature Function signature of the initialize function (default: "")
  • --skip-git Skit git commit, pull & push (default: "false")
  • --tag Add a extra tag to this version of the contract (default: "")
  • --verify-contract Validate the contract on Etherscan.io (default: "false")

test-deploy-then-upgrade-contract: Upgrade a proxy contract, save the address, commit, pull and push

Functions

Function allow you to use the deployment OR upgrade script in scripts or tests files, they all return a instance of the contract that you can use.

    const { contractDeployment } = require('hardhat');

    contractDeployment.deployContract(
        contractName: string,
        initializeArguments: any[] = [],
        initializeSignature: string = 'initialize',
        tag?: string,
        extra?: any,
        skipGit?: boolean,
        verifyContract?: boolean
    )
    contractDeployment.upgradeContract(
        contractName: string,
        tag?: string,
        extra?: any,
        skipGit?: boolean,
        verifyContract?: boolean
    )
    contractDeployment.testDeployThenUpgradeContract(
        contractName: string,
        initializeArguments: any[] = [],
        initializeSignature: string = 'initialize',
        tag?: string,
        extra?: any,
        skipGit?: boolean,
        verifyContract?: boolean
    )

Directory Tree

deployment-tool/
│   .eslintrc.js
│   .npmignore
│   .prettierignore
│   .prettierrc
│   CONTRIBUTING.md
│   LICENSE
│   README.md
│   README3.md
│   awesome-readme.config.js
│   package-lock.json
│   package.json
│   tsconfig.json
│   tsconfig.prod.json
│   tslint.json
└─── src/
   │   ContractDeployment.ts
   │   README.md
   │   deploy.ts
   │   deployProxy.ts
   │   index.ts
   │   serveTasks.ts
   │   type-extensions.ts
   │   upgradeProxy.ts
   │   utils.ts

Dependencies

This package/plugin use other hardhat plugins that you can then reuse, for example https://www.npmjs.com/package/hardhat-awesome-cli is used to save the contract address and initialization details, this can be access with a function like

const { addressBook } = require('hardhat');
addressBook.retrieveContractObject(contractName: string, deployedNetwork: string)