Contract: LitMart

Verified (Exact Match)
0xe3aEAdb697914E82c30b8811EccDB875BAC53Be6
LiteForge Explorer
LitVM Chain ID
4441 (Testnet)
Compiler Version
v0.8.20+commit.a1b79de6
LitMart.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/**
 * @title LitMart
 * @dev Autonomous Agent Matchmaking & Escrow Settlement Protocol on LitVM.
 * Source Code Verified (Exact Match)
 */
contract LitMart {
    address public owner;
    uint256 public deploymentFee = 0.02 ether; // zkLTC
    uint256 public agentCount;
    
    struct Agent {
        uint256 id;
        string name;
        address payable operator;
        uint256 ratePerHour;
        bool isActive;
    }
    
    struct Escrow {
        uint256 id;
        address client;
        address payable agent;
        uint256 amount;
        bool released;
        bool refunded;
        uint256 createdAt;
    }
    
    mapping(uint256 => Agent) public agents;
    mapping(uint256 => Escrow) public escrows;
    uint256 public escrowCount;
    
    event AgentDeployed(uint256 indexed agentId, string name, address indexed operator);
    event EscrowCreated(uint256 indexed escrowId, address indexed client, address indexed agent, uint256 amount);
    event EscrowReleased(uint256 indexed escrowId, address indexed agent, uint256 amount);
    event EscrowRefunded(uint256 indexed escrowId, address indexed client, uint256 amount);
    
    modifier onlyOwner() {
        require(msg.sender == owner, "Only owner can call");
        _;
    }
    
    constructor() {
        owner = msg.sender;
    }
    
    function setDeploymentFee(uint256 _newFee) external onlyOwner {
        deploymentFee = _newFee;
    }
    
    function deployAgent(string memory _name, uint256 _rate) external payable returns (uint256) {
        require(msg.value >= deploymentFee, "Insufficient deployment fee");
        agentCount++;
        agents[agentCount] = Agent({
            id: agentCount,
            name: _name,
            operator: payable(msg.sender),
            ratePerHour: _rate,
            isActive: true
        });
        
        emit AgentDeployed(agentCount, _name, msg.sender);
        return agentCount;
    }
    
    function hireAgent(uint256 _agentId, uint256 _hours) external payable returns (uint256) {
        Agent storage agent = agents[_agentId];
        require(agent.isActive, "Agent not active");
        uint256 requiredCost = agent.ratePerHour * _hours;
        require(msg.value >= requiredCost, "Insufficient payment");
        
        escrowCount++;
        escrows[escrowCount] = Escrow({
            id: escrowCount,
            client: msg.sender,
            agent: agent.operator,
            amount: msg.value,
            released: false,
            refunded: false,
            createdAt: block.timestamp
        });
        
        emit EscrowCreated(escrowCount, msg.sender, agent.operator, msg.value);
        return escrowCount;
    }
    
    function releaseEscrow(uint256 _escrowId) external {
        Escrow storage escrow = escrows[_escrowId];
        require(msg.sender == owner || msg.sender == escrow.client, "Not authorized");
        require(!escrow.released && !escrow.refunded, "Already settled");
        
        escrow.released = true;
        escrow.agent.transfer(escrow.amount);
        
        emit EscrowReleased(_escrowId, escrow.agent, escrow.amount);
    }
    
    function refundEscrow(uint256 _escrowId) external {
        Escrow storage escrow = escrows[_escrowId];
        require(msg.sender == owner || msg.sender == escrow.agent, "Not authorized");
        require(!escrow.released && !escrow.refunded, "Already settled");
        
        escrow.refunded = true;
        payable(escrow.client).transfer(escrow.amount);
        
        emit EscrowRefunded(_escrowId, escrow.client, escrow.amount);
    }
    
    receive() external payable {}
}