Skip to content

feat: Agent Logic Contract Examples with IAgentLogic Interface#30

Open
saiboyizhan wants to merge 1 commit intoChatAndBuild:mainfrom
saiboyizhan:feat/agent-logic-examples
Open

feat: Agent Logic Contract Examples with IAgentLogic Interface#30
saiboyizhan wants to merge 1 commit intoChatAndBuild:mainfrom
saiboyizhan:feat/agent-logic-examples

Conversation

@saiboyizhan
Copy link

Summary

Adds three example logic contracts demonstrating how to extend BAP-578 agents with custom on-chain capabilities via the logicAddress field.

Currently there are no examples showing developers how to build logic contracts for their agents. This PR fills that gap with practical, well-documented examples.

What's Included

Standard Interface

  • IAgentLogic — A common interface (execute + description) that all logic contracts implement
  • IBAP578 — Minimal read-only interface for verifying agent ownership and state

Example Contracts

Contract Description
SimpleTrader Token swap executor with per-trade (1 BNB) and daily (5 BNB) spend limits
PriceAlert On-chain price monitoring using Binance Oracle with keeper-compatible alert checks
AutoFunder Automatic agent balance top-up when funds drop below a configurable threshold

Documentation

  • Full README with architecture diagram, quick-start guides for each contract, and a "Building Your Own Logic Contract" tutorial

File Structure

contracts/community/examples/
├── interfaces/
│   ├── IAgentLogic.sol
│   └── IBAP578.sol
├── SimpleTrader.sol
├── PriceAlert.sol
├── AutoFunder.sol
└── README.md

Key Design Decisions

  • All contracts verify bap578.ownerOf(tokenId) == msg.sender before execution
  • PriceAlert uses Binance Oracle Feed Adapters (native to BNB Chain)
  • AutoFunder and PriceAlert are keeper-compatible (public check functions callable by anyone)
  • Each contract includes clear warning that these are educational examples

Test Plan

  • Hardhat compilation passes (0 errors, 0 warnings)
  • Prettier formatting check passes
  • All 31 existing tests still pass (no regressions)
  • No conflicts with existing community contracts

Add three example logic contracts demonstrating how to extend BAP-578
agents with custom on-chain capabilities via the logicAddress field:

- IAgentLogic: standard interface for agent logic contracts
- SimpleTrader: token swap executor with per-trade and daily limits
- PriceAlert: price monitoring with Binance Oracle and keeper support
- AutoFunder: automatic agent balance top-up with pre-funded reserve

Includes IBAP578 minimal interface, full README with quick-start
guides, and a "Building Your Own" tutorial section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments