Managing Smart Contract Artifacts
A practical guide to using the compile_smart_contracts.py script for common development tasks like full recompiles, targeted updates, and cleaning your workspace.
Prerequisites
- Maroo repository cloned locally.
- Python 3.8+ and Node.js 18+ installed.
Task 1: Full Recompile of All Contracts
When you first set up your development environment, or after pulling major changes that affect multiple contracts, you should perform a full recompile. This ensures every artifact is up-to-date.
# 1. Ensure Hardhat dependencies are installed
cd contracts
yarn install
# 2. Run the compile script
cd ../scripts/compile_smart_contracts
python3 compile_smart_contracts.py --compile Note: A full recompile can take a minute or two, as it processes every Solidity file in the repository.
Task 2: Quickly Update a Single Contract
While developing a feature, you'll often make small changes to a single interface file. Instead of a full recompile, you can use the
--add flag to update only the artifact for that specific file. This is significantly faster.# Example: You just added a new function to precompiles/okrw/IOkrw.sol
cd scripts/compile_smart_contracts
python3 compile_smart_contracts.py --add precompiles/okrw/IOkrw.sol Task 3: Cleaning the Build Environment
If you encounter strange compilation errors or suspect a caching issue, it's a good practice to clean the build environment. The
--clean command removes all generated artifacts, the aggregated source files, and the node_modules directory within the Hardhat project.cd scripts/compile_smart_contracts
python3 compile_smart_contracts.py --clean Warning: After running `--clean`, you must run `yarn install` in the `contracts/` directory again before you can compile.