This is a solidity language, BEP-20 standard binance token and ERC-20 standard Ethereum Token contract, it means we can deploy these token on ethereum as well as binance network. It has mintable and burnable, with owner access permissions and pauseable module, also it is upgradeable contract.
A ProxyAdmin is a contract that acts as the owner of all your proxies. Only one per network gets deployed. When you start your project, the ProxyAdmin is owned by the deployer address, but you can transfer ownership of it by calling transferOwnership.
A proxy is a contract that delegates all of its calls to a second contract, named an implementation contract. All state and funds are held in the proxy, but the code actually executed is that of the implementation. A proxy can be upgraded by its admin to use a different implementation contract.
Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows.
Hardhat is a world-class development environment, testing framework and asset pipeline for blockchains using the Ethereum Virtual Machine (EVM), aiming to make life as a developer easier. We use hardhat in this project to compile and deploy the token contracts in specified network
Run below commands
sudo apt install git-all
Run below commands
curl -fsSL https://deb.nodesource.com/setup_lts.x |sudo -E bash -
sudo apt-get install -y nodejs
Run below commands
sudo npm install hardhat -g
- Ubuntu - 22.04.1 LTS
- Git - 2.34.1
- NodeJs - v16.18.0
- Node Package Manager(NPM) - 8.19.2
- Hardhat - 2.12.4
- Solidity - 0.8.4
- Clone Contract Repo from
https://github.com/prasanthdotv/erc20-upgradable-with-multisignature.git
- Open Terminal in the Contract project folder and run
npm install
to install the dependencies.
-
Open Terminal in the Contract project folder.
-
Run
npx hardhat compile
orhh compile
ornpm run compile
to compile the contracts -
Run
npx hardhat test
orhh test
ornpm run test
to run the Contract test cases -
Test report will be generated in both JSON and HTML formats
./mochawesome-report/MyToken-Test-Report.json
./mochawesome-report/MyToken-Test-Report.html
In order to compile and deploy the contract, there are certain values to be set in environment variable. Make a copy of .env.sample
and rename it as .env
Create a new .env
file and put :
- INFURA_KEY Infura API Key,
- ETHERSCAN_KEY if you work on ethereum and want to verify contract on ethereum network.
- BSCSCAN_KEY if you work on binance network and want to verify on binance network.
- TOKEN_NAME Name of token.
- TOKEN_SYMBOL Symbol of token.
- TOKEN_SUPPLY Total initial supply.
- TOKEN_DECIMALS Number of decimals used.
- OWNER Owner wallet address.
- TXN_LIMIT Maximum transaction amount(Anti-Bot).
- WALLET_BALANCE_LIMIT Maximum wallet balance(Anti-Bot)..
- ANTI_BOT_PROTECTION To toggle anti-bot features on and off.
- DEFENDER_TEAM_API_KEY Openzeppelin Defender Team API Key for handling admin proposals.
- DEFENDER_TEAM_API_SECRET_KEY Openzeppelin Defender Team API Key for handling admin proposals.
- MULTI_WALLET Multi Signature wallet address for ProxyAdmin ownership.
- EXISTING_ADDRESS Deployed proxy address for upgrading the contract.
Before starting this section we will understand about .openzeppelin folder. This folder contain set of json files with network names as file name with contents being the contract addresses deployed under that network. This file is one of the key file to track contract deployment and perform change/upgrade.
-
Make sure contract contract configurations are correct
-
Set the environment variables as required
-
Deploy contract with below commands
hh run scripts/deploy.js --network network_name
hh run scripts/transfer-ownership.js
where network_name = development, bsc_testnet, bsc, polygon_mainnet, live etc.
A Hardhat plugin that can be used to automatically verify your contracts through the Etherscan API. With this plugin you can verify your contracts with just a simple command:
hh verify --network network_name ContractName
-
Create a copy of contract you intend to modify. name it as easy it is to understand.
-
Write the changes in the new file we copied and also rename the class in the similar pattern based on the new file name
-
After modifying the contract, We need to propose the upgrade. For that run
hh run scripts/propose-upgrade.js
after adding the new contract name and existing proxy address
-
This will create a proposal for contract upgrade with a URL
-
The URL will direct to Openzeppelin Defender, with details of proposal.
-
Members of multi signature wallet can go there and approve or reject the upgrade.
-
Once it reaches enough approvals members can execute the upgrade.
-
For more details please visit: https://docs.openzeppelin.com/defender/guide-upgrades