The instructions below have been tested on Ubuntu 20.04.5 LTS.
The toolchain includes the following components, where the versions are the latest ones that we tested:
- npm 10.2.5
- Hardhat ^2.22.7
- Solidity 0.8.27 (via solc-js)
- Node 20.5.0
- OpenZeppelin Contracts (Node.js module) v5.0.2
- OpenZeppelin Contracts Upgradeable (Node.js module) v5.0.2
- Test: OpenZeppelin Contracts Upgradeable (submodule) v5.0.2
- Clone the repository
Clone the git repository, with the option --recurse-submodules
to fetch the submodules:
git clone git@github.com:CMTA/CMTAT.git --recurse-submodules
- Node.js version
We recommend to install the Node Version Manager nvm
to manage multiple versions of Node.js on your machine. You can then, for example, install the version 20.5.0 of Node.js with the following command: nvm install 20.5.0
The file .nvmrc at the root of the project set the Node.js version. nvm use
will automatically use this version if no version is supplied on the command line.
- node modules
To install the node modules required by CMTAT, run the following command at the root of the project:
npm install
Since the sunset of Truffle by Consensys ,Hardhat is our main development tool and replace Truffle.
To use Hardhat, the recommended way is to use the version installed as
part of the node modules, via the npx
command:
npx hardhat
Alternatively, you can install Hardhat globally:
npm install -g hardhat
See Hardhat's official documentation for more information.
Truffle is no longer supported since it has been sunset by Consensys, see Consensys Announces the Sunset of Truffle and Ganache and New Hardhat Partnership
You can get the size of the contract by running the following commands.
- Compile the contracts:
npx hardhat compile
- Run the script:
npm run-script size
The script calls the plugin hardhat-contract-sizer with Hardhat.
Tests are written in JavaScript by using web3js and run only with Hardhat as follows:
npx hardhat test
To use the global hardhat install, use instead hardhat test
.
Please see the Hardhat documentation for more information about the writing and running of Hardhat.
We use linters to ensure consistent coding style. If you contribute code, please run this following command:
For JavaScript:
npm run-script lint:js
npm run-script lint:js:fix
For Solidity:
npm run-script lint:sol
npm run-script lint:sol:fix
solc --base-path . --include-path ./node_modules/ contracts/CMTAT_STANDALONE.sol