Skip to main content

Prerequisites

Before you begin, ensure you have the following installed on your system:
  • Git - Version control system
  • A Unix-like environment - macOS, Linux, or WSL on Windows

Installation

1

Install Foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.Install Foundry using the following command:
curl -L https://foundry.paradigm.xyz | bash
After installation, run foundryup to install the latest versions of forge, cast, anvil, and chisel:
foundryup
Foundry has daily updates. Run foundryup regularly to keep forge and cast up to date.
2

Clone the Repository

Clone the Polymarket CTF Exchange repository from GitHub:
git clone https://github.com/Polymarket/ctf-exchange.git
cd ctf-exchange
3

Install Dependencies

The CTF Exchange uses Foundry’s submodule system for dependencies. Install all required dependencies:
forge install
This will install all the dependencies specified in the project, including:
  • OpenZeppelin contracts
  • Conditional Tokens Framework
  • Other necessary libraries
4

Verify Installation

Verify that everything is set up correctly by running the test suite:
forge test
You should see all tests passing. This confirms that your development environment is properly configured.

Project Structure

After installation, your project directory will have the following structure:
ctf-exchange/
├── src/
│   └── exchange/
│       ├── CTFExchange.sol          # Main exchange contract
│       ├── interfaces/              # Contract interfaces
│       ├── libraries/               # Helper libraries
│       ├── scripts/                 # Deployment scripts
│       └── test/                    # Test files
├── foundry.toml                     # Foundry configuration
├── .env.example                     # Environment variables template
└── README.md                        # Project documentation

Foundry Configuration

The project’s foundry.toml file contains important configuration settings:
[profile.default]
solc = "0.8.15"
ffi = true
gas_reports = ["*"]
out = "out"
optimizer_runs = 1000000

[profile.default.fuzz]
runs = 256

[profile.intense.fuzz]
runs = 10_000

[fmt]
line_length = 120
tab_width = 4
bracket_spacing = true
wrap_comments = true
single_line_statement_blocks = "single"

Key Configuration Details

Solidity Version

The project uses Solidity 0.8.15 for compilation

Optimizer

Runs with 1,000,000 optimizer runs for maximum gas efficiency

Fuzz Testing

Default: 256 runs, Intense profile: 10,000 runs

FFI Enabled

Foreign Function Interface is enabled for advanced testing

Managing Dependencies

Adding New Dependencies

To install a new Foundry submodule:
forge install UserName/RepoName@CommitHash

Removing Dependencies

To remove a dependency:
forge remove UserName/RepoName

Next Steps

Now that you have the development environment set up, you can proceed to:

Configuration

Set up environment variables and deployment scripts

Testing

Learn about the testing framework and patterns

Build docs developers (and LLMs) love