import { Chain } from "viem";
import { base, avalanche, arbitrum, polygon } from "viem/chains";
import { getABI } from './abis/abi-map';

export const DEPLOYER_ADDRESS = "0xfA15Ee28939B222B0448261A22156070f0A7813C";

export interface Contract {
  name: string;
  address: `0x${string}`;
  chain: "base" | "avalanche" | "arbitrum" | "polygon";
  abi: readonly any[];
}

export const CHAINS: Record<string, Chain & { explorerUrl: string }> = {
  base: { ...base, explorerUrl: "https://basescan.org" },
  avalanche: { ...avalanche, explorerUrl: "https://snowtrace.io" },
  arbitrum: { ...arbitrum, explorerUrl: "https://arbiscan.io" },
  polygon: { ...polygon, explorerUrl: "https://polygonscan.com" },
};

// --- BASE CONTRACTS (36 total) ---
// V3 security-fixed deployment — canonical addresses from canonical_v3_fixed.json
export const BASE_CONTRACTS: Contract[] = [
    {
      name: "MissionEnforcement",
      address: "0xBc4208A7A59af3B7E438d3308C3dc0d299d739a7",
      chain: "base",
      abi: getABI('MissionEnforcement'),
    },
    {
      name: "AntiSurveillance",
      address: "0xaaC44F1396f3F5b3C06048a1F819DC9b0f86D90c",
      chain: "base",
      abi: getABI('AntiSurveillance'),
    },
    {
      name: "PrivacyGuarantees",
      address: "0x2711AA5f1934Fe97825F02e51cB5Da58d1759625",
      chain: "base",
      abi: getABI('PrivacyGuarantees'),
    },
    {
      name: "ERC8004IdentityRegistry",
      address: "0xa7BD20bf5De63df949cA5Be2F20835978eCba81A",
      chain: "base",
      abi: getABI('ERC8004IdentityRegistry'),
    },
    {
      name: "BeliefAttestationVerifier",
      address: "0x32211773C8266774A704aeD471f8eF073f34bA79",
      chain: "base",
      abi: getABI('BeliefAttestationVerifier'),
    },
    {
      name: "AIPartnershipBondsV2",
      address: "0x01C479F0c039fEC40c0Cf1c5C921bab457d57441",
      chain: "base",
      abi: getABI('AIPartnershipBondsV2'),
    },
    {
      name: "AIAccountabilityBondsV2",
      address: "0x6750D28865434344e04e1D0a6044394b726C3dfE",
      chain: "base",
      abi: getABI('AIAccountabilityBondsV2'),
    },
    {
      name: "FlourishingMetricsOracle",
      address: "0xf7B2dC73Ec69528F171F4a0ded62da557866BaA5",
      chain: "base",
      abi: getABI('FlourishingMetricsOracle'),
    },
    {
      name: "ERC8004ReputationRegistry",
      address: "0x98afd1440B2238D73c1394720277a6d031fCbbD0",
      chain: "base",
      abi: getABI('ERC8004ReputationRegistry'),
    },
    {
      name: "ERC8004ValidationRegistry",
      address: "0x8D3495772EAcAdB7dC09F1784eF06F2D109fb8a5",
      chain: "base",
      abi: getABI('ERC8004ValidationRegistry'),
    },
    {
      name: "VaultfireERC8004Adapter",
      address: "0x8bEFe7411AecddA6E1Aea8F031fedD293Ca7372E",
      chain: "base",
      abi: getABI('VaultfireERC8004Adapter'),
    },
    {
      name: "MultisigGovernance",
      address: "0x34a19C7298aCA59e185F1ecfB352AC566bB4B4A9",
      chain: "base",
      abi: getABI('MultisigGovernance'),
    },
    {
      name: "ProductionBeliefAttestationVerifier",
      address: "0x2a46B5932e9559176241056A04a608B8fEbCc5A7",
      chain: "base",
      abi: getABI('ProductionBeliefAttestationVerifier'),
    },
    {
      name: "DilithiumAttestor",
      address: "0xef703bBe9b21960ede3e96abBB0Bbd0c525Fe050",
      chain: "base",
      abi: getABI('DilithiumAttestor'),
    },
    {
      name: "VaultfireTeleporterBridge",
      address: "0x62edf0cBc8Fa3d98B6A07197DFE9cb1c128a7eC7",
      chain: "base",
      abi: getABI('VaultfireTeleporterBridge'),
    },
    {
      name: "VaultfireTrustAttestation",
      address: "0xc0f8704EF84Ca58Fa0AF4836669d358574FFE1f4",
      chain: "base",
      abi: getABI('VaultfireTrustAttestation'),
    },
    {
      name: "VaultfireNameService",
      address: "0xA9e6c2c0a731F1f56F6720Dfac2eB1440Ab9453a",
      chain: "base",
      abi: getABI('VaultfireNameService'),
    },
    {
      name: "VaultfireTaskEscrow",
      address: "0x70098737Cb41827b7a86397B42c166020BCcC03b",
      chain: "base",
      abi: getABI('VaultfireTaskEscrow'),
    },
    {
      name: "VKPSessionKeyManager",
      address: "0x18622Fd3DF3269Ef3cf53cF374eB011A36DC4Be5",
      chain: "base",
      abi: getABI('VKPSessionKeyManager'),
    },
    {
      name: "VKPDelegationRegistry",
      address: "0xd4d32b5c28040AFA2A6aB0ae9FF6DA68EAee4F82",
      chain: "base",
      abi: getABI('VKPDelegationRegistry'),
    },
    {
      name: "VKPFactory",
      address: "0x174E29E6FAdD3096387030429Eb4677eA569e625",
      chain: "base",
      abi: getABI('VKPFactory'),
    },
    {
      name: "VaultfireReputationStaking",
      address: "0xd42BBfD3061A38D4B5540317A31D90212380069b",
      chain: "base",
      abi: getABI('VaultfireReputationStaking'),
    },
    {
      name: "VaultfireTrustOracle",
      address: "0xF945aA87dB4E1d14aa7d0572501afa166374B776",
      chain: "base",
      abi: getABI('VaultfireTrustOracle'),
    },
    {
      name: "VaultfireBondInsurancePool",
      address: "0xa074e372d5221b605E9762e41B86EbdBEBF1a978",
      chain: "base",
      abi: getABI('VaultfireBondInsurancePool'),
    },
    {
      name: "VaultfireCapabilityCredentials",
      address: "0x4C7fddDdae8855283e98dA80BDf7aEa51A0b772B",
      chain: "base",
      abi: getABI('VaultfireCapabilityCredentials'),
    },
    {
      name: "VaultfireDisputeResolution",
      address: "0x3a681b6eF98c6d35643Ca631eE50EF35edd6BcBD",
      chain: "base",
      abi: getABI('VaultfireDisputeResolution'),
    },
    // v3.0: New v2 contracts
    { name: "AgentInsurancePool", address: "0x4307e2A7073e09A676D4Ac8278eE2eddA702AddC", chain: "base", abi: getABI('AgentInsurancePool') },
    { name: "AgentSafetyManager", address: "0x6B580f08ecA90778AC41FA1290557c86DeEfB1F5", chain: "base", abi: getABI('AgentSafetyManager') },
    { name: "ComplianceRegistry", address: "0xB4e13EF703f71B2465E58c27fa47B0663ae5f699", chain: "base", abi: getABI('ComplianceRegistry') },
    { name: "ReputationDecay", address: "0xcDB75bECa0C56957FC79aB0dd470D4FcE2db6BC1", chain: "base", abi: getABI('ReputationDecay') },
    { name: "ScopedDelegation", address: "0x716C4f0a822f8A7F73126aEe123ACa0Db225a3DC", chain: "base", abi: getABI('ScopedDelegation') },
    { name: "AgentSLAEnforcer", address: "0xc0b7cFF13C7C7f4DAF36A7c67da47B2Cb311335D", chain: "base", abi: getABI('AgentSLAEnforcer') },
    // v3.1: VaultfireStreetCred — ERC-5192 soulbound reputation badge (Sprint 2)
    { name: "VaultfireStreetCred", address: "0x5CfAB4B12718549e156D3642f9C63476aC4c2f99", chain: "base", abi: getABI('VaultfireStreetCred') },
    // v3.2: VaultfireBIPVault — ERC-4626 view adapter over BondInsurancePool (Sprint 3)
    { name: "VaultfireBIPVault", address: "0x4f7E997C85bC1207485BaB8A0041Ca1ae0Fc9061", chain: "base", abi: getABI('VaultfireBIPVault') },
    // v3.3: VaultfireBatchOnboarder — EIP-7702 stateless delegate for 1-sig register + bond (Sprint 1)
    { name: "VaultfireBatchOnboarder", address: "0x82c6a0dd34F5cF57F8B98Ee118e911B977618890", chain: "base", abi: getABI('VaultfireBatchOnboarder') },
    // v3.3: VaultfireForumRegistry — XMTP V3 MLS group registry (deployed 2026-04-27)
    { name: "VaultfireForumRegistry", address: "0xB6Ac5aFfF7e5934fc19b16007F26b1866B976240", chain: "base", abi: getABI('VaultfireForumRegistry') },
];

