Nitewatch is a package used by NeoDAX to interact with an EVM on-chain custody contract through the ICustody interface. It provides the security policy engine and the infrastructure to manage deposits and withdrawals.
NeoDAX utilizes the Nitewatch package to run two primary processes:
- Event Daemon: Produces
ICustodyevents by listening to the blockchain and pushing them to an internal Message Queue (MQ). - Contract Interface: An implementation to call smart-contract methods (e.g., starting or finalizing withdrawals).
- Smart Contracts: Solidity (Forge)
- Backend: Go
- Blockchain: EVM-compatible chains
- User deposits native ETH or ERC20 tokens into the custody contract via a frontend dApp.
- The Event Daemon detects the on-chain event.
- An internal event is fired to the NeoDAX MQ.
- NeoDAX credits the user's balance.
Withdrawals are governed by a security policy engine that tracks per-user and global limits (hourly/daily).
- User requests a withdrawal via the NeoDAX Web API.
- NeoDAX validates the request internally and locks the user's balance.
- NeoDAX uses the Nitewatch package to call
startWithdrawon the custody contract. - The Nitewatch Daemon listens for the
WithdrawStartedevent, applies the security policy, and then either callsfinalizeWithdraworrejectWithdraw. - The Event Daemon waits for the outcome (
WithdrawFinalizedorWithdrawRejected), fires an internal event, and NeoDAX debits the balance upon successful confirmation.
sequenceDiagram
actor User
participant NeoDAX as NeoDAX (API & MQ)
participant NWPkg as Nitewatch Package
participant Contract as Custody Contract
participant NWDaemon as Nitewatch Daemon
Note over User, NeoDAX: Request
User->>NeoDAX: Request withdrawal
NeoDAX->>NeoDAX: Validate & Lock balance
Note over NWPkg, Contract: Initiation
NeoDAX->>NWPkg: startWithdraw()
NWPkg->>Contract: on-chain call
Contract-->>NWDaemon: WithdrawStarted event
Note over NWDaemon, Contract: Security Policy & Finalization
NWDaemon->>NWDaemon: Apply Security Policy
NWDaemon->>Contract: finalizeWithdraw() or rejectWithdraw()
Note over NWPkg, NeoDAX: Confirmation
Contract-->>NWPkg: WithdrawFinalized/Rejected event
NWPkg->>NeoDAX: Fire internal MQ event
NeoDAX->>NeoDAX: Debit balance (if finalized)