Skip to main content

Overview

Plugins extend Dokrypt’s functionality with custom lifecycle hooks, CLI commands, and services. Plugins can be installed globally or per-project.

Plugin Types

TypeDescription
containerRuns as a Docker container alongside your services
binaryRuns as a native binary on the host machine

Installation

# Install from registry
dokrypt plugin install gas-reporter

# Install a specific version
dokrypt plugin install gas-reporter --version 1.0.0

# Install globally (available to all projects)
dokrypt plugin install gas-reporter --global
Storage locations:
  • Local: ./plugins/ (project directory)
  • Global: ~/.dokrypt/plugins/

Plugin Manifest

Every plugin has a plugin.yaml manifest:
name: gas-reporter
version: "1.0.0"
description: "Detailed gas usage reporting"
author: dokrypt
license: MIT
type: container

container:
  image: gas-reporter:latest
  ports:
    http: 3100
  environment:
    CHAIN_URL: "http://ethereum:8545"
  depends_on: [ethereum]

hooks:
  on_up: true
  on_down: true
  on_test_end: true

commands:
  - name: gas-report
    description: "Generate gas report"

Lifecycle Hooks

Plugins can subscribe to these lifecycle events:
HookTriggered WhenUse Cases
on_initDokrypt initializesSetup, configuration validation
on_updokrypt up completesStart monitoring, register listeners
on_downdokrypt down startsCleanup, save state
on_transactionA transaction executesTX logging, gas tracking
on_block_minedA new block is minedBlock monitoring, indexing
on_contract_deployedContract deployment detectedABI registration, verification
on_test_endTest suite completesReport generation, notifications

Plugin Configuration

Configure plugins in dokrypt.yaml:
plugins:
  gas-reporter:
    version: "1.0.0"
    config:
      output: "gas-report.json"
      format: "table"

Creating a Plugin

Scaffold

dokrypt plugin create my-plugin
Creates:
my-plugin
plugin.yaml
Dockerfile
README.md

Plugin Environment

Plugins receive an environment interface with:
MethodDescription
ProjectName()Current project name
ChainRPCURL(name)RPC URL for a chain
ServiceURL(name)URL for a service

Publishing

cd my-plugin
DOKRYPT_REGISTRY_TOKEN=your-token dokrypt plugin publish

Managing Plugins

# List installed plugins
dokrypt plugin list

# Search registry
dokrypt plugin search gas

# Update a plugin
dokrypt plugin update gas-reporter

# Remove a plugin
dokrypt plugin uninstall gas-reporter

Hooks Configuration (dokrypt.yaml)

In addition to plugin hooks, you can define shell command hooks directly in dokrypt.yaml:
hooks:
  pre_up: "echo 'Starting environment...'"
  post_up: "npx hardhat run scripts/deploy.js --network localhost"
  pre_down: "echo 'Stopping...'"
  post_down: "echo 'Environment stopped'"
  post_snapshot: "echo 'Snapshot saved'"
HookWhen
pre_upBefore starting services
post_upAfter all services are healthy
pre_downBefore stopping services
post_downAfter all services stopped
post_snapshotAfter a snapshot is saved