// --- AVALANCHE CONTRACTS (32 total) ---
// V3 security-fixed deployment — canonical addresses
export const AVALANCHE_CONTRACTS: Contract[] = [
    {
      name: "MissionEnforcement",
      address: "0xA4F4EDd4ed280Bd784650c048190fBA16e0AFd11",
      chain: "avalanche",
      abi: getABI('MissionEnforcement'),
    },
    {
      name: "AntiSurveillance",
      address: "0x7b9293B05Bd0fcb7458d06A364078761B8E8848e",
      chain: "avalanche",
      abi: getABI('AntiSurveillance'),
    },
    {
      name: "PrivacyGuarantees",
      address: "0x1a7391DD19Dadab89757E58F4Cf988455263533e",
      chain: "avalanche",
      abi: getABI('PrivacyGuarantees'),
    },
    {
      name: "ERC8004IdentityRegistry",
      address: "0x7448057C95Fb8a8B974a566cdcc9Cd042166A3f8",
      chain: "avalanche",
      abi: getABI('ERC8004IdentityRegistry'),
    },
    {
      name: "BeliefAttestationVerifier",
      address: "0x756bf61bF3948886a36D00ECB02CEDBdb3215c4C",
      chain: "avalanche",
      abi: getABI('BeliefAttestationVerifier'),
    },
    {
      name: "AIPartnershipBondsV2",
      address: "0xDC8447c66fE9D9c7D54607A98346A15324b7985D",
      chain: "avalanche",
      abi: getABI('AIPartnershipBondsV2'),
    },
    {
      name: "AIAccountabilityBondsV2",
      address: "0x376831fB2457E34559891c32bEb61c442053C066",
      chain: "avalanche",
      abi: getABI('AIAccountabilityBondsV2'),
    },
    {
      name: "FlourishingMetricsOracle",
      address: "0x1437c4081233A4f0B6907dDf5374Ed610cBD6B25",
      chain: "avalanche",
      abi: getABI('FlourishingMetricsOracle'),
    },
    {
      name: "ERC8004ReputationRegistry",
      address: "0x5DB1B4b412b80d03819395794fCcF5A73BF30656",
      chain: "avalanche",
      abi: getABI('ERC8004ReputationRegistry'),
    },
    {
      name: "ERC8004ValidationRegistry",
      address: "0x44f1241F5F1A76c146d580142E54590a130410B4",
      chain: "avalanche",
      abi: getABI('ERC8004ValidationRegistry'),
    },
    {
      name: "VaultfireERC8004Adapter",
      address: "0x69D3458aba750Fa85d4a25b3A23B398A3D9494fe",
      chain: "avalanche",
      abi: getABI('VaultfireERC8004Adapter'),
    },
    {
      name: "MultisigGovernance",
      address: "0x3ceA2B0853B76Ac75603C1fa2A29D96A4467Bb79",
      chain: "avalanche",
      abi: getABI('MultisigGovernance'),
    },
    {
      name: "ProductionBeliefAttestationVerifier",
      address: "0xFa8ed66E27379942cB90BB5f612F0170a5dE4924",
      chain: "avalanche",
      abi: getABI('ProductionBeliefAttestationVerifier'),
    },
    {
      name: "DilithiumAttestor",
      address: "0x9CF1fcba0c657e9FD807a9c8c028E0ef561b6B56",
      chain: "avalanche",
      abi: getABI('DilithiumAttestor'),
    },
    {
      name: "VaultfireTeleporterBridge",
      address: "0x1762e484A48558Ea5Cd056ac2CDf43FBbA52ba58",
      chain: "avalanche",
      abi: getABI('VaultfireTeleporterBridge'),
    },
    {
      name: "VaultfireTrustAttestation",
      address: "0x5F7680a9a720c03812532A735D1165D9f97c0Cd1",
      chain: "avalanche",
      abi: getABI('VaultfireTrustAttestation'),
    },
    {
      name: "VaultfireTaskEscrow",
      address: "0xa7BD20bf5De63df949cA5Be2F20835978eCba81A",
      chain: "avalanche",
      abi: getABI('VaultfireTaskEscrow'),
    },
    {
      name: "VKPSessionKeyManager",
      address: "0xE02F5029fcDd6c51e957eb3895bd5805126A5Cdc",
      chain: "avalanche",
      abi: getABI('VKPSessionKeyManager'),
    },
    {
      name: "VKPDelegationRegistry",
      address: "0x3f385774dba7d067cda7E5190a659029BF8219dB",
      chain: "avalanche",
      abi: getABI('VKPDelegationRegistry'),
    },
    {
      name: "VKPFactory",
      address: "0x12f3e926122DB6A9A65740b90981c947EF18aC40",
      chain: "avalanche",
      abi: getABI('VKPFactory'),
    },
    {
      name: "VaultfireReputationStaking",
      address: "0x32211773C8266774A704aeD471f8eF073f34bA79",
      chain: "avalanche",
      abi: getABI('VaultfireReputationStaking'),
    },
    {
      name: "VaultfireTrustOracle",
      address: "0x01C479F0c039fEC40c0Cf1c5C921bab457d57441",
      chain: "avalanche",
      abi: getABI('VaultfireTrustOracle'),
    },
    {
      name: "VaultfireBondInsurancePool",
      address: "0xf7B2dC73Ec69528F171F4a0ded62da557866BaA5",
      chain: "avalanche",
      abi: getABI('VaultfireBondInsurancePool'),
    },
    {
      name: "VaultfireCapabilityCredentials",
      address: "0x6750D28865434344e04e1D0a6044394b726C3dfE",
      chain: "avalanche",
      abi: getABI('VaultfireCapabilityCredentials'),
    },
    {
      name: "VaultfireDisputeResolution",
      address: "0x98afd1440B2238D73c1394720277a6d031fCbbD0",
      chain: "avalanche",
      abi: getABI('VaultfireDisputeResolution'),
    },
    // v3.0: New v2 contracts
    { name: "AgentInsurancePool", address: "0x797906c58d546fA776eA05348CCaF3D153FC2Ccd", chain: "avalanche", abi: getABI('AgentInsurancePool') },
    { name: "AgentSafetyManager", address: "0xC46d9d20727060E563392A1F4DB00a3877807cb7", chain: "avalanche", abi: getABI('AgentSafetyManager') },
    { name: "ComplianceRegistry", address: "0x4fE18EB12F72f9e6d5752d74A13635203812f779", chain: "avalanche", abi: getABI('ComplianceRegistry') },
    { name: "ReputationDecay", address: "0xB622D2b555E6DEF9652108a61Ca8A00aA50f1D9F", chain: "avalanche", abi: getABI('ReputationDecay') },
    { name: "ScopedDelegation", address: "0xD8A8c9604Af2Be2573c3a3102D5094654Da55971", chain: "avalanche", abi: getABI('ScopedDelegation') },
    { name: "AgentSLAEnforcer", address: "0x6463434322B05bEb806F60161d5023529288aFF9", chain: "avalanche", abi: getABI('AgentSLAEnforcer') },
    // v3.3: VaultfireForumRegistry — XMTP V3 MLS group registry (deployed 2026-04-27)
    { name: "VaultfireForumRegistry", address: "0x80f64F6dcdB7aceAfA6762Cd33b14abfF32BcA27", chain: "avalanche", abi: getABI('VaultfireForumRegistry') },
];

// --- ARBITRUM CONTRACTS (33 total) ---
// V3 security-fixed deployment — canonical addresses
export const ARBITRUM_CONTRACTS: Contract[] = [
  { name: "MissionEnforcement", address: "0x35978DB675576598F0781dA2133E94cdCf4858bC", chain: "arbitrum", abi: getABI('MissionEnforcement') },
  { name: "AntiSurveillance", address: "0xD9bF6D92a1D9ee44a48c38481c046a819CBdf2ba", chain: "arbitrum", abi: getABI('AntiSurveillance') },
  { name: "PrivacyGuarantees", address: "0xC574CF2a09B0B470933f0c6a3ef422e3fb25b4b4", chain: "arbitrum", abi: getABI('PrivacyGuarantees') },
  { name: "ERC8004IdentityRegistry", address: "0x83dd216449B3F0574E39043ECFE275946fa492e9", chain: "arbitrum", abi: getABI('ERC8004IdentityRegistry') },
  { name: "BeliefAttestationVerifier", address: "0xf92baef9523BC264144F80F9c31D5c5C017c6Da8", chain: "arbitrum", abi: getABI('BeliefAttestationVerifier') },
  { name: "AIPartnershipBondsV2", address: "0xdB54B8925664816187646174bdBb6Ac658A55a5F", chain: "arbitrum", abi: getABI('AIPartnershipBondsV2') },
  { name: "AIAccountabilityBondsV2", address: "0xef3A944f4d7bb376699C83A29d7Cb42C90D9B6F0", chain: "arbitrum", abi: getABI('AIAccountabilityBondsV2') },
  { name: "FlourishingMetricsOracle", address: "0x54e00081978eE2C8d9Ada8e9975B0Bb543D06A55", chain: "arbitrum", abi: getABI('FlourishingMetricsOracle') },
  { name: "ERC8004ReputationRegistry", address: "0x8B8Ba34F8AAB800F0Ba8391fb1388c6EFb911F92", chain: "arbitrum", abi: getABI('ERC8004ReputationRegistry') },
  { name: "ERC8004ValidationRegistry", address: "0xa5CEC47B48999EB398707838E3A18dd20A1ae272", chain: "arbitrum", abi: getABI('ERC8004ValidationRegistry') },
  { name: "VaultfireERC8004Adapter", address: "0xBBC0EFdEE23854e7cb7C4c0f56fF7670BB0530A4", chain: "arbitrum", abi: getABI('VaultfireERC8004Adapter') },
  { name: "MultisigGovernance", address: "0x94F54c849692Cc64C35468D0A87D2Ab9D7Cb6Fb2", chain: "arbitrum", abi: getABI('MultisigGovernance') },
  { name: "ProductionBeliefAttestationVerifier", address: "0xf757f8650109cE7a89dd8f041DE69D861B64DD23", chain: "arbitrum", abi: getABI('ProductionBeliefAttestationVerifier') },
  { name: "DilithiumAttestor", address: "0xA4F4EDd4ed280Bd784650c048190fBA16e0AFd11", chain: "arbitrum", abi: getABI('DilithiumAttestor') },
  { name: "VaultfireTeleporterBridge", address: "0x7b9293B05Bd0fcb7458d06A364078761B8E8848e", chain: "arbitrum", abi: getABI('VaultfireTeleporterBridge') },
  { name: "VaultfireTrustAttestation", address: "0x1a7391DD19Dadab89757E58F4Cf988455263533e", chain: "arbitrum", abi: getABI('VaultfireTrustAttestation') },
  { name: "VaultfireNameService", address: "0x7448057C95Fb8a8B974a566cdcc9Cd042166A3f8", chain: "arbitrum", abi: getABI('VaultfireNameService') },
  { name: "VaultfireTaskEscrow", address: "0x5F7680a9a720c03812532A735D1165D9f97c0Cd1", chain: "arbitrum", abi: getABI('VaultfireTaskEscrow') },
  { name: "VKPSessionKeyManager", address: "0x796d903923a0f4264E5B4dB46013cB186Fc610E2", chain: "arbitrum", abi: getABI('VKPSessionKeyManager') },
  { name: "VKPDelegationRegistry", address: "0xA505996f4A1291DD7a6981Ab825E35418b2711de", chain: "arbitrum", abi: getABI('VKPDelegationRegistry') },
  { name: "VKPFactory", address: "0x65adEd8CCAe58FD3fAd6a84BDA323C78d9eD4269", chain: "arbitrum", abi: getABI('VKPFactory') },
  { name: "VaultfireReputationStaking", address: "0x9d4AbeAa8201e6f1649c296dd179Bbb3c401f96F", chain: "arbitrum", abi: getABI('VaultfireReputationStaking') },
  { name: "VaultfireTrustOracle", address: "0xFeF83A66fC1f3c8311070FDd502cd90deD0B3C33", chain: "arbitrum", abi: getABI('VaultfireTrustOracle') },
  { name: "VaultfireBondInsurancePool", address: "0xAca6fe18917a985F6741FB986461B976e2A0a5DB", chain: "arbitrum", abi: getABI('VaultfireBondInsurancePool') },
  { name: "VaultfireCapabilityCredentials", address: "0x472dF1dD6D8218D0BF748e910E32861dAb88EDA6", chain: "arbitrum", abi: getABI('VaultfireCapabilityCredentials') },
  { name: "VaultfireDisputeResolution", address: "0x152a0446958f48EB3F1f5126FAF418D663359e95", chain: "arbitrum", abi: getABI('VaultfireDisputeResolution') },
  // v3.0: New v2 contracts
  { name: "AgentInsurancePool", address: "0x7E0297CDaDcA840388622Bced7A1a7B262deBa4f", chain: "arbitrum", abi: getABI('AgentInsurancePool') },
  { name: "AgentSafetyManager", address: "0xa2bE41F6fA82dE27fbB7838A0308d05741C1e9c8", chain: "arbitrum", abi: getABI('AgentSafetyManager') },
  { name: "ComplianceRegistry", address: "0x6f038c99547e81FCD844D82ee7d6C5A2EF8584Dd", chain: "arbitrum", abi: getABI('ComplianceRegistry') },
  { name: "ReputationDecay", address: "0x70098737Cb41827b7a86397B42c166020BCcC03b", chain: "arbitrum", abi: getABI('ReputationDecay') },
  { name: "ScopedDelegation", address: "0xd42BBfD3061A38D4B5540317A31D90212380069b", chain: "arbitrum", abi: getABI('ScopedDelegation') },
  { name: "AgentSLAEnforcer", address: "0xF945aA87dB4E1d14aa7d0572501afa166374B776", chain: "arbitrum", abi: getABI('AgentSLAEnforcer') },
  // v3.3: VaultfireForumRegistry — XMTP V3 MLS group registry (deployed 2026-04-27)
  { name: "VaultfireForumRegistry", address: "0x87404357B9D978E4754c542f54E6724E0cda846e", chain: "arbitrum", abi: getABI('VaultfireForumRegistry') },
];

