Skip to main content

What are CoW Hooks?

Technical specification

Hook Store — Browse and use pre-built hooks

Hooks: Getting Started — Create your first hook step-by-step

Hook dApp - is an application that allows you to conveniently program an order to perform any action before or after a swap. In the CoW Swap interface you can find several hooks for different tasks. For example, you can claim GNO from Gnosis validators before your swap. You can also specify an arbitrary call to a smart contract before or after your swap using the “Build your own hooks” dApp. But that’s not all. You can also develop your own application that will install a hook in CoW Swap! For this purpose, there is a custom application based on iframe. In order to add a custom hook, you need to:
  • Click “add Pre/Post-Hook Action”
  • Go to “My Custom Hooks” tab
  • Paste a URL of the hook dApp
Demo
CoW Hooks are still under development! But you can test it by switching “Enable hooks” toggle ON in the Swap settings.

How to develop CoW Hook dApps

CoW Hook dApp is a web application that communicates with CoW Swap using post-messages. For your convenience there is a npm library @cowprotocol/hook-dapp-lib which provides everything necessary to get started with your hook dApp development.

Install

It provides:
  • EIP-1193 provider to interact with a user wallet
  • HookDappContext which contains environment parameters (chainId, account, etc.) and current order parameters (sell token, validTo, etc.)
And it expects calling following callbacks:
  • addHook when a hook data is ready and can be added to an order
  • editHook when hook parameters were changed (edit mode)
  • setSellToken / setBuyToken if you want to change the trade assets

Quick start

Let’s create a simple hook dApp that checks the COW token balance of the order creator.

Types specification


HookDappContext


CoWHookDappActions

Manifest

As stated at the beginning of this document, in the CoW Swap interface you can add your application as a custom application. To do this, the application must contain manifest.json file with following structure:

Advanced Hook Dapps

For more complex scenarios — such as post-hooks that need to act on received tokens (staking, bridging, depositing into DeFi protocols) — you need CoW Shed. CoW Shed is a deterministic smart account that holds tokens on behalf of the user and executes pre-signed operations during settlement.
Last modified on March 17, 2026