What Are Hooks?
A hook is a transaction that executes on the destination chain after the deBridge protocol fulfills your order. You configure hooks by adding thedlnHook parameter to your order creation request.
Use Cases
You can use hooks to:- Supply bridged tokens to lending protocols (Aave, Compound)
- Stake tokens in protocols immediately after bridging
- Execute swaps on the destination chain
- Call custom smart contract functions
- Automate multi-step DeFi workflows
Hook Structure
ThedlnHook parameter follows this structure:
Parameters
The hook type. Currently supports
evm_transaction_call for EVM destination chains.The address of the smart contract to call on the destination chain.
The ABI-encoded function call data. Generate this using ethers.js
Interface.encodeFunctionData().Gas limit for the hook execution. Set to
0 to let the protocol estimate automatically.How Hooks Work
- You create a bridge order with a
dlnHookparameter - Your order gets filled by a taker on the destination chain
- The taker delivers tokens to your specified recipient
- The hook transaction executes immediately after delivery
- Your tokens interact with the target protocol automatically
The hook executes in the same transaction as the token delivery, ensuring atomicity of your cross-chain workflow.
Generating Calldata
You need to generate thecalldata parameter using the target contract’s ABI. Here’s a basic example:
Examples
Explore complete implementations:EVM to EVM Hooks
Bridge from Arbitrum to Polygon and supply to Aave
Solana to EVM Hooks
Bridge from Solana to Polygon with automatic protocol interaction
Important Considerations
Token Flow
When using hooks, the token flow is:- Tokens arrive at
dstChainTokenOutRecipient - Hook executes with the specified calldata
- Your hook logic can interact with those tokens
- Your wallet (which can authorize token movements)
- A smart contract designed to handle the hook interaction
Gas Limits
Settinggas: 0 lets deBridge estimate the gas automatically. For complex interactions, you may need to specify a higher limit explicitly.