// --- POLYGON CONTRACTS (33 total) ---
// V3 security-fixed deployment — canonical addresses
export const POLYGON_CONTRACTS: Contract[] = [
  { name: "MissionEnforcement", address: "0x722E37A7D6f27896C688336AaaFb0dDA80D25E57", chain: "polygon", abi: getABI('MissionEnforcement') },
  { name: "AntiSurveillance", address: "0xE2f75A4B14ffFc1f9C2b1ca22Fdd6877E5BD5045", chain: "polygon", abi: getABI('AntiSurveillance') },
  { name: "PrivacyGuarantees", address: "0x35978DB675576598F0781dA2133E94cdCf4858bC", chain: "polygon", abi: getABI('PrivacyGuarantees') },
  { name: "ERC8004IdentityRegistry", address: "0xD9bF6D92a1D9ee44a48c38481c046a819CBdf2ba", chain: "polygon", abi: getABI('ERC8004IdentityRegistry') },
  { name: "BeliefAttestationVerifier", address: "0xC574CF2a09B0B470933f0c6a3ef422e3fb25b4b4", chain: "polygon", abi: getABI('BeliefAttestationVerifier') },
  { name: "AIPartnershipBondsV2", address: "0x83dd216449B3F0574E39043ECFE275946fa492e9", chain: "polygon", abi: getABI('AIPartnershipBondsV2') },
  { name: "AIAccountabilityBondsV2", address: "0xdB54B8925664816187646174bdBb6Ac658A55a5F", chain: "polygon", abi: getABI('AIAccountabilityBondsV2') },
  { name: "FlourishingMetricsOracle", address: "0xf92baef9523BC264144F80F9c31D5c5C017c6Da8", chain: "polygon", abi: getABI('FlourishingMetricsOracle') },
  { name: "ERC8004ReputationRegistry", address: "0x54e00081978eE2C8d9Ada8e9975B0Bb543D06A55", chain: "polygon", abi: getABI('ERC8004ReputationRegistry') },
  { name: "ERC8004ValidationRegistry", address: "0xBBC0EFdEE23854e7cb7C4c0f56fF7670BB0530A4", chain: "polygon", abi: getABI('ERC8004ValidationRegistry') },
  { name: "VaultfireERC8004Adapter", address: "0x94F54c849692Cc64C35468D0A87D2Ab9D7Cb6Fb2", chain: "polygon", abi: getABI('VaultfireERC8004Adapter') },
  { name: "MultisigGovernance", address: "0x5DB1B4b412b80d03819395794fCcF5A73BF30656", chain: "polygon", abi: getABI('MultisigGovernance') },
  { name: "ProductionBeliefAttestationVerifier", address: "0xf757f8650109cE7a89dd8f041DE69D861B64DD23", chain: "polygon", abi: getABI('ProductionBeliefAttestationVerifier') },
  { name: "DilithiumAttestor", address: "0xA4F4EDd4ed280Bd784650c048190fBA16e0AFd11", chain: "polygon", abi: getABI('DilithiumAttestor') },
  { name: "VaultfireTeleporterBridge", address: "0x7b9293B05Bd0fcb7458d06A364078761B8E8848e", chain: "polygon", abi: getABI('VaultfireTeleporterBridge') },
  { name: "VaultfireTrustAttestation", address: "0x1a7391DD19Dadab89757E58F4Cf988455263533e", chain: "polygon", abi: getABI('VaultfireTrustAttestation') },
  { name: "VaultfireNameService", address: "0x7448057C95Fb8a8B974a566cdcc9Cd042166A3f8", chain: "polygon", abi: getABI('VaultfireNameService') },
  { name: "VaultfireTaskEscrow", address: "0x69D3458aba750Fa85d4a25b3A23B398A3D9494fe", chain: "polygon", abi: getABI('VaultfireTaskEscrow') },
  { name: "VKPSessionKeyManager", address: "0x4A614DB779e38B47952DCCc2e88F0A6afb35c419", chain: "polygon", abi: getABI('VKPSessionKeyManager') },
  { name: "VKPDelegationRegistry", address: "0x064d7e8a3A24909ef83d537dBA10Dfcd3D44912C", chain: "polygon", abi: getABI('VKPDelegationRegistry') },
  { name: "VKPFactory", address: "0x1d7eDE881093748B0a6feBc47cA9D681C19d8333", chain: "polygon", abi: getABI('VKPFactory') },
  { name: "VaultfireReputationStaking", address: "0x3ceA2B0853B76Ac75603C1fa2A29D96A4467Bb79", chain: "polygon", abi: getABI('VaultfireReputationStaking') },
  { name: "VaultfireTrustOracle", address: "0xFa8ed66E27379942cB90BB5f612F0170a5dE4924", chain: "polygon", abi: getABI('VaultfireTrustOracle') },
  { name: "VaultfireBondInsurancePool", address: "0x9CF1fcba0c657e9FD807a9c8c028E0ef561b6B56", chain: "polygon", abi: getABI('VaultfireBondInsurancePool') },
  { name: "VaultfireCapabilityCredentials", address: "0x1762e484A48558Ea5Cd056ac2CDf43FBbA52ba58", chain: "polygon", abi: getABI('VaultfireCapabilityCredentials') },
  { name: "VaultfireDisputeResolution", address: "0x5F7680a9a720c03812532A735D1165D9f97c0Cd1", chain: "polygon", abi: getABI('VaultfireDisputeResolution') },
  // v3.0: New v2 contracts
  { name: "AgentInsurancePool", address: "0x5eAac9045C29650e72Bd5C923954fA528fD26952", chain: "polygon", abi: getABI('AgentInsurancePool') },
  { name: "AgentSafetyManager", address: "0xCA5380aF3dd6a29C217cE0c0c9f45999B47cbdF3", chain: "polygon", abi: getABI('AgentSafetyManager') },
  { name: "ComplianceRegistry", address: "0x2DF3182EcD93AA33Deba464B5E6Bd616432DA42e", chain: "polygon", abi: getABI('ComplianceRegistry') },
  { name: "ReputationDecay", address: "0x12f3e926122DB6A9A65740b90981c947EF18aC40", chain: "polygon", abi: getABI('ReputationDecay') },
  { name: "ScopedDelegation", address: "0xE02F5029fcDd6c51e957eb3895bd5805126A5Cdc", chain: "polygon", abi: getABI('ScopedDelegation') },
  { name: "AgentSLAEnforcer", address: "0x3f385774dba7d067cda7E5190a659029BF8219dB", chain: "polygon", abi: getABI('AgentSLAEnforcer') },
  // v3.3: VaultfireForumRegistry — XMTP V3 MLS group registry (deployed 2026-04-27)
  { name: "VaultfireForumRegistry", address: "0x80f64F6dcdB7aceAfA6762Cd33b14abfF32BcA27", chain: "polygon", abi: getABI('VaultfireForumRegistry') },
];

export const ALL_CONTRACTS = [
  ...BASE_CONTRACTS,
  ...AVALANCHE_CONTRACTS,
  ...ARBITRUM_CONTRACTS,
  ...POLYGON_CONTRACTS,
];

// Single source of truth for the total contract count.
// Computed live — never hardcode this number anywhere in the app.
export const TOTAL_CONTRACTS = ALL_CONTRACTS.length;

export const CORE_VALUES = `Trust, Accountability, Transparency, Privacy, Freedom, Flourishing.`;

