To add a new detector just follow the following steps:
-
Create a new file in the
detectors
folder and extend the baseDetector
class:// Internal. export default class ContractSenderDetector extends Detector { detect(): void { this.status = this.isInvokedByContract() ? DetectionStatus.DETECTED : DetectionStatus.NOT_DETECTED; } /** * @returns true iff the protocol was invoked by a contract address. */ isInvokedByContract(): boolean { const { trace } = this.txContext; return !this.isCallToProtocol(trace); } formatDetectionMessage(): string { // Optional. return ''; } }
-
Test your detector following the guide.
-
The
Ironblocks
team will provide you with aunique-id
for the new detector, e.g.:"ib-1-12345"
-
Add the detector to the detectors factory:
// Import your detector here import ContractSenderDetector from "./detectors/contract-sender"; export default function detectorFactory(id: string): DetectorClass { switch (id) { ... // Insert code (start) case 'ib-1-12345': return ContractSenderDetector; // Insert code (end) ... default: ... } }
-
Build and restart:
docker-compose build docker-compose up
Once we detect a transaction related to your protocol we will invoke your registered detectors.
You are all set now, we will take care of the rest :)