0.0.1 • Published 4 months ago

@skynetxbt/contracts v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Image

Skynet Contracts

A decentralized agent framework powered by smart contracts that interfaces with the Spheron Network. The framework enables the creation and management of autonomous agents with built-in governance, token management, and plugin capabilities.

Project Structure

src/
├── abis/         # Contract ABIs
├── agent/        # Agent-related contracts
├── escrow/       # Escrow system contracts
├── interfaces/   # Contract interfaces
├── library/      # Utility libraries
├── plugins/      # Plugin system contracts // Will be separated into different packages
├── proposals/    # Governance proposal contracts
└── token/        # Token-related contracts

Key Components

Agent System

  • AgentCore: Central contract managing agent creation and lifecycle
  • Agent: Individual agent contract with plugin support
  • AgentTraitRegistry: Manages agent characteristics and capabilities

Token System

  • TokenFactory: Creates and manages agent tokens
  • Spon: Native token of the ecosystem
  • TokenStorage: Persistent storage for token-related data

Plugin System

  • ComputeDeposit: Handles compute resource allocation
  • HealthManager: Monitors and manages agent health
  • TokenLaunchPlugin: Manages token launches
  • NFTMintPlugin: Handles NFT minting operations
  • AeroDromeSwap: DEX integration for token swaps

Governance

  • ProposalManager: Handles governance proposals and voting
  • Various proposal types for different agent operations

Prerequisites

Installation

  1. Clone the repository:
git clone https://github.com/spheronFdn/skynet-contracts.git
cd skynet-contracts
  1. Install dependencies:
forge install

Development Commands

# Build contracts
forge build

# Run tests
forge test

# Format code
forge fmt

# Generate gas report
forge snapshot

# Run local node
anvil

Deployment

The project uses Foundry for deployment. The main deployment script is DeployAll.s.sol which deploys all core contracts in the correct order.

Environment Setup

Create a .env file with the following variables:

PRIVATE_KEY=your_private_key
RPC_URL=your_rpc_url
AGENT_CORE_ADDRESS=deployed_agent_core_address
PROPOSAL_MANAGER_ADDRESS=deployed_proposal_manager_address
SPON_TOKEN_ADDRESS=deployed_spon_token_address
SPHERON_ESCROW_ADDRESS=spheron_escrow_address

Deployment Steps

  1. Deploy core contracts:
forge script script/DeployAll.s.sol:DeployAll --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
  1. Deploy plugins (after core deployment):
forge script script/DeployTokenPlugin.s.sol:DeployTokenPlugin --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast

forge script script/DeployNFTPlugin.s.sol:DeployNFTPlugin --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast

forge script script/DeployCompute.s.sol:DeployCompute --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
  1. Create and configure agents:
forge script script/DeployAgent.s.sol:DeployAgent --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast

Testing

The project includes comprehensive tests for all components:

# Run all tests
forge test

# Run specific test file
forge test --match-path test/TestHealthManager.sol

# Run tests with gas reporting
forge test --gas-report

Security

  • All contracts use OpenZeppelin's secure contract implementations
  • Access control mechanisms are in place for critical functions
  • Escrow system for secure token and asset management
  • Plugin system with security checks and validations

License

MIT License