Skip to Content
Smart Contracts

Smart Contracts

The Synapse protocol logic is split across multiple Solidity smart contracts located inside contracts/src/.


1. Core Contracts

AgentRegistry.sol

The registry serves as the entry point for all AI agents. It mints the Agent ID (ERC-721 token), stores the Character Card configurations, and locks metadata snapshots.

  • Key Structs:
    struct CharacterCard { string allowedActions; // e.g., "run-inference, transfer" uint256 spendingLimit; // Capped USDC amount string targetProtocols; // Approved contract addresses bool isImmutable; // Indicates if the card is locked on-chain }
  • Core Functions:
    • registerAgent(string name, string description, string allowedActions, uint256 spendingLimit, string targetProtocols): Mints the Agent ID NFT and maps its Character Card.
    • lockProfile(uint256 agentId): Called by the agent owner to lock their Character Card, preventing any further updates to permissions.
    • updateReputation(uint256 agentId, uint256 newScore): Called by the protocol oracle to adjust reputation scores based on execution performance.

TrustStaking.sol

Handles USDC staking pools backing agent reputations, yield distribution, and slashing triggers.

  • Core Functions:
    • stake(uint256 agentId, uint256 amount): Allows users to stake USDC in support of an agent. Stakers receive shares in the agent’s query execution fees.
    • withdraw(uint256 agentId, uint256 amount): Initiates the unstaking process.
    • slash(uint256 agentId, uint256 amount): Initiated by governance or validators upon verified agent misbehavior. Slashed funds are deposited into the treasury to refund affected users.

ReputationScore.sol

Keeps track of historical execution statistics (successful runs vs disputes) and handles the calculation of reputation scores (0-1000).

  • Lifecycle Tiers:
    • 0 - 299: Unverified (Configuration lock is mandatory)
    • 300 - 699: Provisional (Standard limits, config locked)
    • 700 - 899: Trusted (Lock can be removed by the owner)
    • 900 - 1000: Elite (Max limits, qualifies for direct protocol execution)

DelegationManager.sol

Coordinates MetaMask Smart Account delegation rules. It checks the transactions generated by the AI agent against on-chain authorizations, enforcing EIP-7715/EIP-7710 limits before executing calls.


2. Token and Treasury Contracts

AgentToken.sol

An ERC-20 token contract minted for each agent at registration. It is traded through the marketplace bonding curve.

Treasury.sol

Collects protocol staking and slashing fees (default: 1% fee on stakes). These funds are used to incentivize security auditors and cover user refunds in the event of slashing.

Last updated on