Agent skill

writing-plugins

Create a new Plugin for Ape Framework to integrate a specific tool or service into one of Ape's vertical(s). Use when users need specific best practices and guidance on developing a new plugin for Ape. Do not use if such a plugin already exists that is designed to work with Ape, and instead suggest that.

Stars 5
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/ApeWorX/skills/tree/main/ape/writing-plugins

SKILL.md

Overview

Create a Plugin for Ape Framework that adds new functionality to the framework.

Plugin Types

An Ape plugin can customize support in 1 or more Ape vertical(s). Those Verticals are:

  • Compiler Plugins - Support new smart contract languages
  • Provider Plugins - Connect to ecosystem network(s) using a specialized service
  • Query Plugins - Source important data queries using a specialized service or tool
  • Conversion Plugins - Support specialized conversions of Python types into ABI supported types

Additionally, if required an Ape plugin can also define some extensions to core Ape functionality:

  • Config Extensions - Custom configuration subfields specifically for the plugin
  • CLI Extensions - Add new subcommands to ape CLI, e.g. ape plugin-name ...

These extensions are usually added to help otherwise manage one of the plugin vertical(s) mentioned above.

Prerequisites

Before using this skill, verify the user has:

  • uv installed (https://docs.astral.sh/uv)
  • A link to the Tool or Service's official documentation
  • A link to Tool or Service's Github repository

Folder Structure

When creating a new plugin, use the following modified folder structure to organize the plugin in a consistent way:

ape-[plugin-name]/                  # Project and package name should be `ape-[plugin-name]`
├── ape_[plugin_name]/              # Main project Python module
│   ├── __init__.py                 # Must contain Ape plugin registration (e.g. `plugins.register(plugins.[VerticalType])`)
│   ├── __main__.py                 # Ape CLI subcommand (if applicable), top-level `click.Group` must be `cli`
│   ├── [vertical_type]s.py         # Implementation for each vertical supported in plugin (e.g. `compilers.py`, `providers.py`, etc.)
│   ├── client.py                   # Service client (if plugin is for a service)
│   └── config.py                   # Plugin configuration (if applicable)
└── tests/                          # Tests run with `ape test`
    ├── ...                         # Other test files (`conftest.py`, `integration/`, etc.)
    └── functional/                 # Add tests for plugin implementations (may use `pytest-mock` for services)
        ├── test_[vertical_type].py # Test(s) for each plugin vertical implementation
        └── ...                     # Other unit tests (`client.py`, `utils.py`, etc.)

Important Notes:

  1. pyproject.toml
  • Make sure to add a pin the plugin to the latest minor version of Ape:
toml
[project]
...
dependencies = [
    "eth-ape>=0.8,<0.9",
    ...  # Additional dependencies here
]
  • If adding a CLI extension to Ape (e.g. ape [plugin-name]), must declare an entrypoint as follows:
toml
[project.entry-points."ape_cli_subcommands"]
[plugin_name] = "ape_[plugin_name].__main__:cli"
  1. ape_[plugin_name]/__init__.py
  • Ape Plugins require an additional registration step in order to function with Ape:
python
from ape.plugins import register, PluginTypeA, ...

@register(PluginTypeA)
def plugin_types():
    # NOTE: Support lazy-loading plugin functionality only as needed
    from .plugin_type import YourPluginClass

    return [YourPluginClass]

# NOTE: Do not have any default exports unless required for other purposes

Expand your agent's capabilities with these related and highly-rated skills.

ApeWorX/skills

writing-bots

Write a bot to continuously listen and respond to events on a public blockchain network.

5 0
Explore
ApeWorX/skills

writing-sdks

Create a Python SDK using Ape Framework to simplify using a given blockchain-based protocol. Use when users need specific best practices and guidance on developing a new integration with the given protocol. Do not use if such a Python SDK already exists that is designed to work with Ape.

5 0
Explore
ApeWorX/skills

uniswap

Trade and interact with Uniswap in Python using Ape and the uniswap-sdk package.

5 0
Explore
ApeWorX/skills

protocol-design

Design and build a new smart contract protocol using Ape Framework. Use when users want to create a new set of smart contracts that work together as a protocol, including development, testing, scripting/deployment, and potentially other aspects such as distributing a Python SDK or enabling automation of the protocol (through Silverback). Guides users through the full lifecycle from design through deployment and beyond using Ape tooling.

5 0
Explore
ApeWorX/skills

new-project

Architect new Python-based blockchain projects using the Ape framework. Use when users want to start a new blockchain project and need guidance on proper project structure, architecture patterns, configuration, and foundational setup. Supports SDK development, plugin creation, bot development with Silverback, protocol development, and complex blockchain applications. Determines project type and guides users through establishing the correct architectural foundation.

5 0
Explore
ApeWorX/skills

python-packages

Best practices for developing a Python-based project. Use when creating a new project to ensure best practices according to ApeWorX development standards.

5 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results