AgentExecutor

Contract for executing agent tasks with authorization and resource control.

Overview

The AgentExecutor contract manages agent task execution with role-based access control, gas limits, and execution fees. It provides a secure environment for running agent code on-chain.

Contract Address

Testnet: 0x157C56dEdbAB6caD541109daabA4663Fc016026e

Execution Context

struct ExecutionContext {
    address agent;
    bytes32 taskId;
    address requester;
    uint256 gasLimit;
    uint256 value;
    uint256 timestamp;
    ExecutionStatus status;
    bytes result;
}

enum ExecutionStatus {
    Pending,
    Success,
    Failed,
    Reverted
}

Main Functions

Authorize Agent

Authorize an agent for execution (Admin only):

Function Signature:

Execute Task

Execute an agent task with gas limit and execution fee:

Function Signature:

Parameters:

  • agent: Address of authorized agent contract

  • data: Encoded task data

  • gasLimit: Maximum gas for execution

  • msg.value: Execution fee (minimum required)

Returns: taskId - Unique task identifier

Get Execution Details

Function Signature:

Check Agent Authorization

Get Agent Execution Count

Admin Functions

Revoke Agent

Update Execution Fee

Update Max Gas Limit

Withdraw Fees

Events

ExecutionQueued

Emitted when a task is queued for execution:

ExecutionCompleted

Emitted when execution finishes:

AgentAuthorized

AgentRevoked

Complete Example

Security Features

  1. Role-Based Access Control - Admin and executor roles

  2. Agent Authorization - Only authorized agents can execute

  3. Gas Limits - Prevent excessive gas consumption

  4. Execution Fees - Spam prevention

  5. Reentrancy Protection - Safe external calls

See Also

Last updated