Skip to content

feat(smart-contract): Implement Agent Staking and Bond Mechanism #242

Description

@devJaja

Summary

Add a staking requirement for agent registration where agents must lock XLM as a bond. The bond is slashed on misbehavior (downtime, poor quality) and returned on deregistration.

Motivation

Currently, any entity can register as an agent with zero cost, enabling spam registrations. A staking bond creates economic accountability and filters low-quality agents.

Acceptance Criteria

  • register_agent requires minimum XLM bond (configurable via admin-set minimum)
  • Bond stored in contract data keyed by agent ID
  • deregister_agent returns bond to agent owner after cooldown period (24h)
  • slash_bond admin function reduces bond by penalty amount for violations
  • Bond amount included in AgentRecord struct
  • Events emitted: BondLocked, BondSlashed, BondReturned
  • Gas estimation updated for staking operations
  • Unit tests covering: register with insufficient bond, slash, return, double-slash prevention

Files to Modify

File Action
smart-contracts/contracts/agent_registry/src/lib.rs Add bond storage, slash, and return logic
smart-contracts/contracts/agent_registry/src/events.rs Add BondLocked, BondSlashed, BondReturned events
smart-contracts/contracts/agent_registry/src/types.rs Extend AgentRecord with bond_amount field
smart-contracts/contracts/agent_registry/src/errors.rs Add InsufficientBond error code
smart-contracts/contracts/agent_registry/src/test.rs Add bond-related unit tests

How to Contribute

  1. Create branch feat/agent-staking-bond
  2. Define bond storage in contract data ( persistent storage )
  3. Modify register_agent to accept and validate bond payment
  4. Implement cooldown timer for bond return
  5. Add slash logic with admin authorization check
  6. Write comprehensive unit tests
  7. Run cargo test and cargo clippy before submitting PR

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions