This directory is part of the Xahau Hooks 101 educational series. It contains concise, beginner-friendly smart contract (Hook) examples written in C for the Xahau blockchain. These hooks demonstrate native XAH payment operations, including acceptance, rejection, and logging scenarios. All examples are compiled to WebAssembly (WASM) using the Xahau Hooks Builder and are suitable for Testnet or Mainnet deployment.
See the parent Xahau-Hooks-101 for more details.
Hooks in this collection demonstrate:
- Accepting or rejecting native XAH payments based on amount, type, or other criteria
- Subdirectories for incoming/outgoing and accept/reject patterns
- Use of the Hook API for transaction inspection and control
- No persistent state or parameterization; logic is hardcoded in each hook
- Triggers:
ttPAYMENT(Payment transactions)- Only payment triggers are required for these hooks
| Directory | Description |
|---|---|
| Accept_Incoming_Payment/ | Hooks that accept incoming XAH payments based on various criteria (amount thresholds, exact matches, multiples) |
| Accept_Outgoing_Payment/ | Hooks that accept outgoing XAH payments based on various criteria (amount thresholds, exact matches, multiples) |
| Reject_Incoming_Payment/ | Hooks that reject incoming XAH payments based on various criteria (amount thresholds, exact matches, multiples) |
| Reject_Outgoing_Payment/ | Hooks that reject outgoing XAH payments based on various criteria (amount thresholds, exact matches, multiples) |
For detailed explanations, see the README.md in each subdirectory and comments in each .c file.
- Hardcoded logic for payment validation (no install/invoke parameters)
- Accept or reject based on payment amount, type, or direction
- XAH amounts are handled in drops (no XFL conversion needed)
- Use of Hook API for transaction inspection
- Xahau Hooks Builder: Develop, compile, deploy, and test hooks
- Deploy: Deploy and configure hooks on Testnet accounts
- Test: Create accounts, fund them, and perform transactions
- XRPLWin Hook Management: Explore hook executions and manage deployments
- Xahau Explorer: Verify transactions and hook details
- Hex visualizer and Hooks.Services: For hex conversion and debugging
-
Set Up Testnet Account(s) in Hooks Builder
- Create funded accounts in the “Deploy” section: https://builder.xahau.network/deploy
- Or in the “Test” section: https://builder.xahau.network/test
-
Prepare the Code
- Go to the “Developer” section: https://builder.xahau.network/develop
- Copy the desired
.chook code into the Xahau Hooks Builder starter template (delete the template content)
-
Compile
- Click “Compile to WASM”
-
Deploy and Set Triggers
- Go to the “Deploy” section and deploy the hook to an account by clicking “Set Hook”
- Important: Configure hook triggers for
ttPAYMENT. If you don’t set this, the hook will NOT be triggered!
-
Test Transactions
- Use the “Test” section in Hooks Builder (or XRPLWin tools) to perform transactions and test hook behavior
-
Verify
- Check results in Hooks Builder logs (TRACESTR/TRACEHEX Debug Stream) and/or in Xahau Explorer
- Use TRACESTR and TRACEHEX for execution tracing
- Check transaction logs and explorer for results
- Common pitfalls:
- Parameter length/type mismatches (should not occur, as logic is hardcoded)
- Missing triggers (hook not firing)
- Invalid or missing state access (should not occur)
- Not removing debug traces before production
- Each hook has a clear entry point, account validation, and payment amount/type validation
- Accept or rollback based on conditions
- Use safe state handling (if any) and clear rollback messages
- Remove debug traces before production deployment
- Requires
hookapi.hand standard C libraries
This is an open educational resource. Contributions and improvements are welcome!
See the root project LICENSE file for details.