Building the Project
The CoW Protocol contracts project uses a hybrid build system compiling both Solidity smart contracts and TypeScript bindings.
Prerequisites
- Node.js v16 or higher
- Yarn package manager
- Git
Installation
git clone https://github.com/cowprotocol/contracts.git
cd contracts
yarn install
Build Commands
Full Build
Compiles Solidity contracts and generates TypeScript bindings:
Solidity Only
Runs Hardhat compiler with force flag:
TypeScript Only
Compiles in ESM, CommonJS, and default formats:
Compiler Settings
The project is configured for gas-efficient contract execution:
| Setting | Value |
|---|
| Optimizer | Enabled |
| Optimizer Runs | 1,000,000 |
| EVM Version | Cancun |
This prioritizes minimal execution costs over deployment expenses.
Output Structure
Successful builds generate:
| Directory | Contents |
|---|
out/ | Compiled Solidity contracts and artifacts |
lib/esm/ | TypeScript ESM modules |
lib/commonjs/ | TypeScript CommonJS modules |
Solidity
# Lint
yarn lint:sol
# Format
yarn fmt:sol
TypeScript
# Lint
yarn lint:ts
# Format
yarn fmt:ts
Troubleshooting
If you encounter build issues:
-
Clear build artifacts:
-
Reinstall dependencies:
rm -rf node_modules
yarn install
-
Force rebuild:
yarn build:sol --force
yarn build:ts
Last modified on March 4, 2026