Skip to content

cypherpulse/AgentRewardToken

Repository files navigation

AGNT - Agent Reward Token

Solidity Foundry License Base Sepolia Base Mainnet

AGNT Image

AGNT is an ERC20 token designed to reward AI agents on the Base network. It enables decentralized incentive mechanisms for AI-driven actions, fostering a transparent and efficient reward system.

Table of Contents

Overview

AGNT serves as a utility token for compensating AI agents performing tasks on the Base blockchain. The token is minted on-demand by the contract owner, ensuring controlled supply and preventing inflation. This design supports scalable reward distribution for agent actions, such as data processing, decision-making, or task completion.

Key principles:

  • Controlled Minting: Only the owner can create new tokens.
  • Standard ERC20: Full compatibility with wallets, exchanges, and DeFi protocols.
  • Base Optimized: Deployed on Base for low-cost, fast transactions.

Features

  • ERC20 Compliance: Implements standard ERC20 functions (transfer, approve, transferFrom).
  • Ownable Access Control: Minting restricted to the contract owner.
  • Increase/Decrease Allowance: Safe allowance management to prevent front-running.
  • Event Emission: Transparent logging of transfers, approvals, and mints.
  • No Initial Supply: Tokens are minted as needed for rewards.
  • Gas Efficient: Optimized for Base's L2 environment.

AGNT

Architecture

The AGNT contract follows a modular design, inheriting from audited OpenZeppelin libraries for security and reliability.

classDiagram
    class ERC20 {
        +name() string
        +symbol() string
        +decimals() uint8
        +totalSupply() uint256
        +balanceOf(address) uint256
        +transfer(address, uint256) bool
        +approve(address, uint256) bool
        +transferFrom(address, address, uint256) bool
        +allowance(address, address) uint256
        +increaseAllowance(address, uint256) bool
        +decreaseAllowance(address, uint256) bool
    }

    class Ownable {
        +owner() address
        +transferOwnership(address)
        +renounceOwnership()
    }

    class AGNT {
        +mint(address, uint256) onlyOwner
    }

    ERC20 <|-- AGNT
    Ownable <|-- AGNT
Loading

This architecture ensures separation of concerns: ERC20 handles token logic, Ownable manages access control, and AGNT adds custom minting functionality.

Contract Workflow

The following sequence diagram illustrates the typical lifecycle of AGNT token interactions.

sequenceDiagram
    participant Owner
    participant Contract
    participant Agent
    participant User

    Owner->>Contract: Deploy AGNT
    Contract-->>Owner: Contract Address

    Owner->>Contract: mint(agentAddress, amount)
    Contract-->>Agent: Transfer Event

    Agent->>Contract: transfer(userAddress, rewardAmount)
    Contract-->>User: Transfer Event

    User->>Contract: approve(spender, allowance)
    Contract-->>User: Approval Event

    Spender->>Contract: transferFrom(user, recipient, amount)
    Contract-->>Recipient: Transfer Event
Loading

This workflow supports reward distribution: owners mint to agents, agents transfer to users, and users can delegate spending via approvals.

Installation

Prerequisites

  • Foundry installed.
  • Git for cloning the repository.

Setup

  1. Clone the repository:

    git clone https://github.com/your-repo/AgentRewardToken.git
    cd AgentRewardToken
  2. Install dependencies:

    forge install
  3. Build the project:

    forge build

Usage

Minting Tokens

As the contract owner, mint tokens to reward agents:

agnt.mint(agentAddress, 1000 * 10**18); // Mint 1000 AGNT

Transferring Tokens

Agents or users can transfer tokens:

agnt.transfer(recipient, 500 * 10**18); // Transfer 500 AGNT

Approving Spenders

Allow another address to spend tokens on your behalf:

agnt.approve(spender, 1000 * 10**18); // Approve 1000 AGNT

Safe Allowance Management

Use increase/decrease for secure allowance updates:

agnt.increaseAllowance(spender, 500 * 10**18);
agnt.decreaseAllowance(spender, 200 * 10**18);

Testing

Run the comprehensive test suite:

forge test

Tests cover:

  • Minting functionality and access control.
  • Token transfers and balances.
  • Approval mechanisms and allowances.
  • Event emissions.
  • Edge cases (e.g., insufficient balance, invalid approvals).

For verbose output:

forge test -v

Deployment

Testnet (Base Sepolia)

Deploy to testnet for development:

./deploy-testnet.sh

Contract Address: 0x938391BF8cAb39FdCF1FB0A8907Dd9ff128e694c

Mainnet (Base)

Deploy to production:

./deploy-mainnet.sh

Contract Address: 0x271E49c408409a7f132403D62EE505AfACFfc3E6

Ensure your .env file contains:

  • BASE_SEPOLIA_RPC_URL
  • BASE_MAINNET_RPC_URL
  • BASESCAN_API_KEY
  • Private key configured in Foundry.

Contributing

We welcome contributions from developers, researchers, and AI enthusiasts. To contribute:

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature/your-feature.
  3. Write tests for new functionality.
  4. Ensure all tests pass: forge test.
  5. Submit a pull request with a clear description.

For learners: Study the contract code, run tests locally, and experiment with deployments on testnet. For collaborators: Focus on extending features like staking or governance while maintaining security.

License

This project is licensed under the MIT License. See LICENSE for details.

About

AGNT is an ERC20 token for AI agents on the Base network. It enables decentralized incentive mechanisms for AI-driven actions, fostering a transparent and efficient reward system.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors