Skip to main content

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:
Run DeployMockTokens.s.sol in simulation mode first. It deploys two 18-decimal MockERC20 contracts and writes deployments/tokens.json with .tokenA and .tokenB:
Inspect the predicted addresses and gas estimate, then broadcast once:
After a successful broadcast, load the deployed token addresses:
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:
Broadcast only after the simulation succeeds:
Read the hook address from the manifest and verify it:
The poolManager() result should match POOL_MANAGER.

Next step

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