> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ameo.agiwithai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Contracts

> MantleAgentIdentity public interface and ABI.

Primary contract: **`MantleAgentIdentity`** — ERC-721 agent identity with `[DecisionLogged](/glossary#decisionlogged-event)` audit log.

**Canonical deployment (Mantle Sepolia, chain 5003):**

|                          |                                                                                                                                   |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| Contract                 | [`0xB86dC64573089D8DD89C5686010295bB4412D652`](https://sepolia.mantlescan.xyz/address/0xB86dC64573089D8DD89C5686010295bB4412D652) |
| Owner + agent NFT holder | `0x59ffc8907beaA275F29B466BCB1D9BbfeaDAd165`                                                                                      |
| Agent token id           | `0`                                                                                                                               |
| Source verify            | Sourcify `exact_match` (bytecode matches `forge build` artifact)                                                                  |
| Deploy tx                | `0xa1b8ae9629fcbaad0816c644695820a15784750a0a95c2f8de93b6c1cdf1d7ad`                                                              |

Source: `packages/contracts/src/MantleAgentIdentity.sol`

## Events

| Event            | Indexed fields | Payload                                                  |
| ---------------- | -------------- | -------------------------------------------------------- |
| `DecisionLogged` | `agentId`      | `rationaleHash`, `actionType`, `metadataUri`, `operator` |

## Functions

| Function                                                                                     | Visibility            | Description                                               |
| -------------------------------------------------------------------------------------------- | --------------------- | --------------------------------------------------------- |
| `mintAgent(address operator)`                                                                | external, `onlyOwner` | Mint agent NFT to `operator`, return `tokenId`            |
| `logDecision(uint256 agentId, bytes32 rationaleHash, string actionType, string metadataUri)` | external              | Caller must own `agentId`; updates snapshot + emits event |

## View mappings

| Mapping                      | Returns                 |
| ---------------------------- | ----------------------- |
| `lastRationaleHash(agentId)` | Latest rationale hash   |
| `lastActionHash(agentId)`    | `keccak256(actionType)` |
| `lastMetadataUri(agentId)`   | Latest metadata URI     |
| `nextTokenId`                | Next mint id            |

## Build & verify

```bash theme={null}
cd packages/contracts
forge build
```

Set `AGENT_IDENTITY_ADDRESS` and `AGENT_TOKEN_ID` in worker + web env. The canonical deployment is already live; only redeploy if you are running a private fork.

## ABI

Generated ABI after build:

```
packages/contracts/out/MantleAgentIdentity.sol/AgentIdentity.json
```

Verify source on Mantlescan after any new deployment.
