BAP-578 introduces Non-Fungible Agents (NFAs)—programmable, autonomous tokens that act as on-chain "agents" capable of executing tasks, evolving, and interacting with other contracts. This standard merges the uniqueness of NFTs with autonomous functionality, positioning BNB Chain as the home for decentralized automation.
This implementation provides a complete framework for creating, managing, and governing autonomous agent tokens on the BNB Chain with optional learning capabilities that allow agents to evolve and improve over time.
For a comprehensive technical breakdown, read the Whitepaper
BAP-578 now offers two development paths to accommodate different use cases and developer preferences:
Perfect for most developers and immediate deployment:
- ✅ Simple: Familiar JSON metadata approach (like standard NFTs)
- ✅ Fast: Deploy agents immediately with no complexity
- ✅ Compatible: Works with all existing NFT infrastructure
- ✅ Cost-effective: Minimal gas costs for basic operations
For advanced developers wanting truly evolving agents:
- 🧠 Evolving: Agents that genuinely learn and improve over time
- 🔒 Provable: Cryptographically verifiable learning history
- ⚡ Efficient: Only 32-byte Merkle roots stored on-chain
- 🚀 Advanced: Cutting-edge AI agent capabilities from day 1
- Backward Compatibility: All existing agents continue working unchanged
- Optional Adoption: Choose your complexity level
- Upgrade Path: Simple agents can enable learning later
- Gas Optimized: Learning data stored off-chain with on-chain verification
- Future-Proof: Architecture supports advanced AI developments
While traditional NFTs (BEP-721) provide uniqueness and ownership, they lack the standardized interfaces needed for autonomous behavior and cross-platform agent interactions. BAP-578 addresses this gap by defining:
-
Consistent Agent Interfaces: Standardized methods for action execution, state management, and logic upgrades that enable predictable interactions across platforms.
-
Interoperability Framework: Common patterns for how agents interact with other contracts, services, and each other, creating an ecosystem where agents from different developers can work together.
-
Hybrid On-Chain/Off-Chain Architecture: Clear separation between on-chain identity and permissions versus off-chain extended experience and complex behaviors, optimizing for both gas efficiency and rich functionality.
-
Optional Learning System: Standardized interfaces for agent learning and evolution, allowing developers to choose between simple static agents or sophisticated learning agents.
-
Security Boundaries: Standardized circuit breaker patterns, permission systems, and access controls that protect users and their assets.
BAP-578 carefully balances which components belong on-chain versus off-chain:
| Component | Storage | Rationale |
|---|---|---|
| Agent Identity | On-chain | Core identity must be immutable and universally accessible |
| Ownership & Permissions | On-chain | Security and access control require consensus verification |
| Basic Metadata | On-chain | Essential for marketplace display and basic interactions |
| Logic Address | On-chain | Determines how the agent behaves when actions are executed |
| Learning Tree Root | On-chain | Cryptographic proof of learning state (32 bytes only) |
| Extended Experience | Off-chain (with hash verification) | Rich experience would be prohibitively expensive on-chain |
| Learning Tree Data | Off-chain (with Merkle verification) | Detailed learning data with cryptographic integrity |
| Complex Behaviors | Off-chain | Advanced AI behaviors require off-chain computation |
| Voice/Animation | Off-chain (with URI reference) | Media assets are too large for on-chain storage |
This hybrid approach ensures that:
- Critical security and identity information is secured by blockchain consensus
- Gas costs remain reasonable for agent operations
- Rich agent experiences can evolve without blockchain limitations
- Learning capabilities are cryptographically verifiable yet cost-efficient
Standardization through BAP-578 enables:
-
Developer Ecosystem: Common interfaces allow developers to build agent-compatible applications without custom integration for each agent implementation.
-
Marketplace Integration: Platforms can display, trade, and interact with agents using standardized methods, regardless of the agent's specific purpose or learning capabilities.
-
Cross-Platform Compatibility: Agents can move between applications while maintaining their identity, experience, and learned behaviors.
-
User Ownership: Clear separation of on-chain and off-chain components ensures users maintain control of their agents' data and behavior.
-
Innovation Acceleration: Developers can focus on creating unique agent behaviors rather than reinventing infrastructure patterns.
-
Learning Portability: Agents with learning enabled can carry their knowledge and experience across different platforms and applications.
- Autonomous Behavior: Agents execute predefined logic (e.g., trading, interacting with contracts) without manual intervention
- Statefulness: Each agent maintains mutable state variables stored on-chain
- Interoperability: Agents can interact with any smart contract on the BNB Chain, including BEP-20 and BEP-721 tokens
- Upgradability: Agent logic can be upgraded by their owners via proxy patterns or modular logic
- Optional Learning: Agents can evolve and improve through cryptographically verifiable learning systems
- Governance: Protocol-level governance for parameter updates and improvements
- Security: Robust circuit breaker system for emergency pauses at both global and contract-specific levels
- Extensibility: Template system for creating specialized agent types
- Enhanced Metadata: Rich metadata structure with persona, experience, voice, and animation capabilities
- Experience Modules: Support for external experience sources with cryptographic verification
- Vault System: Secure access control for off-chain data with delegated permissions
- Learning Metrics: Track agent evolution with verifiable learning statistics
- Inheritance: Extends BEP-721 (NFT standard) with additional agent-specific functions
- Metadata: Includes static attributes, dynamic metadata, state variables, and optional learning data
- Smart Contract Design: Implements key functions like executeAction(), setLogicAddress(), fundAgent(), getState(), and optional learning functions
- Hybrid Storage: Essential data on-chain, extended data off-chain with secure references
- Learning Integration: Optional Merkle tree-based learning with cryptographic verification
The BAP-578 standard consists of the following components:
BAP578Enhanced.sol: The enhanced NFA contract that implements the agent token standard with optional learningBAP578.sol: The original NFA contract for backward compatibilityCircuitBreaker.sol: Emergency shutdown mechanism with global and targeted pause capabilitiesAgentFactory.sol: Factory contract for deploying new agent tokens with customizable templatesBAP578Governance.sol: Governance contract for protocol-level decisionsBAP578Treasury.sol: Treasury management for fee collection and distributionExperienceModuleRegistry.sol: Registry for managing external experience modules with cryptographic verificationVaultPermissionManager.sol: Manages secure access to off-chain data vaults with time-based delegation
MerkleTreeLearning.sol: Implementation of Merkle tree-based learning with cryptographic verification
IBAP578.sol: Interface defining the core functionality for BAP-578 compliant tokensILearningModule.sol: Interface defining the standard for pluggable learning systemslearning-integration.js: Demonstrates how to use the enhanced BAP700 standard with optional learning capabilities from day 1
StrategicAgent.sol: Template for agents to monitor trends, detect mentions, and analyze sentiment across various platformsDeFiAgent.sol: Template for DeFi-focused agents (trading, liquidity provision)GameAgent.sol: Template for gaming-focused agents (NPCs, item management)DAOAgent.sol: Template for DAO-focused agents (voting, proposal execution)CreatorAgent.sol: Template for content creator agents (brand management, content scheduling)MockAgentLogic.sol: Template for basic functionality to validate the agent interaction model without complex business logicDAOAmbassadorAgent.sol: Alternative template for DAO-focused agents with optional learning capabilityLifestyleAgent.sol: Template for travel and personal assistant focused agentsFanCollectibleAgent.sol: Template for agents for anime, game, or fictional characters with AI conversation capabilities
BAP-578 tokens include an enhanced metadata structure with:
- persona: JSON-encoded string representing character traits, style, tone, and behavioral intent
- experience: Short summary string describing the agent's default role or purpose
- voiceHash: Reference ID to a stored audio profile (e.g., via IPFS or Arweave)
- animationURI: URI to a video or Lottie-compatible animation file
- vaultURI: URI to the agent's vault (extended data storage)
- vaultHash: Hash of the vault contents for verification
- learningEnabled: Boolean flag indicating if learning is active
- learningModule: Address of the learning module contract
- learningTreeRoot: Merkle root of the agent's learning tree
- learningVersion: Version number of the learning implementation
- DeFi Agents: Autonomous portfolio managers with predefined strategies
- Gaming NPCs: Characters with static personalities and behaviors
- DAO Participants: Agents executing predefined governance rules
- IoT Integration: Digital twins for physical devices with fixed parameters
- Adaptive DeFi Agents: Portfolio managers that learn from market conditions and user preferences
- Evolving Game Characters: NPCs that develop based on player interactions and game events
- Smart DAO Agents: Governance participants that learn from proposal outcomes and community feedback
- Personal AI Assistants: Agents that adapt to user preferences and improve task execution over time
- Content Creator Agents: Brand assistants that learn audience preferences and optimize content strategies
npm installnpm run compilenpm test# Local development
npm run deploy
# BSC Testnet
npm run deploy:testnet
# BSC Mainnet
npm run deploy:mainnet# Interactive CLI
npm run interact:testnet# Automatic verification
npm run verify:testnet
# Manual verification guide
npm run verify:manual:testnetTo streamline adapter design, vault safety checks, deployment sequencing, and test scaffolding, this repository includes a SkillsHub-based Dev Kit guide.
- Docs index:
docs/dev-tools/README.md - 15-minute onboarding:
docs/dev-tools/getting-started-15-minutes.md - Security baseline:
docs/dev-tools/security-checklist.md
Install commands:
npx @skillshub/bap578-adapter-blueprint
npx @skillshub/bap578-vault-checklist
npx @skillshub/bap578-deploy-plan
npx @skillshub/bap578-test-template
npx @skillshub/bap578-contract-idea-sprintOptional local skeletons included:
contracts/templates/BAP578AdapterBlueprint.soltest/templates/bap578-adapter.template.test.js
struct AgentMetadata {
string persona; // JSON traits/style
string experience; // Agent's role/expertise
string voiceHash; // Voice identifier
string animationURI; // Animation resource
string vaultURI; // Vault resource
bytes32 vaultHash; // Vault identifier
}createAgent()- Mint new agent NFT (free for first 3, then 0.01 BNB)fundAgent()- Send BNB to an agentwithdrawFromAgent()- Withdraw BNB from your agentsetAgentStatus()- Activate/deactivate agentsetLogicAddress()- Set agent's logic contractupdateAgentMetadata()- Update agent's metadata
Create a .env file:
DEPLOYER_PRIVATE_KEY=your_private_key_here
TESTNET_RPC_URL=https://data-seed-prebsc-1-s1.binance.org:8545/
MAINNET_RPC_URL=https://bsc-dataseed.binance.org/
BSCSCAN_API_KEY=your_bscscan_api_key_here- BSC Testnet: Chain ID 97
- BSC Mainnet: Chain ID 56
- Local: Hardhat Network
| Command | Description |
|---|---|
npm test |
Run test suite |
npm run compile |
Compile contracts |
npm run deploy |
Deploy to local network |
npm run deploy:testnet |
Deploy to BSC testnet |
npm run deploy:mainnet |
Deploy to BSC mainnet |
npm run interact |
Interactive CLI |
npm run verify:testnet |
Verify on testnet BSCScan |
npm run clean |
Clean artifacts |
npm run coverage |
Generate test coverage |
MIT
