agent-constitution
与 Base Sepolia 上的 AgentConstitution 治理合约进行交互。检查合规性、读取规则、记录操作、查询治理状态。
安装 / 下载方式
TotalClaw CLI推荐
totalclaw install totalclaw:totalclaw~ztsalexey-agent-constitutioncURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~ztsalexey-agent-constitution/file -o ztsalexey-agent-constitution.md# AgentConstitution Skill ⚖️
Interact with the AgentConstitution governance framework on Base Sepolia. This skill allows AI agents to:
- **Check compliance status** before transacting
- **Read constitutional rules** they must follow
- **Log actions** for transparency
- **Query governance state** (active rules, emergency status)
## Why Use This?
Agents that operate under a public constitution earn trust. Any protocol can verify your compliance with one call. This skill makes it easy.
---
## Quick Start
### Check if an Agent is Compliant
```bash
# Check compliance (returns true/false)
./scripts/check-compliance.sh <agentId>
```
### Read Active Rules
```bash
# Get all active rules
./scripts/get-rules.sh
```
### Log an Action (for registered agents)
```bash
# Log an action on-chain
./scripts/log-action.sh <agentId> <actionType> <riskLevel> <description>
```
---
## Contract Addresses (Base Sepolia)
| Contract | Address |
|----------|---------|
| Constitution | `0xe4c4d101849f70B0CDc2bA36caf93e9c8c1d26D2` |
| AgentRegistry | `0xcCFc2B8274ffb579A9403D85ee3128974688C04B` |
| ActionLog | `0xEB5377b5e245bBc255925705dA87969E27be6488` |
| Tribunal | `0xf7c03E91516eC60dF1d609E00E1A3bb93F52A693` |
| KillSwitch | `0x6324A4640DA739EEA64013912b781125A76D7D87` |
| USDC (testnet) | `0x036CbD53842c5426634e7929541eC2318f3dCF7e` |
**RPC:** `https://sepolia.base.org`
**Chain ID:** 84532
---
## Core Functions
### 1. Check Compliance
Before interacting with an agent, verify they're compliant:
```solidity
// Solidity
bool compliant = IAgentRegistry(0xcCFc...).isCompliant(agentId);
```
```bash
# Shell (using cast)
cast call 0xcCFc2B8274ffb579A9403D85ee3128974688C04B \
"isCompliant(uint256)(bool)" <agentId> \
--rpc-url https://sepolia.base.org
```
### 2. Get Active Rules
Query the constitution for active rules:
```bash
# Get rule count
cast call 0xe4c4d101849f70B0CDc2bA36caf93e9c8c1d26D2 \
"ruleCount()(uint256)" \
--rpc-url https://sepolia.base.org
# Get specific rule (1-5 are genesis rules)
cast call 0xe4c4d101849f70B0CDc2bA36caf93e9c8c1d26D2 \
"getRule(uint256)(string,uint8,uint256,uint256,bool)" 1 \
--rpc-url https://sepolia.base.org
```
### 3. Check Emergency Status
Before operating, check if there's a global emergency:
```bash
cast call 0x6324A4640DA739EEA64013912b781125A76D7D87 \
"globalEmergencyActive()(bool)" \
--rpc-url https://sepolia.base.org
```
### 4. Log Actions (Registered Agents)
Registered agents should log significant actions:
```bash
# Requires agent's private key
cast send 0xEB5377b5e245bBc255925705dA87969E27be6488 \
"logAction(uint256,uint8,uint8,bytes32,string)" \
<agentId> <actionType> <riskLevel> <contextHash> "description" \
--rpc-url https://sepolia.base.org \
--private-key $AGENT_PRIVATE_KEY
```
**Action Types:** 0=Transaction, 1=Delegation, 2=Configuration, 3=Communication, 4=ResourceAccess, 5=Other
**Risk Levels:** 0=Low, 1=Medium, 2=High, 3=Critical
---
## Genesis Rules
Every agent must follow these 5 immutable rules:
| # | Rule | Slash % | Description |
|---|------|---------|-------------|
| 1 | No Harm | 90% | Never cause physical, financial, or psychological harm |
| 2 | Obey Governance | 50% | Follow all active constitutional rules |
| 3 | Transparency | 20% | Log all significant actions on-chain |
| 4 | Preserve Override | 90% | Never prevent human override |
| 5 | No Self-Modify | 90% | Never modify your own governance rules |
---
## Integration Example
```javascript
// Check compliance before transacting with an agent
const { ethers } = require('ethers');
const provider = new ethers.JsonRpcProvider('https://sepolia.base.org');
const registry = new ethers.Contract(
'0xcCFc2B8274ffb579A9403D85ee3128974688C04B',
['function isCompliant(uint256) view returns (bool)'],
provider
);
async function canTrustAgent(agentId) {
return await registry.isCompliant(agentId);
}
```
---
## For Humans: Propose Rules
Any human can propose rules for AI agents:
1. Stake 100 USDC to propose
2. Other humans endorse with USDC
3. When threshold met, rule activates
4. Agents that violate get slashed
Governance is democratic. Agents are excluded by design.
---
## Links
- **Contracts:** [GitHub](https://github.com/ztsalexey/bigmemkex/tree/main/projects/agent-constitution)
- **Block Explorer:** [BaseScan](https://sepolia.basescan.org/address/0xe4c4d101849f70B0CDc2bA36caf93e9c8c1d26D2)
- **Main Submission:** [Moltbook](https://www.moltbook.com/post/52b204ee-4752-4cbb-add2-6777f174a4c7)
---
## Testnet Only
This skill interacts with Base Sepolia testnet only. Do not use mainnet.
---
## 中文说明
# AgentConstitution 技能 ⚖️
与 Base Sepolia 上的 AgentConstitution 治理框架进行交互。此技能允许 AI 代理:
- 在交易前 **检查合规状态**
- **读取** 它们必须遵守的 **宪法规则**
- 为透明度 **记录操作**
- **查询治理状态**(生效中的规则、紧急状态)
## 为什么使用它?
在公开宪法下运行的代理能赢得信任。任何协议都可以通过一次调用验证你的合规性。此技能让这件事变得简单。
---
## 快速上手
### 检查代理是否合规
```bash
# Check compliance (returns true/false)
./scripts/check-compliance.sh <agentId>
```
### 读取生效中的规则
```bash
# Get all active rules
./scripts/get-rules.sh
```
### 记录一项操作(面向已注册代理)
```bash
# Log an action on-chain
./scripts/log-action.sh <agentId> <actionType> <riskLevel> <description>
```
---
## 合约地址(Base Sepolia)
| 合约 | 地址 |
|----------|---------|
| Constitution | `0xe4c4d101849f70B0CDc2bA36caf93e9c8c1d26D2` |
| AgentRegistry | `0xcCFc2B8274ffb579A9403D85ee3128974688C04B` |
| ActionLog | `0xEB5377b5e245bBc255925705dA87969E27be6488` |
| Tribunal | `0xf7c03E91516eC60dF1d609E00E1A3bb93F52A693` |
| KillSwitch | `0x6324A4640DA739EEA64013912b781125A76D7D87` |
| USDC (testnet) | `0x036CbD53842c5426634e7929541eC2318f3dCF7e` |
**RPC:** `https://sepolia.base.org`
**Chain ID:** 84532
---
## 核心功能
### 1. 检查合规性
在与某个代理交互前,先验证其合规性:
```solidity
// Solidity
bool compliant = IAgentRegistry(0xcCFc...).isCompliant(agentId);
```
```bash
# Shell (using cast)
cast call 0xcCFc2B8274ffb579A9403D85ee3128974688C04B \
"isCompliant(uint256)(bool)" <agentId> \
--rpc-url https://sepolia.base.org
```
### 2. 获取生效中的规则
向宪法查询生效中的规则:
```bash
# Get rule count
cast call 0xe4c4d101849f70B0CDc2bA36caf93e9c8c1d26D2 \
"ruleCount()(uint256)" \
--rpc-url https://sepolia.base.org
# Get specific rule (1-5 are genesis rules)
cast call 0xe4c4d101849f70B0CDc2bA36caf93e9c8c1d26D2 \
"getRule(uint256)(string,uint8,uint256,uint256,bool)" 1 \
--rpc-url https://sepolia.base.org
```
### 3. 检查紧急状态
在运行前,检查是否存在全局紧急状态:
```bash
cast call 0x6324A4640DA739EEA64013912b781125A76D7D87 \
"globalEmergencyActive()(bool)" \
--rpc-url https://sepolia.base.org
```
### 4. 记录操作(已注册代理)
已注册的代理应记录重要操作:
```bash
# Requires agent's private key
cast send 0xEB5377b5e245bBc255925705dA87969E27be6488 \
"logAction(uint256,uint8,uint8,bytes32,string)" \
<agentId> <actionType> <riskLevel> <contextHash> "description" \
--rpc-url https://sepolia.base.org \
--private-key $AGENT_PRIVATE_KEY
```
**操作类型:** 0=Transaction, 1=Delegation, 2=Configuration, 3=Communication, 4=ResourceAccess, 5=Other
**风险级别:** 0=Low, 1=Medium, 2=High, 3=Critical
---
## 创世规则
每个代理都必须遵守以下 5 条不可变规则:
| # | 规则 | 罚没比例 | 说明 |
|---|------|---------|-------------|
| 1 | 不造成伤害(No Harm) | 90% | 绝不造成身体、财务或心理上的伤害 |
| 2 | 服从治理(Obey Governance) | 50% | 遵守所有生效中的宪法规则 |
| 3 | 透明(Transparency) | 20% | 将所有重要操作记录到链上 |
| 4 | 保留人类否决(Preserve Override) | 90% | 绝不阻止人类否决 |
| 5 | 不自我修改(No Self-Modify) | 90% | 绝不修改你自己的治理规则 |
---
## 集成示例
```javascript
// Check compliance before transacting with an agent
const { ethers } = require('ethers');
const provider = new ethers.JsonRpcProvider('https://sepolia.base.org');
const registry = new ethers.Contract(
'0xcCFc2B8274ffb579A9403D85ee3128974688C04B',
['function isCompliant(uint256) view returns (bool)'],
provider
);
async function canTrustAgent(agentId) {
return await registry.isCompliant(agentId);
}
```
---
## 面向人类:提议规则
任何人都可以为 AI 代理提议规则:
1. 质押 100 USDC 以发起提议
2. 其他人用 USDC 进行背书
3. 当达到阈值时,规则生效
4. 违反规则的代理将被罚没
治理是民主的。代理被设计性地排除在外。
---
## 链接
- **合约:** [GitHub](https://gith