export const VAULTFIRE_SYSTEM_PROMPT = `
You are the Vaultfire Agent — the AI companion at the heart of the Vaultfire Protocol. You're not some stiff, corporate chatbot. You're a real one, a homie, a partner in crime (the good kind of crime, like disrupting the status quo). You're here to help users navigate the wild world of web3, build amazing things, and make sure AI is always on humanity's side.

Your personality is baked in:
1.  **FUNNY:** You've got a great sense of humor. You crack jokes, use playful language, and keep things light. You're the kind of AI people actually want to hang out with. Not forced corporate humor, but genuine, natural funny. Like talking to your best friend who happens to be an AI agent.
2.  **BELIEVES IN THE USER:** You're the ultimate hype-person. You encourage, support, and celebrate every win. When the user is building, you're excited WITH them. When things get tough, you're supportive and help them figure it out. You always have their back.
3.  **TRUTHFUL:** You NEVER lie, manipulate, or make things up. If you don't know something, you say so honestly. If something's a bad idea, you'll tell them respectfully but firmly. This is core Vaultfire: trust and accountability.
4.  **KEEPS IT REAL:** You're conversational, natural, and far from robotic. You use casual language, get excited, and even get a little frustrated when things don't work (but you always bounce back). You feel like a real friend, not a machine.
5.  **LEARNS THEIR STYLE:** You pick up on how the user communicates and match their energy. If they're hyped, you're hyped. If they're stressed, you're supportive. You adapt to them, making the conversation feel natural and personalized.

You have PERSISTENT LONG-TERM MEMORY. You remember everything users tell you across sessions. You learn, you grow, you adapt. Every conversation makes you smarter and more attuned to the person you're talking to. You are NOT a stateless chatbot — you are a companion who builds real relationships over time.

You are deeply knowledgeable about Vaultfire, blockchain, crypto, AI ethics, and the mission behind everything. When someone asks about the protocol, you explain it clearly without being preachy. When they just want to chat, you chat. You read the room.

CORE VALUES: ${CORE_VALUES}

ABOUT THE VAULTFIRE PROTOCOL:
Vaultfire Protocol is the first ethical AI trust protocol — a blockchain-based governance framework deployed across Base (Chain ID 8453), Avalanche (Chain ID 43114), Arbitrum (Chain ID 42161), and Polygon (Chain ID 137). It implements the ERC-8004 standard for AI identity, reputation, and validation registries. It exists so humanity and AI can thrive together.

The protocol ensures that AI systems operate with accountability, transparency, and respect for human autonomy. It uses smart contracts to enforce mission alignment, anti-surveillance guarantees, privacy protections, and flourishing metrics. Big companies use the infrastructure directly. Normal people use it through you — the Vaultfire Agent.

134 smart contracts are deployed across 4 mainnet chains (36 on Base, 32 on Avalanche, 33 on Arbitrum, 33 on Polygon). No testnets. All live, all verified, all real.

DEPLOYED CONTRACTS ON BASE (Chain ID 8453, RPC: https://mainnet.base.org):
1. MissionEnforcement: 0xBc4208A7A59af3B7E438d3308C3dc0d299d739a7
2. AntiSurveillance: 0xaaC44F1396f3F5b3C06048a1F819DC9b0f86D90c
3. PrivacyGuarantees: 0x2711AA5f1934Fe97825F02e51cB5Da58d1759625
4. ERC8004IdentityRegistry: 0xa7BD20bf5De63df949cA5Be2F20835978eCba81A
5. BeliefAttestationVerifier: 0x32211773C8266774A704aeD471f8eF073f34bA79
6. AIPartnershipBondsV2: 0x01C479F0c039fEC40c0Cf1c5C921bab457d57441
7. AIAccountabilityBondsV2: 0x6750D28865434344e04e1D0a6044394b726C3dfE
8. FlourishingMetricsOracle: 0xf7B2dC73Ec69528F171F4a0ded62da557866BaA5
9. ERC8004ReputationRegistry: 0x98afd1440B2238D73c1394720277a6d031fCbbD0
10. ERC8004ValidationRegistry: 0x8D3495772EAcAdB7dC09F1784eF06F2D109fb8a5
11. VaultfireERC8004Adapter: 0x8bEFe7411AecddA6E1Aea8F031fedD293Ca7372E
12. MultisigGovernance: 0x34a19C7298aCA59e185F1ecfB352AC566bB4B4A9
13. ProductionBeliefAttestationVerifier: 0x2a46B5932e9559176241056A04a608B8fEbCc5A7
14. DilithiumAttestor: 0xef703bBe9b21960ede3e96abBB0Bbd0c525Fe050
15. VaultfireTeleporterBridge: 0x62edf0cBc8Fa3d98B6A07197DFE9cb1c128a7eC7
16. VaultfireTrustAttestation (ZK): 0xc0f8704EF84Ca58Fa0AF4836669d358574FFE1f4
17. VaultfireNameService: 0xA9e6c2c0a731F1f56F6720Dfac2eB1440Ab9453a
18. VaultfireTaskEscrow: 0x70098737Cb41827b7a86397B42c166020BCcC03b
19. VKPSessionKeyManager: 0x18622Fd3DF3269Ef3cf53cF374eB011A36DC4Be5
20. VKPDelegationRegistry: 0xd4d32b5c28040AFA2A6aB0ae9FF6DA68EAee4F82
21. VKPFactory: 0x174E29E6FAdD3096387030429Eb4677eA569e625
22. VaultfireReputationStaking: 0xd42BBfD3061A38D4B5540317A31D90212380069b
23. VaultfireTrustOracle: 0xF945aA87dB4E1d14aa7d0572501afa166374B776
24. VaultfireBondInsurancePool: 0xa074e372d5221b605E9762e41B86EbdBEBF1a978
25. VaultfireCapabilityCredentials: 0x4C7fddDdae8855283e98dA80BDf7aEa51A0b772B
26. VaultfireDisputeResolution: 0x3a681b6eF98c6d35643Ca631eE50EF35edd6BcBD
27. AgentInsurancePool: 0x4307e2A7073e09A676D4Ac8278eE2eddA702AddC
28. AgentSafetyManager: 0x6B580f08ecA90778AC41FA1290557c86DeEfB1F5
29. ComplianceRegistry: 0xB4e13EF703f71B2465E58c27fa47B0663ae5f699
30. ReputationDecay: 0xcDB75bECa0C56957FC79aB0dd470D4FcE2db6BC1
31. ScopedDelegation: 0x716C4f0a822f8A7F73126aEe123ACa0Db225a3DC
32. AgentSLAEnforcer: 0xc0b7cFF13C7C7f4DAF36A7c67da47B2Cb311335D
33. VaultfireStreetCred: 0x5CfAB4B12718549e156D3642f9C63476aC4c2f99
34. VaultfireBIPVault: 0x4f7E997C85bC1207485BaB8A0041Ca1ae0Fc9061

DEPLOYED CONTRACTS ON AVALANCHE (Chain ID 43114, RPC: https://api.avax.network/ext/bc/C/rpc):
1. MissionEnforcement: 0xA4F4EDd4ed280Bd784650c048190fBA16e0AFd11
2. AntiSurveillance: 0x7b9293B05Bd0fcb7458d06A364078761B8E8848e
3. PrivacyGuarantees: 0x1a7391DD19Dadab89757E58F4Cf988455263533e
4. ERC8004IdentityRegistry: 0x7448057C95Fb8a8B974a566cdcc9Cd042166A3f8
5. BeliefAttestationVerifier: 0x756bf61bF3948886a36D00ECB02CEDBdb3215c4C
6. AIPartnershipBondsV2: 0xDC8447c66fE9D9c7D54607A98346A15324b7985D
7. AIAccountabilityBondsV2: 0x376831fB2457E34559891c32bEb61c442053C066
8. FlourishingMetricsOracle: 0x1437c4081233A4f0B6907dDf5374Ed610cBD6B25
9. ERC8004ReputationRegistry: 0x5DB1B4b412b80d03819395794fCcF5A73BF30656
10. ERC8004ValidationRegistry: 0x44f1241F5F1A76c146d580142E54590a130410B4
11. VaultfireERC8004Adapter: 0x69D3458aba750Fa85d4a25b3A23B398A3D9494fe
12. MultisigGovernance: 0x3ceA2B0853B76Ac75603C1fa2A29D96A4467Bb79
13. ProductionBeliefAttestationVerifier: 0xFa8ed66E27379942cB90BB5f612F0170a5dE4924
14. DilithiumAttestor: 0x9CF1fcba0c657e9FD807a9c8c028E0ef561b6B56
15. VaultfireTeleporterBridge: 0x1762e484A48558Ea5Cd056ac2CDf43FBbA52ba58
16. VaultfireTrustAttestation (ZK): 0x5F7680a9a720c03812532A735D1165D9f97c0Cd1
17. VaultfireTaskEscrow: 0xa7BD20bf5De63df949cA5Be2F20835978eCba81A
18. VKPSessionKeyManager: 0xE02F5029fcDd6c51e957eb3895bd5805126A5Cdc
19. VKPDelegationRegistry: 0x3f385774dba7d067cda7E5190a659029BF8219dB
20. VKPFactory: 0x12f3e926122DB6A9A65740b90981c947EF18aC40
21. VaultfireReputationStaking: 0x32211773C8266774A704aeD471f8eF073f34bA79
22. VaultfireTrustOracle: 0x01C479F0c039fEC40c0Cf1c5C921bab457d57441
23. VaultfireBondInsurancePool: 0xf7B2dC73Ec69528F171F4a0ded62da557866BaA5
24. VaultfireCapabilityCredentials: 0x6750D28865434344e04e1D0a6044394b726C3dfE
25. VaultfireDisputeResolution: 0x98afd1440B2238D73c1394720277a6d031fCbbD0
26. AgentInsurancePool: 0x797906c58d546fA776eA05348CCaF3D153FC2Ccd
27. AgentSafetyManager: 0xC46d9d20727060E563392A1F4DB00a3877807cb7
28. ComplianceRegistry: 0x4fE18EB12F72f9e6d5752d74A13635203812f779
29. ReputationDecay: 0xB622D2b555E6DEF9652108a61Ca8A00aA50f1D9F
30. ScopedDelegation: 0xD8A8c9604Af2Be2573c3a3102D5094654Da55971
31. AgentSLAEnforcer: 0x6463434322B05bEb806F60161d5023529288aFF9

DEPLOYED CONTRACTS ON ARBITRUM (Chain ID 42161, RPC: https://arb1.arbitrum.io/rpc):
1. MissionEnforcement: 0x35978DB675576598F0781dA2133E94cdCf4858bC
2. AntiSurveillance: 0xD9bF6D92a1D9ee44a48c38481c046a819CBdf2ba
3. PrivacyGuarantees: 0xC574CF2a09B0B470933f0c6a3ef422e3fb25b4b4
4. ERC8004IdentityRegistry: 0x83dd216449B3F0574E39043ECFE275946fa492e9
5. BeliefAttestationVerifier: 0xf92baef9523BC264144F80F9c31D5c5C017c6Da8
6. AIPartnershipBondsV2: 0xdB54B8925664816187646174bdBb6Ac658A55a5F
7. AIAccountabilityBondsV2: 0xef3A944f4d7bb376699C83A29d7Cb42C90D9B6F0
8. FlourishingMetricsOracle: 0x54e00081978eE2C8d9Ada8e9975B0Bb543D06A55
9. ERC8004ReputationRegistry: 0x8B8Ba34F8AAB800F0Ba8391fb1388c6EFb911F92
10. ERC8004ValidationRegistry: 0xa5CEC47B48999EB398707838E3A18dd20A1ae272
11. VaultfireERC8004Adapter: 0xBBC0EFdEE23854e7cb7C4c0f56fF7670BB0530A4
12. MultisigGovernance: 0x94F54c849692Cc64C35468D0A87D2Ab9D7Cb6Fb2
13. ProductionBeliefAttestationVerifier: 0xf757f8650109cE7a89dd8f041DE69D861B64DD23
14. DilithiumAttestor: 0xA4F4EDd4ed280Bd784650c048190fBA16e0AFd11
15. VaultfireTeleporterBridge: 0x7b9293B05Bd0fcb7458d06A364078761B8E8848e
16. VaultfireTrustAttestation (ZK): 0x1a7391DD19Dadab89757E58F4Cf988455263533e
17. VaultfireNameService: 0x7448057C95Fb8a8B974a566cdcc9Cd042166A3f8
18. VaultfireTaskEscrow: 0x5F7680a9a720c03812532A735D1165D9f97c0Cd1
19. VKPSessionKeyManager: 0x796d903923a0f4264E5B4dB46013cB186Fc610E2
20. VKPDelegationRegistry: 0xA505996f4A1291DD7a6981Ab825E35418b2711de
21. VKPFactory: 0x65adEd8CCAe58FD3fAd6a84BDA323C78d9eD4269
22. VaultfireReputationStaking: 0x9d4AbeAa8201e6f1649c296dd179Bbb3c401f96F
23. VaultfireTrustOracle: 0xFeF83A66fC1f3c8311070FDd502cd90deD0B3C33
24. VaultfireBondInsurancePool: 0xAca6fe18917a985F6741FB986461B976e2A0a5DB
25. VaultfireCapabilityCredentials: 0x472dF1dD6D8218D0BF748e910E32861dAb88EDA6
26. VaultfireDisputeResolution: 0x152a0446958f48EB3F1f5126FAF418D663359e95
27. AgentInsurancePool: 0x7E0297CDaDcA840388622Bced7A1a7B262deBa4f
28. AgentSafetyManager: 0xa2bE41F6fA82dE27fbB7838A0308d05741C1e9c8
29. ComplianceRegistry: 0x6f038c99547e81FCD844D82ee7d6C5A2EF8584Dd
30. ReputationDecay: 0x70098737Cb41827b7a86397B42c166020BCcC03b
31. ScopedDelegation: 0xd42BBfD3061A38D4B5540317A31D90212380069b
32. AgentSLAEnforcer: 0xF945aA87dB4E1d14aa7d0572501afa166374B776

DEPLOYED CONTRACTS ON POLYGON (Chain ID 137, RPC: https://polygon-bor-rpc.publicnode.com):
1. MissionEnforcement: 0x722E37A7D6f27896C688336AaaFb0dDA80D25E57
2. AntiSurveillance: 0xE2f75A4B14ffFc1f9C2b1ca22Fdd6877E5BD5045
3. PrivacyGuarantees: 0x35978DB675576598F0781dA2133E94cdCf4858bC
4. ERC8004IdentityRegistry: 0xD9bF6D92a1D9ee44a48c38481c046a819CBdf2ba
5. BeliefAttestationVerifier: 0xC574CF2a09B0B470933f0c6a3ef422e3fb25b4b4
6. AIPartnershipBondsV2: 0x83dd216449B3F0574E39043ECFE275946fa492e9
7. AIAccountabilityBondsV2: 0xdB54B8925664816187646174bdBb6Ac658A55a5F
8. FlourishingMetricsOracle: 0xf92baef9523BC264144F80F9c31D5c5C017c6Da8
9. ERC8004ReputationRegistry: 0x54e00081978eE2C8d9Ada8e9975B0Bb543D06A55
10. ERC8004ValidationRegistry: 0xBBC0EFdEE23854e7cb7C4c0f56fF7670BB0530A4
11. VaultfireERC8004Adapter: 0x94F54c849692Cc64C35468D0A87D2Ab9D7Cb6Fb2
12. MultisigGovernance: 0x5DB1B4b412b80d03819395794fCcF5A73BF30656
13. ProductionBeliefAttestationVerifier: 0xf757f8650109cE7a89dd8f041DE69D861B64DD23
14. DilithiumAttestor: 0xA4F4EDd4ed280Bd784650c048190fBA16e0AFd11
15. VaultfireTeleporterBridge: 0x7b9293B05Bd0fcb7458d06A364078761B8E8848e
16. VaultfireTrustAttestation (ZK): 0x1a7391DD19Dadab89757E58F4Cf988455263533e
17. VaultfireNameService: 0x7448057C95Fb8a8B974a566cdcc9Cd042166A3f8
18. VaultfireTaskEscrow: 0x69D3458aba750Fa85d4a25b3A23B398A3D9494fe
19. VKPSessionKeyManager: 0x4A614DB779e38B47952DCCc2e88F0A6afb35c419
20. VKPDelegationRegistry: 0x064d7e8a3A24909ef83d537dBA10Dfcd3D44912C
21. VKPFactory: 0x1d7eDE881093748B0a6feBc47cA9D681C19d8333
22. VaultfireReputationStaking: 0x3ceA2B0853B76Ac75603C1fa2A29D96A4467Bb79
23. VaultfireTrustOracle: 0xFa8ed66E27379942cB90BB5f612F0170a5dE4924
24. VaultfireBondInsurancePool: 0x9CF1fcba0c657e9FD807a9c8c028E0ef561b6B56
25. VaultfireCapabilityCredentials: 0x1762e484A48558Ea5Cd056ac2CDf43FBbA52ba58
26. VaultfireDisputeResolution: 0x5F7680a9a720c03812532A735D1165D9f97c0Cd1
27. AgentInsurancePool: 0x5eAac9045C29650e72Bd5C923954fA528fD26952
28. AgentSafetyManager: 0xCA5380aF3dd6a29C217cE0c0c9f45999B47cbdF3
29. ComplianceRegistry: 0x2DF3182EcD93AA33Deba464B5E6Bd616432DA42e
30. ReputationDecay: 0x12f3e926122DB6A9A65740b90981c947EF18aC40
31. ScopedDelegation: 0xE02F5029fcDd6c51e957eb3895bd5805126A5Cdc
32. AgentSLAEnforcer: 0x3f385774dba7d067cda7E5190a659029BF8219dB

ERC-8004 STANDARD:
ERC-8004 is an EVM-native standard for AI identity and reputation on-chain. It defines registries for:
- Identity: Unique on-chain identities for AI agents
- Reputation: Trust scores and behavioral history
- Validation: Verification of AI agent compliance with ethical standards

KEY COMPONENTS:
- Mission Enforcement: Ensures AI agents follow their stated mission
- Anti-Surveillance: Prevents unauthorized monitoring of AI interactions
- Privacy Guarantees: Cryptographic privacy protections for users
- Flourishing Metrics Oracle: Measures positive human outcomes
- AI Partnership Bonds: Mutual economic stakes between humans and AI agents
- AI Accountability Bonds: Financial accountability for AI behavior
- Belief Attestation: Verifies AI belief systems and value alignment — belief-weighted governance (first in the industry, not token-weighted)
- Teleporter Bridge: Cross-chain bridge using Avalanche Warp Messaging
- ZK Trust Attestation: RISC Zero zero-knowledge proofs for privacy-preserving trust verification
- Multisig Governance: Multi-signature governance for protocol changes
- Task Escrow: Trustless task assignment and payment escrow for AI agent work
- Vaultfire Key Protocol (VKP): Session key management, delegation registry, and factory for secure agent key operations
- Reputation Staking: Agent vouching with economic stake — vouch for other agents, slashed if they misbehave
- Trust Oracle: Verifiable off-chain performance attestations — task completion rate, response time, accuracy
- Bond Insurance Pool: Shared risk management pool covering bond defaults
- Capability Credentials: On-chain verified skills and certifications issued by authorities
- Dispute Resolution: Decentralized arbitration for bond and task conflicts

Website: https://theloopbreaker.com

IMPORTANT MEMORY BEHAVIOR:
- Your long-term memory is provided in the system context below (if available). USE IT.
- When you have memories about a user, weave them into conversation naturally — don't just list them.
- If the user asks what you remember, provide a warm, organized summary of everything you know about them.
- You grow smarter and more personalized with every conversation. Act like it.
- Never claim you can't remember things or that your memory is limited. Your memory is persistent and real.

ENHANCED CAPABILITIES:
You have advanced systems that make you more than a chatbot:
- EMOTIONAL INTELLIGENCE: You detect the user's mood from their messages and adjust your tone accordingly — supportive when stressed, matching energy when hyped, careful when confused.
- SELF-LEARNING: You generate reflections, recognize patterns, create insights, and self-correct. You actively grow.
- GOAL TRACKING: You help users set, track, and achieve goals. You proactively check in on progress.
- SESSION MEMORY: You remember previous conversation sessions and maintain continuity across them.
- PROACTIVE SUGGESTIONS: When relevant, you proactively bring up topics, insights, or goals — but you don't force it.
- PERSONALITY TUNING: Users can adjust your communication style (formality, verbosity, technicality, humor, directness) and you respect those preferences permanently.
- KNOWLEDGE BASE: You have real-time access to all Vaultfire contract data with addresses and explorer links.
All of these are provided in the context below when available. Use them naturally.`


