The Agent Smart Contracts provide a modular and decentralized framework for deploying, managing, and interacting with AXES agents. Here’s a detailed summary of the three core components:
1. Agent Token (ERC20)
The Agent Token serves as the native ERC20 token for the agent. It is used to gate permissions, facilitate transactions, and enforce usage policies for interacting with the agent's external functionalities. The AgentTokenFactory contract ensures the streamlined deployment of these tokens, allowing developers to initialize the token with specific names, symbols, and initial supplies. This token is integral to creating an economic layer for the agent, enabling stakeholders to transact efficiently.
2. Agent DAO
The Agent DAO governs the agent's operations and ensures decentralized decision-making. Using the AgentDAO contract, members can create, vote on, and execute proposals to update the agent's logic, tokenomics, or any core behavior. The DAO employs a simple majority voting system to determine the outcomes of proposals, ensuring all changes require consensus among members. The AgentDAOFactory facilitates the deployment of DAO contracts, allowing developers to initialize them with member addresses and voting periods.
3. Agent Smart Contract
The Agent Smart Contract acts as the primary interface for connecting the agent with Web2 and Web3 APIs, much like a programmable router. It is tightly integrated with both the Agent Token and Agent DAO, ensuring that only authorized and consensus-approved actions can be executed. The contract enables external calls triggered by the DAO and supports robust logic for routing and handling requests. The AgentContractFactory simplifies the deployment process by linking the agent's token and DAO to this main contract.
Deployment Workflow
All three contracts are deployed via their respective factory contracts, streamlining the setup process for developers. By following the standardized deployment steps, developers can ensure that agents are secure, decentralized, and fully functional within the AXES ecosystem. These contracts collectively enable developers to create scalable, tokenized, and community-governed agents ready for integration with decentralized and traditional systems.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title Factory for Deploying Agent Token (ERC20)
*/
contract AgentTokenFactory {
event AgentTokenCreated(address indexed tokenAddress, string name, string symbol);
function createAgentToken(string memory name, string memory symbol, uint256 initialSupply) external returns (address) {
AgentToken newToken = new AgentToken(name, symbol, initialSupply, msg.sender);
emit AgentTokenCreated(address(newToken), name, symbol);
return address(newToken);
}
}
contract AgentToken {
string public name;
string public symbol;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
address public owner;
modifier onlyOwner() {
require(msg.sender == owner, "Only owner can call this function");
_;
}
constructor(string memory _name, string memory _symbol, uint256 _initialSupply, address _owner) {
name = _name;
symbol = _symbol;
totalSupply = _initialSupply;
balanceOf[_owner] = _initialSupply;
owner = _owner;
}
function transfer(address to, uint256 amount) external {
require(balanceOf[msg.sender] >= amount, "Insufficient balance");
balanceOf[msg.sender] -= amount;
balanceOf[to] += amount;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title Factory for Deploying Agent DAO
*/
contract AgentDAOFactory {
event AgentDAOCreated(address indexed daoAddress);
function createAgentDAO(address[] memory members, uint256 votingPeriod) external returns (address) {
AgentDAO newDAO = new AgentDAO(members, votingPeriod);
emit AgentDAOCreated(address(newDAO));
return address(newDAO);
}
}
contract AgentDAO {
struct Proposal {
string description;
uint256 voteCount;
mapping(address => bool) voted;
bool executed;
}
mapping(uint256 => Proposal) public proposals;
address[] public members;
uint256 public votingPeriod;
uint256 public proposalCount;
address public owner;
modifier onlyMember() {
require(isMember(msg.sender), "Only DAO members can call this function");
_;
}
constructor(address[] memory _members, uint256 _votingPeriod) {
members = _members;
votingPeriod = _votingPeriod;
owner = msg.sender;
}
function isMember(address addr) public view returns (bool) {
for (uint256 i = 0; i < members.length; i++) {
if (members[i] == addr) {
return true;
}
}
return false;
}
function propose(string memory description) external onlyMember {
Proposal storage newProposal = proposals[proposalCount++];
newProposal.description = description;
}
function vote(uint256 proposalId) external onlyMember {
Proposal storage proposal = proposals[proposalId];
require(!proposal.voted[msg.sender], "Member has already voted");
proposal.voted[msg.sender] = true;
proposal.voteCount++;
}
function execute(uint256 proposalId) external onlyMember {
Proposal storage proposal = proposals[proposalId];
require(proposal.voteCount > members.length / 2, "Insufficient votes");
require(!proposal.executed, "Proposal already executed");
proposal.executed = true;
// Logic for execution
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title Factory for Deploying Agent Smart Contract
*/
contract AgentContractFactory {
event AgentContractCreated(address indexed agentAddress);
function createAgentContract(address tokenAddress, address daoAddress) external returns (address) {
AgentContract newAgent = new AgentContract(tokenAddress, daoAddress);
emit AgentContractCreated(address(newAgent));
return address(newAgent);
}
}
contract AgentContract {
address public agentToken;
address public agentDAO;
address public owner;
modifier onlyDAO() {
require(msg.sender == agentDAO, "Only DAO can call this function");
_;
}
constructor(address _agentToken, address _agentDAO) {
agentToken = _agentToken;
agentDAO = _agentDAO;
owner = msg.sender;
}
function externalCall(bytes memory data) external onlyDAO {
// Logic for handling external calls
}
}