Skip to main content
Hooks Trampoline is a smart contract that enables safe execution of user-specified hooks in CoW Protocol settlements. This guide covers installation, compilation, and deployment.

Prerequisites

Before installing Hooks Trampoline, ensure you have:
  • Foundry installed
  • A CoW Protocol settlement contract address for deployment

Installation

1

Clone the repository

Clone the Hooks Trampoline repository to your local machine:
git clone https://github.com/cowprotocol/hooks-trampoline.git
cd hooks-trampoline
2

Install dependencies

Install Solidity dependencies using Foundry:
forge install
This will install all required libraries as specified in the project configuration.
3

Build the contracts

Compile the smart contracts:
forge build
The contracts are compiled with the following settings (from foundry.toml):
  • Solidity version: 0.8.20
  • EVM version: shanghai
  • Optimizer: enabled with 1000000 runs
4

Run tests

Verify the installation by running the test suite:
forge test
All tests should pass before proceeding to deployment.

Deployment

Hooks Trampoline can be deployed using either Foundry’s forge script or Cannon for multi-chain deployments.

Using Forge Script

The HooksTrampoline constructor requires a single parameter: the address of the CoW Protocol settlement contract.
constructor(address settlement_)
Replace <SETTLEMENT_ADDRESS> with the actual CoW Protocol settlement contract address for your target network.

Using Cannon for Deployment

Cannon provides a more robust deployment workflow with predictable addresses and multi-chain support.
1

Install Cannon dependencies

yarn install
2

Configure deployment settings

The deployment is configured in cannonfile.toml:
cannonfile.toml
name = "cow-hooks-trampoline"
version = "1.0.0"

[var.pkg]
cowSettlementPkg = "cow-settlement:2.0.2"

[pull.cow]
source = "<%= settings.cowSettlementPkg %>"

[var.main]
salt = "0x0000000000000000000000000000000000000000000000000000000000000001"
cowSettlement = "<%= cow.Settlement.address %>"

[deploy.HooksTrampoline]
artifact = "HooksTrampoline"
create2 = true
ifExists = "continue"
salt = "<%= settings.salt %>"
args = ["<%= settings.cowSettlement %>"]
The configuration automatically pulls the settlement address from the cow-settlement package, ensuring compatibility.
3

Build the Cannon package

Generate the deployment artifact:
yarn build:cannon
This creates a deployment manifest with:
  • Compiled contract ABIs
  • Predicted deployment addresses (using CREATE2)
  • Solidity input JSON
  • Default configuration settings
4

Publish the package (optional)

To publish to Cannon’s registry:
yarn cannon:publish
Publishing requires:
  • Permissions on the cow-settlement package
  • 0.0025 ETH + gas fees on Optimism Mainnet

Deployment Verification

After deployment, verify your Hooks Trampoline contract:
cast call <TRAMPOLINE_ADDRESS> "settlement()" --rpc-url <YOUR_RPC_URL>

Network Addresses

For production deployments, refer to the cowprotocol/deployments repository or the cow-omnibus package on Cannon Explorer for official contract addresses.

Next Steps

Now that you have deployed Hooks Trampoline, learn how to use it in your CoW Protocol integrations:

Usage Guide

Learn how to create and execute hooks with Hooks Trampoline

Build docs developers (and LLMs) love