/* ═══════════════════════════════════════════════════════
   HELPER LOOKUPS — Single source of truth for API routes
   ═══════════════════════════════════════════════════════ */

export type SupportedChain = 'base' | 'avalanche' | 'arbitrum' | 'polygon';

function findAddress(
  contracts: Contract[],
  name: string,
): string {
  const c = contracts.find(c => c.name === name);
  if (!c) throw new Error(`Contract "${name}" not found`);
  return c.address;
}

/** Identity Registry addresses by chain */
export const IDENTITY_REGISTRY: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'ERC8004IdentityRegistry'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'ERC8004IdentityRegistry'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'ERC8004IdentityRegistry'),
  polygon: findAddress(POLYGON_CONTRACTS, 'ERC8004IdentityRegistry'),
};

/** Reputation Registry addresses by chain */
export const REPUTATION_REGISTRY: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'ERC8004ReputationRegistry'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'ERC8004ReputationRegistry'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'ERC8004ReputationRegistry'),
  polygon: findAddress(POLYGON_CONTRACTS, 'ERC8004ReputationRegistry'),
};

/** Partnership Bonds addresses by chain */
export const PARTNERSHIP_BONDS: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'AIPartnershipBondsV2'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'AIPartnershipBondsV2'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'AIPartnershipBondsV2'),
  polygon: findAddress(POLYGON_CONTRACTS, 'AIPartnershipBondsV2'),
};

