一键导入
writing-bots
Write a bot to continuously listen and respond to events on a public blockchain network.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Write a bot to continuously listen and respond to events on a public blockchain network.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
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.
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.
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.
Best practices for developing a Python-based project. Use when creating a new project to ensure best practices according to ApeWorX development standards.
Use this skill if a user's request is under-specified, and you need to clarify the project requirements.
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.
| name | writing-bots |
| description | Write a bot to continuously listen and respond to events on a public blockchain network. |
| compatibility | Requires uv installed |
This skill describes when and how to a bot using the Silverback SDK.
The user provides operational requirements such as which blockchain network they want it to run on, which smart contracts they want to interact with, what types of actions they want to take. They may provide additional context about technical constraints, or scenarios it must avoid.
CRITICAL: Before writing any Silverback bot code, you MUST:
web_fetch to retrieve the latest documentation from https://docs.apeworx.io/silverback/stableDO NOT rely on general knowledge about Silverback - always fetch the current documentation first to ensure accuracy.
Before writing the bot, understand the types of actions you want to perform, and which on-chain or off-chain events you might want to monitor in order to trigger them
CRITICAL: Have a good understanding of the requirements first before proceeding to write any code.
Then implement event handlers, which are callbacks implemented that trigger logic which might:
In order to have visibility into the operation of the bot, it is often useful to define key "Metrics" or signal values that you can monitor over time to understand the real-world operation of the bot. This can also be very useful for monitoring purposes, but Silverback also lets you define event triggers based on the value of the metric. For example, if you've defined a complex metric based on the amount of trading volume occuring on a particular decentralized exchange pool in the latest block, you might want to trigger an action to occur when that volume signal is above or below a certain threshold. This can create more complex, reactive behaviors beyond what basic blockchain events can tell you.
Sometimes the actions you want to take in a bot depends on the results of other actions, so it is useful to maintain some internal state to track those results. Use internal state sparingly, and try to rely as much as you can on the blockchain state, or the state of other external services you've integrated the bot with in order to make correct decisions.
Overall, bots can do potentially risky actions and may end up being a part of critical user infrastructure.
It is best to advise them on proceeding slowly and verifying the correctness of their implementation in stages,
before more drastic steps like adding a signer to submit transactions or giving it access to a critical communications channel.
You can easily do this through print debugging at first,
or build-in operational modes based on the presence of a specific environment variable such as the availability of an API key,
whether the bot.signer is configured, or based on other on-chain information like account balances.
Also, you should suggest things like adding configurable limits (using environment variables via os.environ),
emergency stop conditions (raising the silverback.CircuitBreaker exception), or others ways to effectively manage risk.
[bot-name]/
├── README.md # Overview of bot, how to run it (with `silverback`) etc.
├── pyproject.toml # Any required Ape plugins, or other Python dependencies
└── bot.py # Main bot implementation
bot.py - Main bot definition:
from ape import Contract
from silverback import SilverbackBot
bot = SilverbackBot()
# NOTE: Load any required types *after* `SilverbackBot()`
contract = Contract(os.environ.get("<ENV_VAR_NAME>"))
# NOTE: See https://docs.apeworx.io/silverback/stable/userguides/development to use `bot`
dependencies = [
"silverback~=0.7",
... # Other required dependencies, SDKs, etc.
]
Only after the user thinks that the bot seems well-written and ready for testing should you install silverback and run it.
To install silverback, run the following command with uv installed:
$ uv tool install silverback
This will make the silverback cli command available.
You can then run the bot on the ecosystem and network they want (such as "ethereum:mainnet") using:
$ silverback run --network <ecosystem>:<network>
You can make the bot shutdown manually via ctrl+C, or sending the SHUTDOWN or KILL signal to the process.
Monitor the bot's operations via it's logs and try to resolve errors until they rarely happen. Silverback can handle the occasional error, so you can't figure out exactly why something is failing, it could be okay to continue testing with.
Ask the user to monitor their bot as well via the logs, and then ask if they like how the bot is working.