Skip to main content

Block-driven Ethereum job/transaction execution framework

Project description

brawny

Block-driven Ethereum job and transaction execution framework, inspired by eth-brownie.

Brownie-style ergonomics: brawny mirrors Brownie's developer experience with familiar patterns—accounts, Contract(), chain, history, and an interactive console. If you've used Brownie, you'll feel right at home.

Installation (Local Development)

# Clone and install the framework
git clone https://github.com/yearn/brawny.git
cd brawny
pip install -e .

Quick Start

# Create a new keeper project
mkdir my-keeper && cd my-keeper
brawny init

# Install your project (brawny is already installed from above)
pip install -e .

# Configure
cp .env.example .env
# Edit .env: set RPC_URL and BRAWNY_KEYSTORE_PASSWORD_WORKER

# Import a signer key (will prompt for password)
brawny accounts import --name worker --private-key 0xYOUR_PRIVATE_KEY

# Run
brawny start

See docs/quickstart.md for a longer walkthrough.

Project Structure

After brawny init, your project looks like:

my-keeper/
├── my_keeper/              # Your Python package
│   └── __init__.py
├── jobs/
│   ├── __init__.py
│   └── _examples.py        # Reference implementations (not registered)
├── interfaces/             # Place ABI JSON files here
├── monitoring/             # Prometheus + Grafana stack
│   ├── docker-compose.yml
│   └── grafana/...
├── pyproject.toml
├── config.yaml
├── .env.example
├── .gitignore
└── AGENTS.md               # AI agent guide for writing jobs

The AGENTS.md file contains a comprehensive guide for AI agents to generate correct, idiomatic jobs.

Minimal Job Example

Create jobs/harvester.py:

from brawny import Job, job, Contract, trigger, intent, block


@job(signer="worker")
class HarvestJob(Job):
    name = "Harvest Example"
    check_interval_blocks = 50
    vault_address = "0xYourVault"

    def check(self):
        vault = Contract(self.vault_address)
        pending = vault.pendingRewards()
        if pending > 1_000_000_000_000_000_000:
            return trigger(
                reason="Harvest pending rewards",
                data={"pending": pending},
                idempotency_parts=[block.number // 50],
            )
        return None

    def build_intent(self, trig):
        vault = Contract(self.vault_address)
        return intent(
            signer_address=self._signer_name,
            to_address=self.vault_address,
            data=vault.harvest.encode_input(),
            min_confirmations=2,
        )

    def alert_triggered(self, ctx):
        return f"Harvest triggered: {ctx.trigger.data['pending'] / 1e18:.4f}"

    def alert_confirmed(self, ctx):
        return f"Harvest confirmed: {ctx.tx.hash}"

Docs

  • docs/quickstart.md
  • docs/cli.md
  • docs/job-lifecycle.md
  • docs/alerts.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brawny-0.1.14.tar.gz (296.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brawny-0.1.14-py3-none-any.whl (359.2 kB view details)

Uploaded Python 3

File details

Details for the file brawny-0.1.14.tar.gz.

File metadata

  • Download URL: brawny-0.1.14.tar.gz
  • Upload date:
  • Size: 296.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for brawny-0.1.14.tar.gz
Algorithm Hash digest
SHA256 b91b85751ccb73d2bdf80280834a62d63721aa7020e5272a8092ccd143b4d0be
MD5 7d64568a024864146746c75e8340c6c7
BLAKE2b-256 015b2e346c71ad5e9ff2677d11e5a1e0f78acd1d0924b5038e7f4c39a59a389f

See more details on using hashes here.

File details

Details for the file brawny-0.1.14-py3-none-any.whl.

File metadata

  • Download URL: brawny-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 359.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for brawny-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 3090bbfa1d2b71c558d6b33bad6e72a6eef2e9c3b1c736d50ca2a5754e298f6b
MD5 e7fcb36ed75eb178859da172ff99a1c6
BLAKE2b-256 aa6f3be5c288d25b1e45b62e8f8cd74166f3ea93ceeb43d0d9cba581dc1184f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page