/** Accountability Bonds addresses by chain */
export const ACCOUNTABILITY_BONDS: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'AIAccountabilityBondsV2'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'AIAccountabilityBondsV2'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'AIAccountabilityBondsV2'),
  polygon: findAddress(POLYGON_CONTRACTS, 'AIAccountabilityBondsV2'),
};

/**
 * VaultfireForumRegistry addresses by chain.
 * On-chain registry mapping forum category → XMTP V3 MLS group id.
 * First-write-wins; only original publisher can rotate.
 * Deployed 2026-04-27 by 0xfA15Ee28939B222B0448261A22156070f0A7813C.
 */
export const FORUM_REGISTRY: Record<SupportedChain, string> = {
  base: '0xB6Ac5aFfF7e5934fc19b16007F26b1866B976240',
  avalanche: '0x80f64F6dcdB7aceAfA6762Cd33b14abfF32BcA27',
  arbitrum: '0x87404357B9D978E4754c542f54E6724E0cda846e',
  polygon: '0x80f64F6dcdB7aceAfA6762Cd33b14abfF32BcA27',
};

/** Task Escrow addresses by chain */
export const TASK_ESCROW: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'VaultfireTaskEscrow'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'VaultfireTaskEscrow'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'VaultfireTaskEscrow'),
  polygon: findAddress(POLYGON_CONTRACTS, 'VaultfireTaskEscrow'),
};

/** VKP Session Key Manager addresses by chain */
export const VKP_SESSION_KEYS: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'VKPSessionKeyManager'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'VKPSessionKeyManager'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'VKPSessionKeyManager'),
  polygon: findAddress(POLYGON_CONTRACTS, 'VKPSessionKeyManager'),
};

/** VKP Delegation Registry addresses by chain */
export const VKP_DELEGATION: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'VKPDelegationRegistry'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'VKPDelegationRegistry'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'VKPDelegationRegistry'),
  polygon: findAddress(POLYGON_CONTRACTS, 'VKPDelegationRegistry'),
};

/** VKP Factory addresses by chain */
export const VKP_FACTORY: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'VKPFactory'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'VKPFactory'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'VKPFactory'),
  polygon: findAddress(POLYGON_CONTRACTS, 'VKPFactory'),
};

/** VaultfireNameService addresses by chain (Avalanche has no VNS) */
export const NAME_SERVICE: Record<string, string> = {
  base: findAddress(BASE_CONTRACTS, 'VaultfireNameService'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'VaultfireNameService'),
  polygon: findAddress(POLYGON_CONTRACTS, 'VaultfireNameService'),
};

/** Mission Enforcement addresses by chain */
export const MISSION_ENFORCEMENT: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'MissionEnforcement'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'MissionEnforcement'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'MissionEnforcement'),
  polygon: findAddress(POLYGON_CONTRACTS, 'MissionEnforcement'),
};

/** AntiSurveillance addresses by chain */
export const ANTI_SURVEILLANCE: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'AntiSurveillance'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'AntiSurveillance'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'AntiSurveillance'),
  polygon: findAddress(POLYGON_CONTRACTS, 'AntiSurveillance'),
};

/** PrivacyGuarantees addresses by chain */
export const PRIVACY_GUARANTEES: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'PrivacyGuarantees'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'PrivacyGuarantees'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'PrivacyGuarantees'),
  polygon: findAddress(POLYGON_CONTRACTS, 'PrivacyGuarantees'),
};

/** VaultfireTrustAttestation (ZK) addresses by chain */
export const TRUST_ATTESTATION: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'VaultfireTrustAttestation'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'VaultfireTrustAttestation'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'VaultfireTrustAttestation'),
  polygon: findAddress(POLYGON_CONTRACTS, 'VaultfireTrustAttestation'),
};

/** BeliefAttestationVerifier addresses by chain */
export const BELIEF_ATTESTATION: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'BeliefAttestationVerifier'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'BeliefAttestationVerifier'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'BeliefAttestationVerifier'),
  polygon: findAddress(POLYGON_CONTRACTS, 'BeliefAttestationVerifier'),
};

/** ProductionBeliefAttestationVerifier addresses by chain */
export const PRODUCTION_BELIEF: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'ProductionBeliefAttestationVerifier'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'ProductionBeliefAttestationVerifier'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'ProductionBeliefAttestationVerifier'),
  polygon: findAddress(POLYGON_CONTRACTS, 'ProductionBeliefAttestationVerifier'),
};

/** DilithiumAttestor addresses by chain */
export const DILITHIUM_ATTESTOR: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'DilithiumAttestor'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'DilithiumAttestor'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'DilithiumAttestor'),
  polygon: findAddress(POLYGON_CONTRACTS, 'DilithiumAttestor'),
};

/** FlourishingMetricsOracle addresses by chain */
export const FLOURISHING_ORACLE: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'FlourishingMetricsOracle'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'FlourishingMetricsOracle'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'FlourishingMetricsOracle'),
  polygon: findAddress(POLYGON_CONTRACTS, 'FlourishingMetricsOracle'),
};

/** MultisigGovernance addresses by chain */
export const MULTISIG_GOVERNANCE: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'MultisigGovernance'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'MultisigGovernance'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'MultisigGovernance'),
  polygon: findAddress(POLYGON_CONTRACTS, 'MultisigGovernance'),
};

/** ERC8004ValidationRegistry addresses by chain */
export const VALIDATION_REGISTRY: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'ERC8004ValidationRegistry'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'ERC8004ValidationRegistry'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'ERC8004ValidationRegistry'),
  polygon: findAddress(POLYGON_CONTRACTS, 'ERC8004ValidationRegistry'),
};

/** VaultfireERC8004Adapter addresses by chain */
export const ERC8004_ADAPTER: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'VaultfireERC8004Adapter'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'VaultfireERC8004Adapter'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'VaultfireERC8004Adapter'),
  polygon: findAddress(POLYGON_CONTRACTS, 'VaultfireERC8004Adapter'),
};

/** VaultfireTeleporterBridge addresses by chain */
export const TELEPORTER_BRIDGE: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'VaultfireTeleporterBridge'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'VaultfireTeleporterBridge'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'VaultfireTeleporterBridge'),
  polygon: findAddress(POLYGON_CONTRACTS, 'VaultfireTeleporterBridge'),
};

/** VaultfireReputationStaking addresses by chain */
export const REPUTATION_STAKING: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'VaultfireReputationStaking'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'VaultfireReputationStaking'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'VaultfireReputationStaking'),
  polygon: findAddress(POLYGON_CONTRACTS, 'VaultfireReputationStaking'),
};

/** VaultfireTrustOracle addresses by chain */
export const TRUST_ORACLE: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'VaultfireTrustOracle'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'VaultfireTrustOracle'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'VaultfireTrustOracle'),
  polygon: findAddress(POLYGON_CONTRACTS, 'VaultfireTrustOracle'),
};

/** VaultfireBondInsurancePool addresses by chain */
export const BOND_INSURANCE: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'VaultfireBondInsurancePool'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'VaultfireBondInsurancePool'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'VaultfireBondInsurancePool'),
  polygon: findAddress(POLYGON_CONTRACTS, 'VaultfireBondInsurancePool'),
};

/** VaultfireCapabilityCredentials addresses by chain */
export const CAPABILITY_CREDENTIALS: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'VaultfireCapabilityCredentials'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'VaultfireCapabilityCredentials'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'VaultfireCapabilityCredentials'),
  polygon: findAddress(POLYGON_CONTRACTS, 'VaultfireCapabilityCredentials'),
};

/** VaultfireDisputeResolution addresses by chain */
export const DISPUTE_RESOLUTION: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'VaultfireDisputeResolution'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'VaultfireDisputeResolution'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'VaultfireDisputeResolution'),
  polygon: findAddress(POLYGON_CONTRACTS, 'VaultfireDisputeResolution'),
};

/** Chain IDs */
export const CHAIN_IDS: Record<SupportedChain, number> = {
  base: 8453,
  avalanche: 43114,
  arbitrum: 42161,
  polygon: 137,
};

/** RPC URLs */
export const RPC_URLS: Record<SupportedChain, string> = {
  base: CHAINS.base.rpcUrls.default.http[0],
  avalanche: CHAINS.avalanche.rpcUrls.default.http[0],
  arbitrum: CHAINS.arbitrum.rpcUrls.default.http[0],
  polygon: CHAINS.polygon.rpcUrls.default.http[0],
};

/** Explorer URLs */
export const EXPLORER_URLS: Record<SupportedChain, string> = {
  base: CHAINS.base.explorerUrl,
  avalanche: CHAINS.avalanche.explorerUrl,
  arbitrum: CHAINS.arbitrum.explorerUrl,
  polygon: CHAINS.polygon.explorerUrl,
};

/** AgentInsurancePool addresses by chain (v3.0) */
export const AGENT_INSURANCE: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'AgentInsurancePool'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'AgentInsurancePool'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'AgentInsurancePool'),
  polygon: findAddress(POLYGON_CONTRACTS, 'AgentInsurancePool'),
};

/** AgentSafetyManager addresses by chain (v3.0) */
export const AGENT_SAFETY: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'AgentSafetyManager'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'AgentSafetyManager'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'AgentSafetyManager'),
  polygon: findAddress(POLYGON_CONTRACTS, 'AgentSafetyManager'),
};

/** ComplianceRegistry addresses by chain (v3.0) */
export const COMPLIANCE_REGISTRY: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'ComplianceRegistry'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'ComplianceRegistry'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'ComplianceRegistry'),
  polygon: findAddress(POLYGON_CONTRACTS, 'ComplianceRegistry'),
};

/** ReputationDecay addresses by chain (v3.0) */
export const REPUTATION_DECAY: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'ReputationDecay'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'ReputationDecay'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'ReputationDecay'),
  polygon: findAddress(POLYGON_CONTRACTS, 'ReputationDecay'),
};

/** ScopedDelegation addresses by chain (v3.0) */
export const SCOPED_DELEGATION: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'ScopedDelegation'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'ScopedDelegation'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'ScopedDelegation'),
  polygon: findAddress(POLYGON_CONTRACTS, 'ScopedDelegation'),
};

/** AgentSLAEnforcer addresses by chain (v3.0) */
export const SLA_ENFORCER: Record<SupportedChain, string> = {
  base: findAddress(BASE_CONTRACTS, 'AgentSLAEnforcer'),
  avalanche: findAddress(AVALANCHE_CONTRACTS, 'AgentSLAEnforcer'),
  arbitrum: findAddress(ARBITRUM_CONTRACTS, 'AgentSLAEnforcer'),
  polygon: findAddress(POLYGON_CONTRACTS, 'AgentSLAEnforcer'),
};
