Skip to content
Monpediaby Unity Nodes
Monad Docsguides › uniswap v4 hooks › deploy

Deploy the hook and test tokens

From docs.monad.xyz/guides/uniswap-v4-hooks/deployUpdated Sep 18, 2026read Oct 24, 2026

Contents4 sections

On this page, you will deploy a Counter hook and two mock tokens on Monad Testnet.

Prerequisites

Complete Setup first. Run the commands from your monad-hook directory with the account, RPC, and contract addresses loaded in the same shell. The addresses come from shared-infrastructure.json in that directory. If you opened a new shell, restore the environment variables from Setup’s account configuration and address exports.

Deploy the mock tokens

Create the manifest directory if you have not already done so:

mkdir -p deployments

Run DeployMockTokens.s.sol in simulation mode first. It deploys two 18-decimal MockERC20 contracts and writes deployments/tokens.json with .tokenA and .tokenB:

FOUNDRY_PROFILE=monad_testnet forge script \
  script/monad/DeployMockTokens.s.sol:DeployMockTokens \
  --network monad --rpc-url "$MONAD_TESTNET_RPC_URL" \
  --account monad-hooks-testnet \
  --sender "$DEPLOYER"

Inspect the predicted addresses and gas estimate, then broadcast once:

FOUNDRY_PROFILE=monad_testnet forge script \
  script/monad/DeployMockTokens.s.sol:DeployMockTokens \
  --network monad --rpc-url "$MONAD_TESTNET_RPC_URL" \
  --account monad-hooks-testnet \
  --sender "$DEPLOYER" \
  --broadcast --slow

After a successful broadcast, load the deployed token addresses:

export TOKEN_A="$(jq -er .tokenA deployments/tokens.json)"
export TOKEN_B="$(jq -er .tokenB deployments/tokens.json)"

Both tokens have public mint and burn methods for testing.

Mine and deploy the hook

Counter enables four callbacks: beforeSwap, afterSwap, beforeAddLiquidity, and beforeRemoveLiquidity. Uniswap encodes these permissions in the hook address; Counter’s permission bits are 0x0ac0.

DeployHook.s.sol finds a CREATE2 salt that produces an address with those bits, then deploys the hook through the factory at 0x4e59b44847b379578588920cA78FbF26c0B4956C. It takes POOL_MANAGER as the constructor argument and writes the result to deployments/hook.json.

Simulate the deployment:

FOUNDRY_PROFILE=monad_testnet forge script \
  script/monad/DeployHook.s.sol:DeployHook \
  --network monad --rpc-url "$MONAD_TESTNET_RPC_URL" \
  --account monad-hooks-testnet \
  --sender "$DEPLOYER"

Broadcast only after the simulation succeeds:

FOUNDRY_PROFILE=monad_testnet forge script \
  script/monad/DeployHook.s.sol:DeployHook \
  --network monad --rpc-url "$MONAD_TESTNET_RPC_URL" \
  --account monad-hooks-testnet \
  --sender "$DEPLOYER" \
  --broadcast --slow

Read the hook address from the manifest and verify it:

export HOOK_ADDRESS="$(jq -er .hook deployments/hook.json)"
cast code "$HOOK_ADDRESS" --rpc-url "$MONAD_TESTNET_RPC_URL"
cast call "$HOOK_ADDRESS" "poolManager()(address)" --rpc-url "$MONAD_TESTNET_RPC_URL"

The poolManager() result should match POOL_MANAGER.

Next step

Continue to Pool lifecycle to create a pool and trigger the hook’s callbacks.