Skip to content

A boilerplate template for building custom detection solutions on top of Venn Network

License

Notifications You must be signed in to change notification settings

ironblocks/venn-custom-detection

Repository files navigation

TypeScript NodeJS Express.js Jest Docker ESLint Yarn

Venn Custom Detector boilerplate

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.

📚 What is Venn?

Table of Contents

✨ Quick start

  1. Clone or fork this repo and install dependencies using yarn install (or npm install)

  2. 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,
                },
            });
        }
    }
  3. Implement your own logic in the detect method

  4. Run yarn dev (or npm run dev)

  5. That's it! Your custom detector service is now ready to inspect transaction

📦 What's inside?

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

  1. Your detector will get a DetectionRequest, and is expected to respond with a DetectionResponse

See our API Reference for more information.

🛠️ Local Development

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

🚀 Deploy To Production

Manual Build

yarn build      # or npm run build
yarn start      # or npm run start

Using Docker

docker build -f Dockerfile . -t my-custom-detector

About

A boilerplate template for building custom detection solutions on top of Venn Network

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •