```\nfunction createAgent(uint256 agentId, address owner, string calldata metadata, uint256[] calldata chainIds)\npublic\n    onlySorted(chainIds)\n    frontrunProtected(keccak256(abi.encodePacked(agentId, owner, metadata, chainIds)), frontRunningDelay)\n{\n    \_mint(owner, agentId);\n    \_beforeAgentUpdate(agentId, metadata, chainIds);\n    \_agentUpdate(agentId, metadata, chainIds);\n    \_afterAgentUpdate(agentId, metadata, chainIds);\n}\n```\n