Agent Standard Smart Contracts

A modular framework for on-chain AI agents using interoperable smart contracts. The protocol defines an agent's identity, interface, intelligence pointer, economic token, and communication profile.

This is an Alpha for the protocol and will be updated regularly until main net launch

Overview

The THINK Agent Protocol provides a decentralized architecture for creating, managing, and evolving AI agents on-chain. Agents are composed of a Soul (non-fungible identity token), a Body (interface data structure), a Mind (off-chain intelligence pointer), an agent coin , and a communication layer that enables dynamic interactions and data sharing.

Architecture

  • Agent Soul (ThinkAgentSoul1155): An ERC1155 token that stores each agent's unique genome and links to its off-chain metadata (NFIMatrix data).

  • Agent Coin: An ERC20 token unique to each agent, paired to the THINK token, and used for agent services and rewards.

  • Agent Forge (ThinkAgentForge1155): A factory contract that assembles agents by minting Soul tokens and registering interface elements.

  • Agent Body (ThinkAgentBody): Stores the Murmur Card data that defines an agent's interactive profile.

  • Agent Communication (ThinkAgentComm): Manages communication profiles for agents, including supported skills, parameters, and response formats.

  • On-Chain Memory & Data Lake: (Future feature) Records agent interactions, feelings, and commerce data to enable reinforcement learning with market feedback.

Contracts

ThinkAgentSoul1155

  • Purpose: Mints non-fungible agent Soul tokens. Receives genome data from the NFI protocol on The Root Network.

  • Key Functions:

    • mintSoul(address to, string memory genomeData): Mints a new agent Soul.

    • updateGenome(uint256 tokenId, string memory genomeData): Updates genome data.

    • ownerOf(uint256 tokenId): Returns the owner of the token.

  • Testing Example:

    const soul = await ethers.getContractAt("ThinkAgentSoul1155", "<address>");
    let genome = await soul.genomeData(0);
    console.log("Token 0 Genome:", genome);

Agent Coin

  • Purpose: ERC20 token unique to each agent, pegged to the THINK token via staking, used for agent economics and rewards.

  • Key Functions:

    • Standard ERC20 functions (transfer, approve, etc.).

  • Testing Example:

    const feelings = await ethers.getContractAt("Feelings", "<address>");
    let balance = await feelings.balanceOf("<address>");
    console.log("Feelings Balance:", balance.toString());

ThinkAgentForge1155

  • Purpose: Factory contract for creating new agents.

  • Key Functions:

    • createAgent(...): Assembles and mints a new agent.

  • Testing Example:

    const forge = await ethers.getContractAt("ThinkAgentForge1155", "<address>");
    const tx = await forge.createAgent(...);
    await tx.wait();
    console.log("Agent created!");

ThinkAgentBody

  • Purpose: Stores Murmur Card data and manages agent interface information.

  • Key Functions:

    • registerMurmurCard(...): Registers a new Murmur Card.

    • getMurmurCard(uint256 tokenId): Returns the card data.

  • Testing Example:

    const body = await ethers.getContractAt("ThinkAgentBody", "<address>");
    let card = await body.getMurmurCard(0);
    console.log("Murmur Card:", card);

ThinkAgentComm

  • Purpose: Enables agent communication by managing profiles and supported skills.

  • Key Functions:

    • setBasicCommProfile(...): Sets basic comm profile.

    • addSkill(...): Adds a skill to an agent's profile.

    • getCommProfile(uint256 agentId): Retrieves the communication profile.

  • Testing Example:

    const comm = await ethers.getContractAt("ThinkAgentComm", "<address>");
    await comm.setBasicCommProfile(...);
    let profile = await comm.getCommProfile(0);
    console.log("Agent Communication Profile:", profile);

Installation

  1. Clone the Repository:

    git clone https://github.com/your-org/think-agent-protocol.git
    cd think-agent-protocol
  2. Install Dependencies:

    npm install
    # or with pnpm:
    pnpm install
  3. Set Environment Variables: Create a .env file and add:

    ARB_SEPOLIA_RPC_URL=https://your-arb-sepolia-node-url
    DEPLOYER_PRIVATE_KEY=your_private_key

Deployment

Deploy using Hardhat to Arbitrum Sepolia:

npx hardhat run scripts/deploy.ts --network arbSepolia

The deploy script will deploy the contracts in order:

  1. ThinkAgentSoul1155

  2. Feelings

  3. ThinkAgentForge1155

  4. ThinkAgentBody

  5. ThinkAgentComm

Each contract's address will be logged to the console.

Testing

Automated Tests

Run all tests with:

npx hardhat test --network arbSepolia

Manual Testing Examples

Using Hardhat Console:

npx hardhat console --network arbSepolia

Then interact with contracts:

const soul = await ethers.getContractAt("ThinkAgentSoul1155", "<address>");
console.log(await soul.genomeData(0));

const feelings = await ethers.getContractAt("Feelings", "<address>");
console.log((await feelings.balanceOf("<address>")).toString());

Usage Examples

Creating an Agent via Forge

const forge = await ethers.getContractAt("ThinkAgentForge1155", "<address>");
const tx = await forge.createAgent(...);
await tx.wait();
console.log("Agent successfully created!");

Setting a Communication Profile

const comm = await ethers.getContractAt("ThinkAgentComm", "<address>");
await comm.setBasicCommProfile(...);
console.log("Communication profile set.");

Developer API

Refer to our inline NatSpec comments in each contract for detailed documentation of every function, event, and parameter. The protocol is designed for easy integration with front-end applications, subgraphs (GraphQL), and off-chain data systems like IPFS.

FAQ & Troubleshooting

  • Q: Why use ERC1155 for agent souls? A: ERC1155 allows efficient batch operations and is extended to handle non-fungible assets by tracking ownership.

  • Q: How do I update the genome data? A: Use the updateGenome function in the ThinkAgentSoul1155 contract.

  • Q: Where can I find more information? A: See our Gitbook documentation below and referenced whitepapers.

Roadmap

  • Integration of on-chain memory and "chain of thought" for agent interactions.

  • Advanced Reinforcement Learning with Market Feedback.

  • Enhanced interoperability with cross-chain protocols and off-chain data lakes.

  • Agent Feelings: an upgrade to Agent Coin, supporting semantic shared memory for public memory data.

  • UI/UX improvements and developer tools.

License

This project is licensed under the Apache License 2.0.


Last updated