A boilerplate for getting started with Venn as a Security Provider. Use is as a starting point to build your own custom detectors on Venn Network.
-
Clone or fork this repo and install dependencies using
yarn install
(ornpm install
) -
Find the detection service under:
src/modules/detection-module/service.ts
import { DetectionResponse, DetectionRequest } from './dtos' /** * DetectionService * * Implements a `detect` method that receives an enriched view of an * EVM compatible transaction (i.e. `DetectionRequest`) * and returns a `DetectionResponse` * * API Reference: * https://github.com/ironblocks/venn-custom-detection/blob/master/docs/requests-responses.docs.md */ export class DetectionService { /** * Update this implementation code to insepct the `DetectionRequest` * based on your custom business logic */ public static detect(request: DetectionRequest): DetectionResponse { /** * For this "Hello World" style boilerplate * we're mocking detection results using * some random value */ const detectionResult = Math.random() < 0.5; /** * Wrap our response in a `DetectionResponse` object */ return new DetectionResponse({ request, detectionInfo: { detected: detectionResult, }, }); } }
-
Implement your own logic in the
detect
method -
Run
yarn dev
(ornpm run dev
) -
That's it! Your custom detector service is now ready to inspect transaction
This boilerplate is built using Express.js
, and written in TypeScript
using NodeJS
.
You can use it as-is by adding your own security logic to it, or as a reference point when using a different programming language.
Notes on the API
- Your detector will get a
DetectionRequest
, and is expected to respond with aDetectionResponse
See our API Reference for more information.
Environment Setup
Create a .env
file with:
PORT=3000
HOST=localhost
LOG_LEVEL=debug
Runing In Dev Mode
yarn # or npm install
yarn dev # or npm run dev
Manual Build
yarn build # or npm run build
yarn start # or npm run start
Using Docker
docker build -f Dockerfile . -t my-custom-detector