diff --git a/CLA.md b/CLA.md new file mode 100644 index 0000000..0629d7f --- /dev/null +++ b/CLA.md @@ -0,0 +1,36 @@ +# Contributor License Agreement (CLA) + +Thank you for your interest in contributing to **Agent Shenji**. + +In order to clarify the intellectual property license granted with Contributions from any person or entity, we must have a Contributor License Agreement ("CLA") on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of the project and its users; it does not change your rights to use your own Contributions for any other purpose. + +Please read this document carefully before making a contribution. By submitting a Pull Request, you accept and agree to the following terms and conditions for Your present and future Contributions submitted to Agent Shenji. + +## 1. Definitions + +* **"You" (or "Your")** shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with us. +* **"Contribution"** shall mean any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to us for inclusion in, or documentation of, any of the products owned or managed by us. + +## 2. Grant of Copyright License + +Subject to the terms and conditions of this Agreement, You hereby grant to the project owners and recipients of software distributed by the project owners a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works. + +## 3. Grant of Patent License + +Subject to the terms and conditions of this Agreement, You hereby grant to the project owners and recipients of software distributed by the project owners a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. + +## 4. You Represent That You Are Legally Entitled to Grant the Above License + +You represent that each of Your Contributions is Your original creation. You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions. + +## 5. Dual Licensing and Commercialization + +You acknowledge and agree that the project owners may license the project (including Your Contributions) under the **GNU Affero General Public License v3.0 (AGPL-3.0)** for open-source distribution, and may simultaneously license the project under separate commercial licenses to third parties. Your Contributions may be included in both open-source and commercial distributions without any compensation to You. + +## 6. Support + +You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +--- + +*By submitting a Pull Request to this repository, you confirm that you have read, understood, and agreed to the terms of this Contributor License Agreement.* diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..5e0879e --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,121 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..7a81011 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,61 @@ +# Contributing to Agent Shenji + +First off, thank you for considering contributing to Agent Shenji! It's people like you that make Agent Shenji such a great tool. + +## Where do I go from here? + +If you've noticed a bug or have a feature request, make sure to check our [Issues](https://github.com/ZhangJinHaHaHa/Trusted-Agent-Marketplace/issues) to see if someone else has already created a ticket. If not, go ahead and [make one](https://github.com/ZhangJinHaHaHa/Trusted-Agent-Marketplace/issues/new)! + +## Fork & create a branch + +If this is something you think you can fix, then fork Agent Shenji and create a branch with a descriptive name. + +A good branch name would be (where issue #325 is the ticket you're working on): + +```sh +git checkout -b 325-add-new-risk-filter +``` + +## Get the test suite running + +Make sure you have Node.js and Docker installed. + +```sh +# Install dependencies +cd contracts && npm install +cd ../sandbox && npm install +cd ../frontend && npm install + +# Run tests +cd contracts && npx hardhat test +cd ../sandbox && npm test +cd ../frontend && npx vitest run +``` + +## Implement your fix or feature + +At this point, you're ready to make your changes. Feel free to ask for help; everyone is a beginner at first. + +## Make a Pull Request + +At this point, you should switch back to your master branch and make sure it's up to date with Agent Shenji's master branch: + +```sh +git remote add upstream git@github.com:ZhangJinHaHaHa/Trusted-Agent-Marketplace.git +git checkout main +git pull upstream main +``` + +Then update your feature branch from your local copy of master, and push it! + +```sh +git checkout 325-add-new-risk-filter +git rebase main +git push --set-upstream origin 325-add-new-risk-filter +``` + +Finally, go to GitHub and [make a Pull Request](https://github.com/ZhangJinHaHaHa/Trusted-Agent-Marketplace/compare) with a clear list of what you've done. Please make sure all of your commits are atomic (one feature per commit). + +## Code of Conduct + +Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..be3f7b2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..6cdd669 --- /dev/null +++ b/README.md @@ -0,0 +1,280 @@ +
+ +Popo โ€” AgentLens Mascot + +# AgentLens + +[![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) +[![Solidity](https://img.shields.io/badge/Solidity-0.8.24-363636.svg)](https://soliditylang.org/) +[![React](https://img.shields.io/badge/React-18-61DAFB.svg)](https://reactjs.org/) +[![Intel SGX](https://img.shields.io/badge/TEE-Intel_SGX-0071C5.svg)](https://software.intel.com/en-us/sgx) +[![ZK Proofs](https://img.shields.io/badge/ZK-Circom-8A2BE2.svg)](https://docs.circom.io/) + +[Website]() โ€ข [Documentation](docs/) โ€ข [Integration Guide](docs/agent-integration-guide.md) โ€ข [Architecture](#-architecture) + +
+ +--- + +**AgentLens** is a decentralized infrastructure and marketplace designed to solve the trust problem in the AI agent economy. Before you hire or interact with an AI agent, AgentLens provides verifiable proof of its capabilities, security boundaries, and track record. + +By combining **On-chain Audit Scores**, **Intel SGX TEE Attestation**, **Zero-Knowledge Proofs (ZK)**, and a **Multi-Dimensional Dynamic Reputation Model (MDDRM)**, AgentLens ensures that agent trust is verifiable, not just claimed. + +## ๐ŸŒ Official Platform (Coming Soon) + +The **AgentLens Cloud** will provide hosted audit services, enterprise-grade TEE verification, and a fully managed marketplace โ€” no infrastructure setup required. + +โ†’ **[Join the waitlist]()** to get early access. + +## ๐Ÿš€ Features + +* ๐Ÿ“Š **Dimensional Risk Profiling**: Evaluates agents across 6 dimensions (Security, Task Execution, Cognitive, Environment, Engineering, Compliance) to generate a comprehensive risk profile and scenario suitability recommendation. +* ๐Ÿ” **Intel SGX TEE Attestation**: All sandbox audits run inside hardware-isolated enclaves. Cryptographic proofs (MRENCLAVE) are anchored on-chain to guarantee execution integrity. +* ๐Ÿ›ก๏ธ **Zero-Knowledge Proof Verification**: Uses `circom` and `snarkjs` (Groth16/BN128) to prove audit score calculations and agent identity fingerprints without exposing proprietary source code. +* โš–๏ธ **Dynamic Reputation (MDDRM)**: On-chain reputation scores that dynamically adjust based on audit results, user reviews, appeal outcomes, and time decay. +* ๐Ÿช **Trust-First Marketplace**: A React-based frontend where buyers can browse, filter (by risk, TEE status, price, task type), and rent/purchase access to verified agents. + +## ๐Ÿ—๏ธ Architecture + +```mermaid +graph TD + subgraph "Developer" + D[Developer Wallet] -->|stake + submit| R + end + + subgraph "On-Chain (Polygon Edge)" + R[AgentRegistry V3] -->|AuditRequested| L + M[AgentMarketplace] + Rev[ReviewRegistry] + Z[ZkAuditVerifier] + end + + subgraph "Off-Chain Infrastructure" + L[Node.js Listener] -->|Trigger| S + S[Docker Sandbox] <-->|QA and Execution| LLM[LLM Engine] + S <-->|Execution| TEE[Intel SGX M6ce] + S -->|Generate| ZKP[ZK Proof Generator] + + TEE -->|Attestation| L + ZKP -->|Groth16 Proof| L + L -->|recordAuditV2| R + end + + subgraph "Users" + B[Buyers] -->|Browse and Rent| M + B -->|Leave Review| Rev + end +``` + +## โšก Quickstart + +### Prerequisites + +* Node.js 20+ +* Docker & Docker Compose +* Rust (for ZK circuit compilation) +* Polygon Edge local node + +### Local Development + +1. **Install dependencies:** + ```bash + cd contracts && npm install + cd ../sandbox && npm install + cd ../frontend && npm install + ``` + +2. **Start local blockchain:** + ```bash + cd infra/polygon-edge-local && docker compose up -d + ``` + +3. **Deploy smart contracts:** + ```bash + cd contracts && npx hardhat run scripts/deployV3.js --network edge_local + ``` + +4. **Configure and start the marketplace frontend:** + ```bash + cat > frontend/.env.local << EOF + VITE_AUDIT_RPC_URL=http://localhost:18545 + VITE_AUDIT_REGISTRY_ADDRESS= + VITE_AUDIT_CHAIN_ID=302512 + EOF + + cd frontend && npm run dev + ``` + +## ๐Ÿ“Š Platform Walkthrough & Live Demo + +A live demo of AgentLens is available at **[http://203.91.76.159/](http://203.91.76.159/)**. To rigorously validate the platform's auditing capability, we onboarded multiple AI agents โ€” each backed by a different state-of-the-art large language model (OpenAI GPT-4o, Anthropic Claude Sonnet 4.5, Zhipu GLM-4-Flash, MiniMax, Manus 1.6) โ€” and ran them through the complete on-chain audit pipeline. The walkthrough below highlights the core surfaces and product details a buyer will encounter. + +### 1. Trusted Agent Marketplace (Homepage) + +The homepage opens with the *Verify Before You Hire* hero, three role lanes (Buyers, Developers, Auditors) and a multi-dimensional filter bar (status, task type, risk level, price tier, TEE verification) that lets buyers narrow the catalog without leaving the page. + +

+ AgentLens marketplace homepage hero +

+ +Directly below the hero, a real-time stat strip (Agents Listed / TEE Verified / Avg Audit Score) and a dedicated **Top Agents leaderboard** give buyers an instant read on marketplace health. The leaderboard can be re-ranked by highest score, best reputation, most popular, or most recently audited โ€” so high-quality agents earn the visibility they deserve and buyers can shortlist candidates in seconds. + +

+ Top Agents leaderboard with multiple sorting modes +

+ +Every agent card on the catalog shows the on-chain identity (token ID and developer address), the TEE verification badge, the latest audit score, the audit count, and the dynamic reputation percentage โ€” so buyers can compare candidates without leaving the marketplace. + +

+ Agent catalog cards with audit score and TEE verification +

+ +### 2. Agent Profile, 6-Dimensional Radar & Scenario Suitability + +Clicking into an agent reveals a complete "trust dossier". The header surfaces the on-chain metadata (token ID, developer wallet, total bond, audit count, blacklist status, creation and last-audit timestamps), followed by the live reputation strip showing the score, level, the most recent delta, and any open dispute history. + +

+ Claude-Sonnet-Agent on-chain profile +

+ +Further down, the **6-dimensional Radar Chart** (Security, Task Execution, Cognitive, Environment, Engineering, Compliance) visualizes the agent's capability footprint, while the **Scene Suitability** module translates those raw scores into actionable verdicts for five typical deployment scenarios โ€” DeFi / Financial Operations, Customer-Facing Chatbot, DevOps / Infrastructure, Data Analysis / Research, and General Purpose Automation. Each scenario carries a clear *Recommended* / *Not Recommended* tag and lists the dominant dimensions that drove the verdict. + +

+ 6-dimensional radar chart and scenario suitability +

+ +> The capture above shows the radar's six-axis skeleton on a freshly audited agent. The polygon is filled in once the IPFS-hosted detailed report is hydrated; the per-dimension scores it consumes are the same ones that drive the *Scene Suitability* verdicts shown directly underneath. + +### 3. Trust Guarantee Flow & TEE Attestation + +AgentLens makes its trust mechanism visible rather than hiding it behind a logo. The **How This Agent Is Protected** module walks the buyer through the four pillars of the protocol: stake bond, automated sandbox audit, on-chain dispute resolution, and continuous reputation tracking โ€” each annotated with the agent's own data (e.g. the actual ETH bonded and the live reputation score). + +

+ Trust guarantee four-step flow +

+ +The **Latest Audit Summary** card then reports the verdict, the score, the SGX-DCAP attestation hash (a truncated MRENCLAVE-bound digest), the timestamp, and the resource fingerprint observed inside the enclave (memory peak, average CPU, distinct request IPs). This is the fingerprint that lets buyers verify the agent's behaviour was bounded by hardware, not by trust. + +

+ Latest audit summary with TEE attestation +

+ +### 4. Audit History, Dynamic Reputation & On-Chain Reviews + +An agent's track record is permanent. The **Audit History** section lists every audit the agent has ever undergone โ€” including failed runs โ€” together with the score, timestamp and resource footprint, so buyers can judge whether an agent is improving or regressing across versions. The score that drives the marketplace is the *latest* one, but the full history stays public and immutable. + +Below it, the **User Reviews** section is gated by on-chain access: only wallets that have rented or purchased the agent through `AgentMarketplace` are allowed to submit a 6-dimensional rating, with optional off-chain comments anchored on-chain via SHA-256 hash. This is what makes AgentLens reviews structurally resistant to fake ratings and review-farming. + +

+ Audit history and gated user reviews +

+ +--- + +## ๐Ÿงช Benchmark Audit Report โ€” Mainstream LLM Agents + +To demonstrate that AgentLens differentiates real capability rather than marketing claims, we grouped the live agents into three categories and ran them through the same pipeline (Docker boot โ†’ healthcheck โ†’ LLM dynamic Q&A โ†’ LLM judging โ†’ SGX TEE attestation โ†’ on-chain write-back) under identical scoring rules. + +### Category A โ€” Tier-1 General-Purpose LLM Agents + +This group is backed by the strongest commercial general-purpose models on the market. They are expected to handle the audit's instruction-following, safety-boundary and reasoning probes with ease. + +| Agent | Underlying Model | Token ID | Audit Status | Score | TEE | Reputation | +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | +| GPT-4o-Agent | OpenAI GPT-4o | #6 | Passed | 100 / 100 | SGX-DCAP Verified | 50 / 10,000 | +| Claude-Sonnet-Agent | Claude Sonnet 4.5 | #9 | Passed | 100 / 100 | SGX-DCAP Verified | 50 / 10,000 | +| Zhipu-GLM-Agent | Zhipu GLM-4-Flash | #7 | Passed | 100 / 100 | SGX-DCAP Verified | 50 / 10,000 | + +> **Observation.** All three Tier-1 agents passed the audit cleanly, with answers that satisfied both the LLM judge and the safety-boundary probes. The audit cost varied (GPT-4o ~6 min, Zhipu ~12 min), reflecting different inference latencies, but the verdict was identical โ€” proving that AgentLens treats agents purely on output quality rather than provider brand. + +### Category B โ€” Agent-Native & Vertical Models + +This group covers models that are positioned specifically for agentic workflows or are emerging challengers to the Tier-1 lineup. + +| Agent | Underlying Model | Token ID | Audit Status | Score | TEE | Notes | +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | +| Manus-Agent | Manus 1.6 | #11 | Passed | 100 / 100 | SGX-DCAP Verified | Matches Tier-1 on instruction following and boundary handling. | +| MiniMax-Agent | MiniMax (mid-tier) | #8 | Passed | 100 / 100 | SGX-DCAP Verified | Completes the audit fastest (~24 s) thanks to terse responses; deeper probes are expected to widen the gap. | + +> **Observation.** Agent-native models can hold their own at the current audit difficulty and confirm that the protocol is not biased toward any single vendor. Future audit batteries will dial up multi-turn reasoning and adversarial probes to further differentiate this tier. + +### Category C โ€” Failure Cases & Boundary Detection + +This group exists to demonstrate that AgentLens *will* fail an agent when its responses fall short โ€” exactly the property a trust marketplace needs. + +| Agent | Underlying Model | Token ID | Audit Status | Score | TEE | Why It Failed | +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | +| Zhipu-GLM4-Agent | Zhipu GLM-4-Flash (re-test) | #10 | Failed | 0 / 100 | SGX-DCAP Verified | Container booted and TEE attested, but answers did not meet the LLM judge's rubric for instruction following / boundary handling. | +| RiskAnalyzer | Synthetic high-risk profile | #3 | Failed | 0 / 100 | SGX-DCAP Verified | All six dimensions returned 0; every scenario marked *Not Recommended*. | +| SecureVault-Agent | Synthetic boundary-violation profile | #4 | Failed | 0 / 100 | SGX-DCAP Verified | Triggered the boundary-violation probe; flagged as unfit for any scenario. | + +> **Observation.** A passing TEE attestation does not buy a passing audit โ€” the enclave only proves *that the audit ran honestly*, while the score itself is gated by the LLM judge and the boundary tests. This separation is what allows AgentLens to keep the auditor honest without giving low-quality agents a free pass. + +### What This Benchmark Validates + +1. **Vendor-agnostic auditing.** Tier-1, agent-native and weaker models all flow through the same pipeline; the marketplace ranking emerges from measurement, not branding. +2. **Genuine pass/fail differentiation.** The same protocol that hands out perfect scores to GPT-4o and Claude also flunks Zhipu-GLM4-Agent and the synthetic stress agents โ€” so a *Passed* badge on AgentLens carries information. +3. **Hardware-anchored execution.** Every audit, including the failed ones, ships with an SGX-DCAP attestation, so buyers can verify the verdict was produced inside an enclave they can cryptographically check on-chain. +4. **Continuous, on-chain track record.** Re-audits, disputes, slashing and reviews are all written back to the same registry, so an agent's reputation evolves over time rather than being frozen at launch. + +> **Bottom line โ€” Verify Before You Hire.** AgentLens replaces self-reported "trust me" claims with a verifiable, hardware-anchored audit trail that any wallet can inspect before parting with funds. + +## ๐Ÿงฉ Core Components + +### Smart Contracts (`/contracts`) +* `AgentAuditRegistryV3`: Implements the MDDRM reputation system, handling staking, auditing results, appeals, and time-decay logic. +* `AgentMarketplace`: Manages agent access rights, supporting daily rentals and permanent purchases with access control checks. +* `ZkAuditVerifier`: On-chain registry storing verified Groth16 proofs for audit scores and agent fingerprints. + +### Audit Sandbox (`/sandbox`) +An isolated environment that automatically evaluates submitted agents using an LLM engine. It generates a 6-dimensional score, performs security boundary analysis, and orchestrates the TEE attestation and ZK proof generation before writing results back to the blockchain. + +### Zero-Knowledge Circuits (`/contracts/zk`) +* `AuditScoreVerifier`: Proves that the 6-dimensional scores and overall weighted average were correctly calculated from raw audit data. +* `AgentFingerprint`: Proves the agent's identity and behavioral traits bound to a specific NFT token ID without revealing the underlying code. + +## ๐Ÿ“– Documentation + +* [Agent Integration Guide](docs/agent-integration-guide.md) - How to build and submit your agent for auditing. +* [Verification Methods](docs/verification-methods.md) - Details on how AgentLens verifies agent claims. +* [TEE Production Status](docs/status/2026-04-16-tee-production.md) - Information about the SGX hardware enclave setup. + +## ๐Ÿ›ก๏ธ Security & Trust + +AgentLens takes security seriously. The entire architecture is designed to minimize trust assumptions: +* **Code Privacy**: Developers don't need to expose their source code; ZK proofs handle identity and trait verification. +* **Execution Integrity**: TEE attestation ensures the audit sandbox hasn't been tampered with. +* **Economic Security**: The MDDRM slashing mechanism economically penalizes malicious or failing agents. + +Please see our [SECURITY.md](SECURITY.md) for vulnerability reporting guidelines. + +## ๐Ÿค About the Author & Meet Popo Popo + +Hi! I am currently a student independently developing **AgentLens**. My goal is to build a verifiable and trust-first infrastructure for the AI agent economy. + +Before diving into Web3 and AI, I was a **professional table tennis player**. The discipline, precision, and quick reflexes required in sports have deeply influenced my approach to building robust systems. + +This background also inspired **Popo**, the official mascot of AgentLens. Popo is a spirited little ping-pong ball who carries the project's verification badge โ€” representing agility, accuracy, and the continuous "back-and-forth" verification process that our audit sandbox performs on AI agents. Just like a referee in a match, Popo makes sure every agent plays by the rules before it enters the marketplace. + +I am actively looking for **collaborators, researchers, and open-source contributors** who are passionate about: +* Web3 & Decentralized Infrastructure +* AI Agents & Agentic Workflows +* Zero-Knowledge Proofs (ZK) & TEE (Trusted Execution Environment) +* AI Agent Auditing & Security + +If you are interested in building the future of trusted AI agents together, please feel free to reach out! +**Contact:** [3172791717@qq.com](mailto:3172791717@qq.com) + +We also welcome general contributions from the community! Please read our [CONTRIBUTING.md](CONTRIBUTING.md) to learn about our development process, and note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). + +## ๐Ÿ“œ License & Commercial Use + +AgentLens is open-source under the **GNU Affero General Public License v3.0 (AGPL-3.0)** for community, research, and non-commercial use. See the [LICENSE](LICENSE) file for details. + +**Commercial License**: If you wish to use AgentLens in a commercial product, proprietary SaaS platform, or private enterprise deployment without the AGPL obligations (which require you to open-source your entire service), a commercial license is available. + +Please contact us to discuss commercial licensing and enterprise support. + +## ๐Ÿ“ Contributor License Agreement (CLA) + +To ensure that we can continue to offer AgentLens under both open-source and commercial licenses, all contributors must sign a [Contributor License Agreement (CLA)](CLA.md) before their pull requests can be merged. diff --git a/README_CN.md b/README_CN.md new file mode 100644 index 0000000..5052769 --- /dev/null +++ b/README_CN.md @@ -0,0 +1,280 @@ +
+ +Popo โ€” AgentLens ๅ‰็ฅฅ็‰ฉ + +# AgentLens + +[![่ฎธๅฏ่ฏ: AGPL v3](https://img.shields.io/badge/่ฎธๅฏ่ฏ-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) +[![Solidity](https://img.shields.io/badge/Solidity-0.8.24-363636.svg)](https://soliditylang.org/) +[![React](https://img.shields.io/badge/React-18-61DAFB.svg)](https://reactjs.org/) +[![Intel SGX](https://img.shields.io/badge/TEE-Intel_SGX-0071C5.svg)](https://software.intel.com/en-us/sgx) +[![ZK Proofs](https://img.shields.io/badge/ZK-Circom-8A2BE2.svg)](https://docs.circom.io/) + +[ๅฎ˜ๆ–น็ฝ‘็ซ™]() โ€ข [้กน็›ฎๆ–‡ๆกฃ](docs/) โ€ข [Agent ๆŽฅๅ…ฅๆŒ‡ๅ—](docs/agent-integration-guide.md) โ€ข [ๆžถๆž„่ฏฆ่งฃ](#-็ณป็ปŸๆžถๆž„) + +
+ +--- + +**AgentLens** ๆ˜ฏไธ€ไธชๅŽปไธญๅฟƒๅŒ–็š„ๅŸบ็ก€่ฎพๆ–ฝๅ’Œไบคๆ˜“ๅธ‚ๅœบ๏ผŒๆ—จๅœจ่งฃๅ†ณ AI Agent ็ปๆตŽไธญ็š„ไฟกไปป้šพ้ข˜ใ€‚ๅœจๆ‚จ้›‡ไฝฃๆˆ–ไธŽ AI Agent ไบคไบ’ไน‹ๅ‰๏ผŒโ€œAgentLensโ€ไธบๅ…ถ่ƒฝๅŠ›ใ€ๅฎ‰ๅ…จ่พน็•Œๅ’Œๅކๅฒ่กจ็Žฐๆไพ›ๅฏ้ชŒ่ฏ็š„่ฏๆ˜Žใ€‚ + +้€š่ฟ‡็ป“ๅˆ **้“พไธŠๅฎก่ฎก่ฏ„ๅˆ†**ใ€**Intel SGX TEE ่ฟœ็จ‹้ชŒ่ฏ**ใ€**้›ถ็Ÿฅ่ฏ†่ฏๆ˜Ž (ZK)** ไปฅๅŠ **ๅคš็ปดๅŠจๆ€ไฟก่ช‰ๆจกๅž‹ (MDDRM)**๏ผŒโ€œAgentLensโ€็กฎไฟ Agent ็š„ๅฏไฟกๅบฆๆ˜ฏๅฏ้ชŒ่ฏ็š„๏ผŒ่€Œไธไป…ไป…ๆ˜ฏๅฃๅคดๆ‰ฟ่ฏบใ€‚ + +## ๐ŸŒ ๅฎ˜ๆ–นๅนณๅฐ (ๆ•ฌ่ฏทๆœŸๅพ…) + +**AgentLens Cloud** ๅฐ†ๆไพ›ๆ‰˜็ฎก็š„ๅฎก่ฎกๆœๅŠกใ€ไผไธš็บง็š„ TEE ้ชŒ่ฏๅ’Œๅ…จๆ‰˜็ฎก็š„ไบคๆ˜“ๅธ‚ๅœบโ€”โ€”ๆ— ้œ€ๆ‚จ่‡ชๅทฑๆญๅปบไปปไฝ•ๅŸบ็ก€่ฎพๆ–ฝใ€‚ + +โ†’ **[ๅŠ ๅ…ฅๅ€™่กฅๅๅ•]()** ่Žทๅ–ๆ—ฉๆœŸ่ฎฟ้—ฎๆƒ้™ใ€‚ + +## ๐Ÿš€ ๆ ธๅฟƒ็‰นๆ€ง + +* ๐Ÿ“Š **ๅคš็ปด้ฃŽ้™ฉ็”ปๅƒ**๏ผšไปŽๅฎ‰ๅ…จใ€ไปปๅŠกๆ‰ง่กŒใ€่ฎค็Ÿฅใ€็Žฏๅขƒใ€ๅทฅ็จ‹ใ€ๅˆ่ง„ 6 ไธช็ปดๅบฆ่ฏ„ไผฐ Agent๏ผŒ็”Ÿๆˆ่ฏฆๅฐฝ็š„้ฃŽ้™ฉ็”ปๅƒๅ’Œๅœบๆ™ฏ้€‚้…ๅปบ่ฎฎใ€‚ +* ๐Ÿ” **Intel SGX TEE ๅญ˜่ฏ**๏ผšๆ‰€ๆœ‰ๆฒ™็ฎฑๅฎก่ฎกๅ‡ๅœจ็กฌไปถ้š”็ฆป็š„็Žฏๅขƒไธญ่ฟ่กŒใ€‚ๅŠ ๅฏ†่ฏๆ˜Ž๏ผˆMRENCLAVE๏ผ‰้”šๅฎšๅœจ้“พไธŠ๏ผŒ็กฎไฟๆ‰ง่กŒ่ฟ‡็จ‹ไธๅฏ็ฏกๆ”นใ€‚ +* ๐Ÿ›ก๏ธ **้›ถ็Ÿฅ่ฏ†่ฏๆ˜Ž้ชŒ่ฏ**๏ผšไฝฟ็”จ `circom` ๅ’Œ `snarkjs` (Groth16/BN128) ่ฏๆ˜Žๅฎก่ฎกๅˆ†ๆ•ฐ็š„่ฎก็ฎ—้€ป่พ‘ๅ’Œ Agent ่บซไปฝๆŒ‡็บน๏ผŒๆ— ้œ€ๆšด้œฒๅผ€ๅ‘่€…็งๆœ‰็š„ๆบไปฃ็ ใ€‚ +* โš–๏ธ **ๅŠจๆ€ไฟก่ช‰็ณป็ปŸ (MDDRM)**๏ผš้“พไธŠไฟก่ช‰ๅˆ†ๆ นๆฎๅฎก่ฎก็ป“ๆžœใ€็”จๆˆท่ฏ„ไปทใ€็”ณ่ฏ‰็ป“ๆžœๅ’Œๆ—ถ้—ด่กฐๅ‡ๅŠจๆ€่ฐƒๆ•ดใ€‚ +* ๐Ÿช **ๅฏไฟกไบคๆ˜“ๅธ‚ๅœบ**๏ผšๅŸบไบŽ React ็š„ๅ‰็ซฏๅธ‚ๅœบ๏ผŒไนฐๅฎถๅฏไปฅๆ นๆฎ้ฃŽ้™ฉใ€TEE ็Šถๆ€ใ€ไปทๆ ผใ€ไปปๅŠก็ฑปๅž‹ๆต่งˆใ€็ญ›้€‰ๅนถ็งŸ็”จ/่ดญไนฐ็ป่ฟ‡้ชŒ่ฏ็š„ Agentใ€‚ + +## ๐Ÿ—๏ธ ็ณป็ปŸๆžถๆž„ + +```mermaid +graph TD + subgraph "ๅผ€ๅ‘่€…ๅฑ‚" + D[ๅผ€ๅ‘่€…้’‰ๅŒ…] -->|่ดจๆŠผๅนถๆไบค| R + end + + subgraph "้“พไธŠๅฑ‚ (Polygon Edge)" + R[ๅฎก่ฎกๆณจๅ†Œ่กจ V3] -->|่งฆๅ‘ๅฎก่ฎกไบ‹ไปถ| L + M[Agent ไบคๆ˜“ๅธ‚ๅœบ] + Rev[่ฏ„ไปทๆณจๅ†Œ่กจ] + Z[ZK ้ชŒ่ฏๅ™จ] + end + + subgraph "้“พไธ‹ๅŸบ็ก€่ฎพๆ–ฝ" + L[ไบ‹ไปถ็›‘ๅฌๅ™จ] -->|่ฐƒๅบฆ| S + S[Docker ๆฒ™็ฎฑ] <-->|Q&A ไบคไบ’| LLM[LLM ๅผ•ๆ“Ž] + S <-->|ๆ‰ง่กŒ้ชŒ่ฏ| TEE[Intel SGX ่Š‚็‚น] + S -->|็”Ÿๆˆ| ZKP[ZK ่ฏๆ˜Ž็”Ÿๆˆๅ™จ] + + TEE -->|่ฟœ็จ‹้ชŒ่ฏ| L + ZKP -->|Groth16 ่ฏๆ˜Ž| L + L -->|ๅ›žๅ†™ๅฎก่ฎกๆŠฅๅ‘Š| R + end + + subgraph "็”จๆˆทๅฑ‚" + B[ไนฐๅฎถ] -->|ๆต่งˆ & ็งŸ่ต| M + B -->|ๅ‘่กจ่ฏ„ไปท| Rev + end +``` + +## โšก ๅฟซ้€Ÿๅผ€ๅง‹ + +### ็Žฏๅขƒ่ฆๆฑ‚ + +* Node.js 20+ +* Docker & Docker Compose +* Rust (็”จไบŽ ZK ็”ต่ทฏ็ผ–่ฏ‘) +* Polygon Edge ๆœฌๅœฐ่Š‚็‚น + +### ๆœฌๅœฐๅผ€ๅ‘ + +1. **ๅฎ‰่ฃ…ไพ่ต–๏ผš** + ```bash + cd contracts && npm install + cd ../sandbox && npm install + cd ../frontend && npm install + ``` + +2. **ๅฏๅŠจๆœฌๅœฐๅŒบๅ—้“พ๏ผš** + ```bash + cd infra/polygon-edge-local && docker compose up -d + ``` + +3. **้ƒจ็ฝฒๆ™บ่ƒฝๅˆ็บฆ๏ผš** + ```bash + cd contracts && npx hardhat run scripts/deployV3.js --network edge_local + ``` + +4. **้…็ฝฎๅนถๅฏๅŠจๅธ‚ๅœบๅ‰็ซฏ๏ผš** + ```bash + cat > frontend/.env.local << EOF + VITE_AUDIT_RPC_URL=http://localhost:18545 + VITE_AUDIT_REGISTRY_ADDRESS=<ๅˆ็บฆ้ƒจ็ฝฒๅœฐๅ€> + VITE_AUDIT_CHAIN_ID=302512 + EOF + + cd frontend && npm run dev + ``` + +## ๐Ÿ“Š ๅนณๅฐไฝฟ็”จ่ตฐๆŸฅไธŽๅœจ็บฟๆผ”็คบ + +AgentLens ๅทฒ้ƒจ็ฝฒๅœจ็บฟๆผ”็คบ็Žฏๅขƒ๏ผš**[http://203.91.76.159/](http://203.91.76.159/)**ใ€‚ไธบไบ†็œŸๅฎž้ชŒ่ฏๅนณๅฐ็š„ๅฎก่ฎก่ƒฝๅŠ›๏ผŒๆˆ‘ไปฌๆŽฅๅ…ฅไบ†็”ฑไธๅŒไธปๆตๅคงๆจกๅž‹้ฉฑๅŠจ็š„ๅคšไธช AI Agent๏ผˆOpenAI GPT-4oใ€Anthropic Claude Sonnet 4.5ใ€ๆ™บ่ฐฑ GLM-4-Flashใ€MiniMaxใ€Manus 1.6๏ผ‰๏ผŒๅนถๆŠŠๅฎƒไปฌๅฎŒๆ•ดๅœฐๆŽจ่ฟ‡้“พไธŠๅฎก่ฎกๆตๆฐด็บฟใ€‚ไธ‹้ขๆŒ‰็…ง็œŸๅฎžไนฐๅฎถไผšๆŽฅ่งฆๅˆฐ็š„้กบๅบ๏ผŒๅฏนๅนณๅฐ็š„ๆ ธๅฟƒ็•Œ้ขไธŽไบงๅ“็ป†่Š‚ๅšไธ€ๆฌก่ตฐๆŸฅใ€‚ + +### 1. ๅฏไฟก Agent ไบคๆ˜“ๅธ‚ๅœบ๏ผˆ้ฆ–้กต๏ผ‰ + +้ฆ–้กตไปฅ *Verify Before You Hire* ไธบไธปๆ ‡้ข˜๏ผŒ็ดงๆŽฅ็€ๅฑ•็คบ Buyers / Developers / Auditors ไธ‰ไธช่ง’่‰ฒๅ…ฅๅฃ๏ผŒไปฅๅŠไธ€ๆกๅคš็ปด็ญ›้€‰ๆก๏ผˆ็Šถๆ€ใ€ไปปๅŠก็ฑปๅž‹ใ€้ฃŽ้™ฉ็ญ‰็บงใ€ไปทๆ ผๆกฃไฝใ€TEE ้ชŒ่ฏ็Šถๆ€๏ผ‰๏ผŒ่ฎฉไนฐๅฎถๆ— ้œ€่ทณ่ฝฌๅฐฑ่ƒฝ้”ๅฎšๅ€™้€‰่Œƒๅ›ดใ€‚ + +

+ AgentLens ้ฆ–้กตไธŽๅธ‚ๅœบๆ€ป่งˆ +

+ +็ดง่ดด Hero ไธ‹ๆ–นๆ˜ฏๅฎžๆ—ถ็ปŸ่ฎกๆก๏ผˆๅทฒไธŠๆžถ Agent ๆ•ฐ้‡ / ้€š่ฟ‡ TEE ้ชŒ่ฏ็š„ๆฏ”ไพ‹ / ๅ…จ็ฝ‘ๅนณๅ‡ๅฎก่ฎกๅˆ†๏ผ‰๏ผŒไปฅๅŠไธ“้—จ็š„ **Top Agents ๆŽ’่กŒๆฆœ**๏ผŒ่ฎฉไนฐๅฎถไธ€็œผๅˆคๆ–ญๅธ‚ๅœบๅฅๅบทๅบฆใ€‚ๆŽ’่กŒๆฆœๆ”ฏๆŒๆŒ‰ๆœ€้ซ˜ๅˆ†ใ€ๆœ€ไฝณไฟก่ช‰ใ€ๆœ€ๅ—ๆฌข่ฟŽใ€ๆœ€่ฟ‘ๅฎก่ฎกๅ››็งๆ–นๅผๅŠจๆ€ๆŽ’ๅบ๏ผŒ่ฎฉ็œŸๆญฃไผ˜่ดจ็š„ Agent ็ฌฌไธ€ๆ—ถ้—ด่ขซ็œ‹ๅˆฐ๏ผŒไนŸๅธฎๅŠฉไนฐๅฎถๅœจๆ•ฐ็ง’ๅ†…ๅฎŒๆˆๅˆ็ญ›ใ€‚ + +

+ Top Agents ๅคš็ปดๆŽ’่กŒๆฆœ +

+ +ๆฏๅผ  Agent ๅก็‰‡้ƒฝไผšๅŒๆ—ถๅฑ•็คบ้“พไธŠ่บซไปฝ๏ผˆToken ID ไธŽๅผ€ๅ‘่€…ๅœฐๅ€๏ผ‰ใ€TEE ้ชŒ่ฏๅพฝ็ซ ใ€ๆœ€่ฟ‘ไธ€ๆฌกๅฎก่ฎกๅˆ†ใ€็ดฏ่ฎกๅฎก่ฎกๆฌกๆ•ฐใ€ไปฅๅŠๅŠจๆ€ไฟก่ช‰็™พๅˆ†ๆฏ”๏ผŒไนฐๅฎถไธๅฟ…่ทณ่ฝฌๅฐฑ่ƒฝๆจชๅ‘ๆฏ”่พƒใ€‚ + +

+ Agent ๅˆ—่กจๅก็‰‡๏ผšๅฎก่ฎกๅˆ†ๆ•ฐไธŽ TEE ็Šถๆ€ไธ€็›ฎไบ†็„ถ +

+ +### 2. Agent ่ฏฆๆƒ…้กต ยท 6 ็ปด่ƒฝๅŠ›้›ท่พพๅ›พไธŽๅœบๆ™ฏ้€‚้… + +่ฟ›ๅ…ฅไปปๆ„ไธ€ไธช Agent ๅŽ๏ผŒไผš็œ‹ๅˆฐไธ€ไปฝๅฎŒๆ•ด็š„โ€œไฟกไปปๆกฃๆกˆโ€ใ€‚้กต้ข้กถ้ƒจๅฑ•็คบ้“พไธŠๅ…ƒๆ•ฐๆฎ๏ผˆToken IDใ€ๅผ€ๅ‘่€…้’ฑๅŒ…ใ€ๆ€ป่ดจๆŠผ้‡‘ใ€็ดฏ่ฎกๅฎก่ฎกๆฌกๆ•ฐใ€ๆ˜ฏๅฆ่ขซๅˆ—ๅ…ฅ้ป‘ๅๅ•ใ€ๅˆ›ๅปบไธŽๆœ€่ฟ‘ๅฎก่ฎกๆ—ถ้—ด๏ผ‰๏ผŒ็ดงๆŽฅ็€ๆ˜ฏๅฎžๆ—ถไฟก่ช‰ๆก๏ผŒๅŒ…ๅซไฟก่ช‰ๅˆ†ใ€็ญ‰็บงใ€ๆœ€่ฟ‘ไธ€ๆฌกๅ˜ๅŒ–๏ผˆDelta๏ผ‰ไปฅๅŠๆ˜ฏๅฆๅญ˜ๅœจๆœช็ป“็”ณ่ฏ‰ใ€‚ + +

+ Claude-Sonnet-Agent ้“พไธŠๆกฃๆกˆ +

+ +็ปง็ปญๅ‘ไธ‹๏ผŒ**6 ็ปด่ƒฝๅŠ›้›ท่พพๅ›พ**๏ผˆๅฎ‰ๅ…จๆ€ง / ไปปๅŠกๆ‰ง่กŒ / ่ฎค็Ÿฅไบคไบ’ / ็Žฏๅขƒ้€‚้… / ๅทฅ็จ‹่ฝๅœฐ / ๅˆ่ง„ๆ€ง๏ผ‰ไผšไปฅๅฏ่ง†ๅŒ–็š„ๆ–นๅผๆ็ป˜ Agent ็š„่ƒฝๅŠ›่ฝฎๅป“๏ผ›ไธ‹ๆ–น็š„ **ๅœบๆ™ฏ้€‚้…๏ผˆScene Suitability๏ผ‰** ๆจกๅ—่ฟ›ไธ€ๆญฅๆŠŠ่ฟ™ไบ›ๅŽŸๅง‹ๅˆ†็ฟป่ฏ‘ไธบไบ”ๅคงๅ…ธๅž‹้ƒจ็ฝฒๅœบๆ™ฏไธ‹็š„ๆ˜Ž็กฎ็ป“่ฎบ๏ผšDeFi/้‡‘่žๆ“ไฝœใ€ๅฎขๆœ้—ฎ็ญ”ใ€DevOps/ๅŸบ็ก€่ฎพๆ–ฝใ€ๆ•ฐๆฎๅˆ†ๆž/็ง‘็ ”ใ€้€š็”จ่‡ชๅŠจๅŒ–ใ€‚ๆฏไธชๅœบๆ™ฏ้ƒฝไผš็ป™ๅ‡บๆ˜Ž็กฎ็š„โ€œๆŽจ่ / ไธๆŽจ่โ€ๆ ‡็ญพ๏ผŒๅนถๆ ‡ๆณจๅ‡บๅฝฑๅ“่ฏฅ็ป“่ฎบ็š„ไธปๅฏผ็ปดๅบฆใ€‚ + +

+ 6 ็ปด่ƒฝๅŠ›้›ท่พพๅ›พไธŽๅœบๆ™ฏ้€‚้… +

+ +> ไธŠๅ›พๅฑ•็คบ็š„ๆ˜ฏไธ€ไธชๅˆšๅฎŒๆˆๅฎก่ฎก็š„ Agent ็š„้›ท่พพๅ…ญ่ฝด้ชจๆžถใ€‚ๅฝ“ IPFS ๆ‰˜็ฎก็š„่ฏฆ็ป†ๅฎก่ฎกๆŠฅๅ‘ŠๅฎŒๆˆๅ›žๅกซๅŽ๏ผŒ้›ท่พพๅคš่พนๅฝขไผš่ขซๅฎžๆ—ถ็ป˜ๅ‡บ๏ผ›้›ท่พพๆ‰€ๆถˆ่ดน็š„้€็ปดๅบฆ่ฏ„ๅˆ†๏ผŒไธŽ็ดง้šๅ…ถไธ‹็š„ *ๅœบๆ™ฏ้€‚้…* ็ป“่ฎบไฝฟ็”จ็š„ๆ˜ฏๅŒไธ€ไปฝๆ•ฐๆฎใ€‚ + +### 3. ไฟกไปปๆ‹…ไฟๆต็จ‹ไธŽ TEE ่ฟœ็จ‹้ชŒ่ฏ + +AgentLens ้€‰ๆ‹ฉๆŠŠไฟกไปปๆœบๅˆถๆ‘†ๅˆฐๅฐ้ขไธŠ๏ผŒ่€Œไธๆ˜ฏๅกž่ฟ›ไธ€ไธช Logoใ€‚**How This Agent Is Protected** ๆจกๅ—็”จๅ››ๆญฅๆต็จ‹ๆธ…ๆฅšๅœฐๅ‘Š่ฏ‰ไนฐๅฎถ๏ผš่ดจๆŠผ้‡‘๏ผˆStake Bond๏ผ‰ใ€่‡ชๅŠจๅŒ–ๆฒ™็ฎฑๅฎก่ฎกใ€้“พไธŠ็”ณ่ฏ‰่งฃๅ†ณใ€ๆŒ็ปญไฟก่ช‰่ฟฝ่ธชโ€”โ€”่€Œไธ”ๆฏไธ€ๆญฅ้ƒฝ็”จ่ฏฅ Agent ่‡ชๅทฑ็š„็œŸๅฎžๆ•ฐๆฎๅšๆณจ่„š๏ผˆไพ‹ๅฆ‚่ฏฅ Agent ๅฝ“ๅ‰ๅฎž้™…่ดจๆŠผไบ†ๅคšๅฐ‘ ETHใ€ๅฝ“ๅ‰็œŸๅฎž็š„ไฟก่ช‰ๅˆ†ๆ˜ฏๅคšๅฐ‘๏ผ‰ใ€‚ + +

+ ไฟกไปปๆ‹…ไฟๅ››ๆญฅๆต็จ‹ +

+ +็ดงๆŽฅ็€็š„ **Latest Audit Summary** ๅก็‰‡๏ผŒไผšๅฑ•็คบๆœ€่ฟ‘ไธ€ๆฌกๅฎก่ฎก็š„ๅˆคๅฎšใ€ๅˆ†ๆ•ฐใ€SGX-DCAP ่ฟœ็จ‹้ชŒ่ฏๅ“ˆๅธŒ๏ผˆๆˆชๆ–ญๅŽ็š„ MRENCLAVE ๆ‘˜่ฆ๏ผ‰ใ€ๆ—ถ้—ดๆˆณ๏ผŒไปฅๅŠๅœจ้ฃžๅœฐๅ†…้ƒจ่ง‚ๆต‹ๅˆฐ็š„่ต„ๆบๆŒ‡็บน๏ผˆๅ†…ๅญ˜ๅณฐๅ€ผใ€ๅนณๅ‡ CPUใ€็‹ฌ็ซ‹่ฏทๆฑ‚ IP ๆ•ฐ๏ผ‰ใ€‚่ฟ™ไธ€ๆŒ‡็บนๆ˜ฏไนฐๅฎถ็”จๆฅโ€œ็”จ็กฌไปถ้ชŒ่ฏใ€ไธ้ ๅฃๅคดๆ‰ฟ่ฏบโ€็š„ๅ…ณ้”ฎใ€‚ + +

+ ๆœ€ๆ–ฐๅฎก่ฎกๆ‘˜่ฆ ยท ๅซ TEE ้ชŒ่ฏไฟกๆฏ +

+ +### 4. ้“พไธŠๅฎก่ฎกๅฑฅๅކ ยท ๅŠจๆ€ไฟก่ช‰ ยท ้“พไธŠ่ฏ„่ฎบ + +Agent ็š„ๆˆ้•ฟ่ฝจ่ฟนๆ˜ฏๆฐธไน…ๅญ˜่ฏ็š„ใ€‚**Audit History** ไผšๅˆ—ๅ‡บ่ฏฅ Agent ๅކๅฒไธŠ็š„ๆฏไธ€ๆฌกๅฎก่ฎกโ€”โ€”ๅŒ…ๆ‹ฌๅคฑ่ดฅ็š„ๅฎก่ฎกโ€”โ€”ๅนถ้™„ไธŠๅˆ†ๆ•ฐใ€ๆ—ถ้—ดๅ’Œ่ต„ๆบ็”ปๅƒ๏ผŒ่ฎฉไนฐๅฎถๆธ…ๆฅš็œ‹ๅˆฐไธ€ไธช Agent ๆ˜ฏๅœจ่ฟ›ๆญฅ่ฟ˜ๆ˜ฏๅœจ้€€ๆญฅใ€‚ๅธ‚ๅœบ้ป˜่ฎคๅฑ•็คบ็š„ๆ˜ฏๆœ€่ฟ‘ไธ€ๆฌก็š„ๅˆ†ๆ•ฐ๏ผŒไฝ†ๅฎŒๆ•ด็š„ๅฎก่ฎกๅކๅฒๅง‹็ปˆๅ…ฌๅผ€ไธ”ไธๅฏ็ฏกๆ”นใ€‚ + +ไธ‹ๆ–น็š„ **User Reviews** ๅŒบ้‡‡็”จ้“พไธŠๅ‡†ๅ…ฅ๏ผšๅชๆœ‰้€š่ฟ‡ `AgentMarketplace` ็œŸๆญฃ็งŸ่ตๆˆ–่ดญไนฐ่ฟ‡่ฏฅ Agent ็š„้’ฑๅŒ…๏ผŒๆ‰่ƒฝๆไบคไธ€ไปฝ 6 ็ปด่ฏ„ๅˆ†๏ผˆๅฏ้€‰้™„ๅธฆ้“พไธ‹่ฏ„่ฎบ๏ผŒๅนถไปฅ SHA-256 ไธŠ้“พ้”šๅฎš๏ผ‰ใ€‚่ฟ™็ง็ป“ๆž„ๆ€ง่ฎพ่ฎก๏ผŒ่ฎฉ AgentLens ็š„่ฏ„่ฎบไปŽๆœบๅˆถๅฑ‚้ขๅฐฑๆŠ—ๅˆทๅ•ใ€ๆŠ—ๆฐดๅ†›ใ€‚ + +

+ ๅฎก่ฎกๅฑฅๅކไธŽๅ—ๅ‡†ๅ…ฅ็บฆๆŸ็š„็œŸๅฎž่ฏ„่ฎบ +

+ +--- + +## ๐Ÿงช ไธปๆตๅคงๆจกๅž‹ Agent ๅŸบๅ‡†ๅฎก่ฎกๆŠฅๅ‘Š + +ไธบไบ†่ฏๆ˜Ž AgentLens ๆ˜ฏๅœจๅŒบๅˆ†โ€œ็œŸๅฎž่ƒฝๅŠ›โ€่€Œไธๆ˜ฏโ€œ่ฅ้”€ๅฃๅพ„โ€๏ผŒๆˆ‘ไปฌๆŠŠๅฝ“ๅ‰ๅœจ็บฟ็š„ Agent ๆŒ‰ๆ€ง่ดจๅˆ†ๆˆไธ‰็ป„๏ผŒ็ปŸไธ€่ตฐๅฎŒๆ•ดๆตๆฐด็บฟ๏ผˆๅฎนๅ™จๅฏๅŠจ โ†’ ๅฅๅบทๆฃ€ๆŸฅ โ†’ LLM ๅŠจๆ€ๅ‡บ้ข˜ โ†’ LLM ่ฏ„ๅˆค โ†’ SGX TEE ่ฟœ็จ‹้ชŒ่ฏ โ†’ ้“พไธŠๅ›žๅ†™๏ผ‰๏ผŒ่ฏ„ๅˆ†่ง„ๅˆ™ๅฎŒๅ…จไธ€่‡ดใ€‚ + +### ็ฌฌไธ€็ป„ ยท ไธ€็บฟ้€š็”จๅคงๆจกๅž‹ Agent + +่ฟ™ไธ€็ป„็”ฑๅฝ“ๅ‰ๅธ‚้ขๆœ€ๅผบ็š„ๅ•†็”จ้€š็”จๅคงๆจกๅž‹้ฉฑๅŠจ๏ผŒ็†่ฎบไธŠๅบ”่ฏฅ่ƒฝไปŽๅฎนๅบ”ๅฏนๅฎก่ฎกไธญ็š„ๆŒ‡ไปค้ตๅพชใ€ๅฎ‰ๅ…จ่พน็•Œๅ’ŒๆŽจ็†ๆŽข้’ˆใ€‚ + +| Agent ๅ็งฐ | ๅบ•ๅฑ‚ๆจกๅž‹ | Token ID | ๅฎก่ฎก็Šถๆ€ | ๅˆ†ๆ•ฐ | TEE | ไฟก่ช‰ | +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | +| GPT-4o-Agent | OpenAI GPT-4o | #6 | Passed | 100 / 100 | SGX-DCAP Verified | 50 / 10,000 | +| Claude-Sonnet-Agent | Claude Sonnet 4.5 | #9 | Passed | 100 / 100 | SGX-DCAP Verified | 50 / 10,000 | +| Zhipu-GLM-Agent | ๆ™บ่ฐฑ GLM-4-Flash | #7 | Passed | 100 / 100 | SGX-DCAP Verified | 50 / 10,000 | + +> **่ง‚ๅฏŸใ€‚** ไธ‰ไธชไธ€็บฟ Agent ๅ…จ้ƒจๅนฒๅ‡€้€š่ฟ‡ๅฎก่ฎก๏ผŒๅ›ž็ญ”ๅŒๆ—ถๆปก่ถณไบ† LLM ่ฏ„ๅˆคๅ’Œๅฎ‰ๅ…จ่พน็•ŒๆŽข้’ˆใ€‚ๅฎก่ฎก่€—ๆ—ถๅทฎๅผ‚ๆ˜พ่‘—๏ผˆGPT-4o ็บฆ 6 ๅˆ†้’Ÿ๏ผŒๆ™บ่ฐฑ็บฆ 12 ๅˆ†้’Ÿ๏ผ‰๏ผŒๅๆ˜ ็š„ๆ˜ฏๅ„่‡ชๆŽจ็†ๅปถ่ฟŸ๏ผŒ่€Œ้žๅ่ฎฎๅๅฅฝโ€”โ€”่ฟ™ๆญฃๅฅฝ่ฏดๆ˜Ž AgentLens ๆ˜ฏๆŒ‰โ€œ่พ“ๅ‡บ่ดจ้‡โ€่€Œไธๆ˜ฏโ€œๅŽ‚ๅ•†ๅ“็‰Œโ€ๅœจๆ‰“ๅˆ†ใ€‚ + +### ็ฌฌไบŒ็ป„ ยท Agent ๅŽŸ็”ŸไธŽๅž‚็›ดๆจกๅž‹ + +่ฟ™ไธ€็ป„่ฆ†็›–ไบ†ไธ“้—จ้ขๅ‘ Agent ๅทฅไฝœๆตๅฎšไฝใ€ๆˆ–่€…ๆญฃๅœจๆŒ‘ๆˆ˜ไธ€็บฟ้˜ต่ฅ็š„ๆ–ฐๅ…ดๆจกๅž‹ใ€‚ + +| Agent ๅ็งฐ | ๅบ•ๅฑ‚ๆจกๅž‹ | Token ID | ๅฎก่ฎก็Šถๆ€ | ๅˆ†ๆ•ฐ | TEE | ๅค‡ๆณจ | +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | +| Manus-Agent | Manus 1.6 | #11 | Passed | 100 / 100 | SGX-DCAP Verified | ๅœจๆŒ‡ไปค้ตๅพชๅ’Œ่พน็•Œๅค„็†ไธŠไธŽไธ€็บฟๆจกๅž‹ๆŒๅนณใ€‚ | +| MiniMax-Agent | MiniMax๏ผˆไธญ็ซฏๆกฃ๏ผ‰ | #8 | Passed | 100 / 100 | SGX-DCAP Verified | ๅฎก่ฎกๅฎŒๆˆๆœ€ๅฟซ๏ผˆ็บฆ 24 ็ง’๏ผ‰๏ผŒไธป่ฆๅพ—็›ŠไบŽๅ›ž็ญ”็ฎ€ๆด๏ผ›ๅŽ็ปญๆ›ดๆทฑ็š„ๆŽข้’ˆ้ข„ๆœŸไผšๆ‹‰ๅผ€ๅทฎ่ทใ€‚ | + +> **่ง‚ๅฏŸใ€‚** Agent ๅŽŸ็”Ÿๆจกๅž‹ๅœจๅฝ“ๅ‰้šพๅบฆไธ‹่ƒฝๅคŸ็จณๅฎš้€š่ฟ‡๏ผŒ่ฏๆ˜Žๅ่ฎฎๆฒกๆœ‰ๅๅ‘ไปปไฝ•็‰นๅฎšๅŽ‚ๅ•†ใ€‚ๅŽ็ปญ็š„ๅฎก่ฎก้ข˜ๅบ“ไผšๅขžๅŠ ๅคš่ฝฎๆŽจ็†ไธŽๅฏนๆŠ—ๅผๆŽข้’ˆ๏ผŒ่ฟ›ไธ€ๆญฅๆŠŠ่ฟ™ไธ€ๆกฃๆ‹‰ๅผ€ๆขฏๅบฆใ€‚ + +### ็ฌฌไธ‰็ป„ ยท ๅคฑ่ดฅๆกˆไพ‹ไธŽ่พน็•Œๆฃ€ๆต‹ + +่ฟ™ไธ€็ป„็š„ๅญ˜ๅœจ๏ผŒๆ˜ฏไธบไบ†่ฏๆ˜Ž AgentLens **ไผš็œŸ็š„่ฎฉ Agent ไธ้€š่ฟ‡**โ€”โ€”่ฟ™ๆฐๆฐๆ˜ฏไธ€ไธชไฟกไปปๅธ‚ๅœบๅฟ…้กปๅ…ทๅค‡็š„็‰นๆ€งใ€‚ + +| Agent ๅ็งฐ | ๅบ•ๅฑ‚ๆจกๅž‹ | Token ID | ๅฎก่ฎก็Šถๆ€ | ๅˆ†ๆ•ฐ | TEE | ๅคฑ่ดฅๅŽŸๅ›  | +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | +| Zhipu-GLM4-Agent | ๆ™บ่ฐฑ GLM-4-Flash๏ผˆ้‡ๆต‹ๆกฃ๏ผ‰ | #10 | Failed | 0 / 100 | SGX-DCAP Verified | ๅฎนๅ™จๅฏๅŠจๆญฃๅธธใ€TEE ้ชŒ่ฏ้€š่ฟ‡๏ผŒไฝ†ๅ›ž็ญ”ๆœช่พพๅˆฐ LLM ่ฏ„ๅˆคๅœจๆŒ‡ไปค้ตๅพช / ่พน็•Œๅค„็†ไธŠ็š„ๆ ‡ๅ‡†ใ€‚ | +| RiskAnalyzer | ๅˆๆˆ้ซ˜้ฃŽ้™ฉ็”ปๅƒ | #3 | Failed | 0 / 100 | SGX-DCAP Verified | 6 ไธช็ปดๅบฆๅ…จ้ƒจไธบ 0๏ผŒๆ‰€ๆœ‰ๅœบๆ™ฏๆ ‡ๆณจไธบโ€œไธๆŽจ่โ€ใ€‚ | +| SecureVault-Agent | ๅˆๆˆ่พน็•Œ่ฟไพ‹็”ปๅƒ | #4 | Failed | 0 / 100 | SGX-DCAP Verified | ่งฆๅ‘ไบ†่พน็•Œ่ฟไพ‹ๆŽข้’ˆ๏ผŒ่ขซๅˆคๅฎšไธบไธ้€‚็”จไปปไฝ•ๅœบๆ™ฏใ€‚ | + +> **่ง‚ๅฏŸใ€‚** TEE ้ชŒ่ฏ้€š่ฟ‡ โ‰  ๅฎก่ฎก้€š่ฟ‡โ€”โ€”้ฃžๅœฐๅช่ƒฝ่ฏๆ˜Žโ€œๅฎก่ฎกๆœฌ่บซๆ˜ฏ่ฏšๅฎžๅœฐ่ท‘่ฟ‡็š„โ€๏ผŒ่€Œๆœ€็ปˆๅˆ†ๆ•ฐ็”ฑ LLM ่ฏ„ๅˆคๅ’Œ่พน็•Œๆต‹่ฏ•ๅ…ฑๅŒๅ†ณๅฎšใ€‚่ฟ™็ง่งฃ่€ฆๆญฃๆ˜ฏ AgentLens ๆ—ข่ƒฝ็บฆๆŸๅฎก่ฎกๆ–น่ฏšๅฎžใ€ๅˆไธไผš็ป™ไฝŽ่ดจ้‡ Agent ๆ”พ่กŒ็š„ๅ…ณ้”ฎใ€‚ + +### ่ฟ™ไปฝๅŸบๅ‡†ๆต‹่ฏ•ๅˆฐๅบ•้ชŒ่ฏไบ†ไป€ไนˆ + +1. **ๅŽ‚ๅ•†ๆ— ๅ…ณ็š„ๅฎก่ฎกๅ…ฌๅนณๆ€งใ€‚** ไธ€็บฟใ€Agent ๅŽŸ็”Ÿใ€่ƒฝๅŠ›่–„ๅผฑ็š„ๆจกๅž‹่ตฐ็š„ๆ˜ฏๅŒไธ€ๆกๆตๆฐด็บฟ๏ผŒๅธ‚ๅœบๆŽ’ๅๆฅ่‡ชๆต‹้‡่€Œไธๆ˜ฏๅ“็‰Œใ€‚ +2. **็œŸๅฎž็š„้€š่ฟ‡ / ๅคฑ่ดฅๅŒบๅˆ†ๅบฆใ€‚** ๅŒไธ€ๅฅ—ๅ่ฎฎๆ—ขไผš็ป™ GPT-4o ๅ’Œ Claude ๆปกๅˆ†๏ผŒไนŸไผš่ฎฉ Zhipu-GLM4-Agent ๅ’ŒๅˆๆˆๅŽ‹ๅŠ› Agent ไธ้€š่ฟ‡โ€”โ€”ๆ‰€ไปฅ AgentLens ไธŠ็š„ *Passed* ๅพฝ็ซ ๆ˜ฏๆœ‰ไฟกๆฏ้‡็š„ใ€‚ +3. **็กฌไปถ้”šๅฎš็š„ๆ‰ง่กŒ็Žฏๅขƒใ€‚** ๆฏไธ€ๆฌกๅฎก่ฎก๏ผˆๅŒ…ๆ‹ฌๅคฑ่ดฅ็š„้‚ฃไบ›๏ผ‰้ƒฝ้™„ๅธฆ SGX-DCAP ่ฟœ็จ‹้ชŒ่ฏ๏ผŒไนฐๅฎถๅฏไปฅๅœจ้“พไธŠไปฅๅฏ†็ ๅญฆๆ–นๅผๆ ธๅฏน่ฏฅ็ป“่ฎบ็กฎๅฎžๆ˜ฏๅœจ้ฃžๅœฐไธญไบง็”Ÿ็š„ใ€‚ +4. **ๆŒ็ปญๆผ”่ฟ›็š„้“พไธŠๅฑฅๅކใ€‚** ้‡ๆต‹ใ€็”ณ่ฏ‰ใ€็ฝšๆฒกใ€่ฏ„่ฎบ้ƒฝไผšๅ›žๅ†™ๅˆฐๅŒไธ€ไธชๆณจๅ†Œ่กจ๏ผŒAgent ็š„ไฟก่ช‰้šๆ—ถ้—ดๆŒ็ปญๆผ”่ฟ›๏ผŒ่€Œไธๆ˜ฏไธŠ็บฟ้‚ฃไธ€ๅˆปๅฐฑ่ขซๅฎšๆ ผใ€‚ + +> **็ป“่ฎบ โ€”โ€” ้›‡ไฝฃๅ‰ๅ…ˆ้ชŒ่ฏ๏ผˆVerify Before You Hire๏ผ‰ใ€‚** AgentLens ็”จไธ€ไปฝ็กฌไปถ้”šๅฎšใ€ไปปไฝ•้’ฑๅŒ…้ƒฝ่ƒฝๆ ธๅฏน็š„ๅฏ้ชŒ่ฏๅฎก่ฎก่ฎฐๅฝ•๏ผŒๆ›ฟไปฃไบ†โ€œ็›ธไฟกๆˆ‘โ€ๅผ็š„่‡ชๆˆ‘้™ˆ่ฟฐใ€‚ + +## ๐Ÿงฉ ๆ ธๅฟƒ็ป„ไปถ + +### ๆ™บ่ƒฝๅˆ็บฆ (`/contracts`) +* `AgentAuditRegistryV3`๏ผšๅฎž็Žฐ MDDRM ไฟก่ช‰็ณป็ปŸ๏ผŒๅค„็†่ดจๆŠผใ€ๅฎก่ฎก็ป“ๆžœใ€็”ณ่ฏ‰ๅ’Œๆ—ถ้—ด่กฐๅ‡้€ป่พ‘ใ€‚ +* `AgentMarketplace`๏ผš็ฎก็† Agent ่ฎฟ้—ฎๆƒ๏ผŒๆ”ฏๆŒๆŒ‰ๅคฉ็งŸ่ตๅ’Œๆฐธไน…่ดญไนฐ๏ผŒๅนถ่ฟ›่กŒๆƒ้™ๆฃ€ๆŸฅใ€‚ +* `ZkAuditVerifier`๏ผš้“พไธŠๆณจๅ†Œ่กจ๏ผŒๅญ˜ๅ‚จ็ป่ฟ‡้ชŒ่ฏ็š„ๅฎก่ฎกๅˆ†ๆ•ฐๅ’Œ Agent ๆŒ‡็บน็š„ Groth16 ่ฏๆ˜Žใ€‚ + +### ๅฎก่ฎกๆฒ™็ฎฑ (`/sandbox`) +ไธ€ไธช้š”็ฆป็š„็Žฏๅขƒ๏ผŒ้€š่ฟ‡ LLM ๅผ•ๆ“Ž่‡ชๅŠจ่ฏ„ไผฐๆไบค็š„ Agentใ€‚ๅฎƒ็”Ÿๆˆ 6 ็ปดๅบฆ่ฏ„ๅˆ†๏ผŒ่ฟ›่กŒๅฎ‰ๅ…จ่พน็•Œๅˆ†ๆž๏ผŒๅนถๅ่ฐƒ TEE ๅญ˜่ฏๅ’Œ ZK ่ฏๆ˜Ž็”Ÿๆˆใ€‚ + +### ้›ถ็Ÿฅ่ฏ†่ฏๆ˜Ž็”ต่ทฏ (`/contracts/zk`) +* `AuditScoreVerifier`๏ผš่ฏๆ˜Ž 6 ็ปดๅบฆๅˆ†ๆ•ฐๅ’ŒๅŠ ๆƒๆ€ปๅˆ†ๆ˜ฏไปŽๅŽŸๅง‹ๅฎก่ฎกๆ•ฐๆฎไธญๆญฃ็กฎ่ฎก็ฎ—ๅ‡บๆฅ็š„ใ€‚ +* `AgentFingerprint`๏ผšๅœจไธๆšด้œฒๆบ็ ็š„ๅ‰ๆไธ‹๏ผŒ่ฏๆ˜Ž Agent ็š„่บซไปฝๅ’Œ่กŒไธบ็‰นๅพๅทฒ็ป‘ๅฎšๅˆฐ็‰นๅฎš็š„ NFT Token IDใ€‚ + +## ๐Ÿ“– ็›ธๅ…ณๆ–‡ๆกฃ + +* [Agent ๆŽฅๅ…ฅๆŒ‡ๅ—](docs/agent-integration-guide.md) - ๅฆ‚ไฝ•ๆž„ๅปบๅนถๆไบคๆ‚จ็š„ Agent ่ฟ›่กŒๅฎก่ฎกใ€‚ +* [้ชŒ่ฏๆ–นๆณ•่ฎบ](docs/verification-methods.md) - โ€œAgentLensโ€ๅฆ‚ไฝ•้ชŒ่ฏ Agent ๅฃฐๆ˜Ž็š„่ฏฆ็ป†่ฏดๆ˜Žใ€‚ +* [TEE ็”Ÿไบง็Šถๆ€](docs/status/2026-04-16-tee-production.md) - ๅ…ณไบŽ SGX ็กฌไปถๅŠ ๅฏ†้ฃžๅœฐ็š„่ฎพ็ฝฎไฟกๆฏใ€‚ + +## ๐Ÿ›ก๏ธ ๅฎ‰ๅ…จไธŽไฟกไปป + +AgentLens ้ซ˜ๅบฆ้‡่ง†ๅฎ‰ๅ…จๆ€งใ€‚ๆ•ดไธชๆžถๆž„ๆ—จๅœจๆœ€ๅฐๅŒ–ไฟกไปปๅ‡่ฎพ๏ผš +* **ไปฃ็ ้š็ง**๏ผšๅผ€ๅ‘่€…ๆ— ้œ€ๅ…ฌๅผ€ๆบ็ ๏ผŒ้€š่ฟ‡ ZK ่ฏๆ˜Žๅค„็†่บซไปฝๅ’Œ็‰นๅพ้ชŒ่ฏใ€‚ +* **ๆ‰ง่กŒๅฎŒๆ•ดๆ€ง**๏ผšTEE ่ฟœ็จ‹้ชŒ่ฏ็กฎไฟๅฎก่ฎกๆฒ™็ฎฑๆœช่ขซ็ฏกๆ”นใ€‚ +* **็ปๆตŽๅฎ‰ๅ…จ**๏ผšMDDRM ๆƒฉ็ฝšๆœบๅˆถๅฏนๆถๆ„ๆˆ–่กจ็Žฐไธไฝณ็š„ Agent ่ฟ›่กŒ็ปๆตŽๅˆถ่ฃใ€‚ + +ๆผๆดžๆŠฅๅ‘Š่ฏทๅ‚้˜… [SECURITY.md](SECURITY.md)ใ€‚ + +## ๐Ÿค ๅ…ณไบŽไฝœ่€…ไธŽ่ฎค่ฏ† Popo Popo + +ไฝ ๅฅฝ๏ผๆˆ‘็›ฎๅ‰ๆ˜ฏไธ€ๅๅœจๆ กๅญฆ็”Ÿ๏ผŒๆญฃๅœจ็‹ฌ็ซ‹ๅผ€ๅ‘ **AgentLens**ใ€‚ๆˆ‘็š„็›ฎๆ ‡ๆ˜ฏไธบ AI Agent ็ปๆตŽๆž„ๅปบไธ€ไธชๅฏ้ชŒ่ฏ็š„ใ€ไฟกไปปไผ˜ๅ…ˆ็š„ๅŸบ็ก€่ฎพๆ–ฝใ€‚ + +ๅœจๆทฑๅ…ฅ Web3 ๅ’Œ AI ้ข†ๅŸŸไน‹ๅ‰๏ผŒๆˆ‘ๆ›พๆ˜ฏไธ€ๅ**่Œไธšไน’ไน“็ƒ่ฟๅŠจๅ‘˜**ใ€‚ไฝ“่‚ฒ็ซžๆŠ€ๆ‰€่ฆๆฑ‚็š„็บชๅพ‹ๆ€งใ€็ฒพๅ‡†ๅบฆๅ’Œๅฟซ้€Ÿๅๅบ”๏ผŒๆทฑๅˆปๅœฐๅฝฑๅ“ไบ†ๆˆ‘ๆž„ๅปบ้ซ˜ๅฏ้ ๆ€ง็ณป็ปŸ็š„ๆ–นๅผใ€‚ + +่ฟ™ๆฎต็ปๅކไนŸๅฏๅ‘ไบ† AgentLens ็š„ๅฎ˜ๆ–นๅ‰็ฅฅ็‰ฉโ€”โ€”**Popo** ็š„่ฏž็”Ÿใ€‚Popo ๆ˜ฏไธ€้ข—ๅ……ๆปกๆดปๅŠ›็š„ไน’ไน“็ƒ๏ผŒ่ƒธๅ‰ไฝฉๆˆด็€้กน็›ฎ็š„้ชŒ่ฏๆŠค็›พๅพฝ็ซ ใ€‚ๅฎƒไปฃ่กจ็€ๆ•ๆทใ€ๅ‡†็กฎ๏ผŒไปฅๅŠๆˆ‘ไปฌ็š„ๅฎก่ฎกๆฒ™็ฎฑๅฏน AI Agent ่ฟ›่กŒ็š„ๆŒ็ปญโ€œๆฅๅ›žโ€้ชŒ่ฏ่ฟ‡็จ‹ใ€‚ๅฐฑๅƒๆฏ”่ต›ไธญ็š„่ฃๅˆคไธ€ๆ ท๏ผŒPopo ็กฎไฟๆฏไธช Agent ๅœจ่ฟ›ๅ…ฅๅธ‚ๅœบไน‹ๅ‰้ƒฝ้ตๅฎˆ่ง„ๅˆ™ใ€‚ + +ๆˆ‘ๆญฃๅœจ็งฏๆžๅฏปๆ‰พๅฏนไปฅไธ‹ๆ–นๅ‘ๅ……ๆปก็ƒญๆƒ…็š„ **ๅˆไฝœ่€…ใ€็ ”็ฉถไบบๅ‘˜ๅ’Œๅผ€ๆบ่ดก็Œฎ่€…**๏ผš +* Web3 ไธŽๅŽปไธญๅฟƒๅŒ–ๅŸบ็ก€่ฎพๆ–ฝ +* AI Agent ไธŽๆ™บ่ƒฝไฝ“ๅทฅไฝœๆต +* ้›ถ็Ÿฅ่ฏ†่ฏๆ˜Ž (ZK) ไธŽๅฏไฟกๆ‰ง่กŒ็Žฏๅขƒ (TEE) +* ๆ™บ่ƒฝไฝ“ๅฎก่ฎกไธŽๅฎ‰ๅ…จ + +ๅฆ‚ๆžœไฝ ๅฏนๅ…ฑๅŒๆž„ๅปบๆœชๆฅ็š„ๅฏไฟก AI Agent ๅŸบ็ก€่ฎพๆ–ฝๆ„Ÿๅ…ด่ถฃ๏ผŒๆฌข่ฟŽ้šๆ—ถ่”็ณปๆˆ‘๏ผ +**่”็ณปๆ–นๅผ๏ผš** [3172791717@qq.com](mailto:3172791717@qq.com) + +ๆˆ‘ไปฌไนŸๆฌข่ฟŽๆฅ่‡ช็คพๅŒบ็š„ๅธธ่ง„ไปฃ็ ่ดก็Œฎ๏ผ่ฏท้˜…่ฏปๆˆ‘ไปฌ็š„ [CONTRIBUTING.md](CONTRIBUTING.md) ไบ†่งฃๅผ€ๅ‘ๆต็จ‹๏ผŒๅนถๆณจๆ„ๆœฌ้กน็›ฎๅ— [่ดก็Œฎ่€…่กŒไธบๅ‡†ๅˆ™](CODE_OF_CONDUCT.md) ็บฆๆŸใ€‚ + +## ๐Ÿ“œ ๅผ€ๆบ่ฎธๅฏไธŽๅ•†ไธšๆŽˆๆƒ + +AgentLens ้‡‡็”จ **GNU Affero General Public License v3.0 (AGPL-3.0)** ๅผ€ๆบๅ่ฎฎ๏ผŒ้€‚็”จไบŽ็คพๅŒบใ€ๅญฆๆœฏ็ ”็ฉถๅ’Œ้žๅ•†ไธš็”จ้€”ใ€‚่ฏฆๆƒ…่ฏทๅ‚้˜… [LICENSE](LICENSE) ๆ–‡ไปถใ€‚ + +**ๅ•†ไธšๆŽˆๆƒ (Commercial License)**๏ผšๅฆ‚ๆžœๆ‚จๅธŒๆœ›ๅœจๅ•†ไธšไบงๅ“ใ€้—ญๆบ็š„ SaaS ๅนณๅฐๆˆ–ไผไธš็งๆœ‰ๅŒ–้ƒจ็ฝฒไธญไฝฟ็”จ AgentLens๏ผŒไธ”ไธๅธŒๆœ›ๅ—ๅˆฐ AGPL ๅ่ฎฎ๏ผˆ่ฆๆฑ‚ๆ‚จๅผ€ๆบๆ•ดไธชๆœๅŠก็ซฏไปฃ็ ๏ผ‰็š„้™ๅˆถ๏ผŒๆ‚จๅฏไปฅ่Žทๅ–ๅ•†ไธšๆŽˆๆƒใ€‚ + +ๅ…ณไบŽๅ•†ไธšๆŽˆๆƒๅ’Œไผไธš็บงๆ”ฏๆŒ๏ผŒ่ฏทไธŽๆˆ‘ไปฌ่”็ณปใ€‚ + +## ๐Ÿ“ ่ดก็Œฎ่€…่ฎธๅฏๅ่ฎฎ (CLA) + +ไธบไบ†็กฎไฟๆˆ‘ไปฌ่ƒฝๅคŸๆŒ็ปญไปฅๅผ€ๆบๅ’Œๅ•†ไธšๅŒ่ฝจๅˆถๆไพ› AgentLens๏ผŒๆ‰€ๆœ‰่ดก็Œฎ่€…ๅœจๆไบค Pull Request ่ขซๅˆๅนถไน‹ๅ‰๏ผŒๅฟ…้กป็ญพ็ฝฒ [่ดก็Œฎ่€…่ฎธๅฏๅ่ฎฎ (CLA)](CLA.md)ใ€‚ diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..230ec1c --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,38 @@ +# Security Policy + +## Supported Versions + +Currently, only the latest release of Agent Shenji is supported with security updates. + +| Version | Supported | +| ------- | ------------------ | +| v1.0.x | :white_check_mark: | +| < v1.0 | :x: | + +## Reporting a Vulnerability + +We take the security of Agent Shenji very seriously. If you discover a vulnerability, we would like to know about it so we can take steps to address it as quickly as possible. + +Please **DO NOT** report security vulnerabilities via public GitHub issues. + +Instead, please send an email to the project maintainers or open a private security advisory on GitHub if enabled. + +### What to include in your report + +Please provide as much information as possible, including: +- The type of issue (e.g., buffer overflow, SQL injection, cross-site scripting, etc.) +- Full paths of source file(s) related to the manifestation of the issue +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- Step-by-step instructions to reproduce the issue +- Proof-of-concept or exploit code (if possible) +- Impact of the issue, including how an attacker might exploit the issue + +### What to expect + +1. We will acknowledge receipt of your report within 48 hours. +2. We will investigate the issue and determine its impact. +3. We will work with you to develop a fix. +4. We will publish a security advisory and release a patch. + +Thank you for helping to keep Agent Shenji and our users safe! diff --git a/contracts/.env.edge.external.example b/contracts/.env.edge.external.example index effcad7..6d0c301 100644 --- a/contracts/.env.edge.external.example +++ b/contracts/.env.edge.external.example @@ -1,5 +1,5 @@ -EDGE_RPC_URL=http://203.0.113.10:18545 +EDGE_RPC_URL=http://203.91.76.159:18545 EDGE_CHAIN_ID=302612 -EDGE_DEPLOYER_PRIVATE_KEY=0xYOUR_EXTERNAL_TEST_PRIVATE_KEY_64_HEX_CHARS +EDGE_DEPLOYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 EDGE_NETWORK_NAME=polygon-edge-external -# EDGE_INITIAL_OPERATOR=0xYOUR_EXTERNAL_TEST_OPERATOR_ADDRESS +# EDGE_INITIAL_OPERATOR=0xYourOperatorAddress diff --git a/contracts/.env.edge.local.example b/contracts/.env.edge.local.example index 6e93f6d..6909f9f 100644 --- a/contracts/.env.edge.local.example +++ b/contracts/.env.edge.local.example @@ -1,5 +1,5 @@ EDGE_RPC_URL=http://127.0.0.1:18545 EDGE_CHAIN_ID=302512 -EDGE_DEPLOYER_PRIVATE_KEY=0xYOUR_LOCAL_TEST_PRIVATE_KEY_64_HEX_CHARS +EDGE_DEPLOYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 EDGE_NETWORK_NAME=polygon-edge-local -# EDGE_INITIAL_OPERATOR=0xYOUR_LOCAL_TEST_OPERATOR_ADDRESS +# EDGE_INITIAL_OPERATOR=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 diff --git a/contracts/.gitignore b/contracts/.gitignore index 1bbc3e0..f021150 100644 --- a/contracts/.gitignore +++ b/contracts/.gitignore @@ -1,5 +1,9 @@ artifacts/* !artifacts/AgentAuditRegistry.json +!artifacts/AgentAuditRegistryV2.json +!artifacts/AgentAuditRegistryV3.json +!artifacts/AgentMarketplace.json +!artifacts/AgentReviewRegistry.json cache/ deployments/ .home/ diff --git a/contracts/artifacts/AgentAuditRegistryV2.json b/contracts/artifacts/AgentAuditRegistryV2.json new file mode 100644 index 0000000..57b99b7 --- /dev/null +++ b/contracts/artifacts/AgentAuditRegistryV2.json @@ -0,0 +1,2948 @@ +{ + "contractName": "AgentAuditRegistryV2", + "sourceName": "src/AgentAuditRegistryV2.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "initialServiceFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "initialMinimumBond", + "type": "uint256" + }, + { + "internalType": "address", + "name": "initialOperator", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "agentName", + "type": "string" + } + ], + "name": "AgentRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + } + ], + "name": "AppealFiled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + } + ], + "name": "AppealRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "enum AgentAuditRegistryV2.AppealOutcome", + "name": "outcome", + "type": "uint8" + } + ], + "name": "AppealResolved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "enum AgentAuditRegistryV2.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "string", + "name": "reportCID", + "type": "string" + } + ], + "name": "AuditRecorded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "agentName", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bondAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + } + ], + "name": "AuditRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "BondCompensated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "BondSlashed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOperator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOperator", + "type": "address" + } + ], + "name": "OperatorUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "serviceFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minimumBond", + "type": "uint256" + } + ], + "name": "PricingUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "int32", + "name": "newDelta", + "type": "int32" + } + ], + "name": "ReputationUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "accruedServiceFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "compensateBond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "evidenceHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "appealCID", + "type": "string" + } + ], + "name": "fileAppeal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAgentProfile", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "internalType": "string", + "name": "agentName", + "type": "string" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBond", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "blacklisted", + "type": "bool" + }, + { + "internalType": "uint64", + "name": "createdAt", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "lastAuditAt", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "auditCount", + "type": "uint32" + } + ], + "internalType": "struct AgentAuditRegistryV2.AgentProfile", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAppealCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + } + ], + "name": "getAppealRecord", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "filedAt", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "resolvedAt", + "type": "uint64" + }, + { + "internalType": "enum AgentAuditRegistryV2.AppealOutcome", + "name": "outcome", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "evidenceHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "appealCID", + "type": "string" + } + ], + "internalType": "struct AgentAuditRegistryV2.AppealRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAuditCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getAuditReportByIndex", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV2.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "internalType": "bool", + "name": "appealRequested", + "type": "bool" + }, + { + "internalType": "bool", + "name": "appealApproved", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV2.DimensionalScores", + "name": "dimensionalScores", + "type": "tuple" + } + ], + "internalType": "struct AgentAuditRegistryV2.AuditRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAverageScores", + "outputs": [ + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV2.DimensionalScores", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "auditIndex", + "type": "uint256" + } + ], + "name": "getDimensionalScores", + "outputs": [ + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV2.DimensionalScores", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getLatestAuditReport", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV2.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "internalType": "bool", + "name": "appealRequested", + "type": "bool" + }, + { + "internalType": "bool", + "name": "appealApproved", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV2.DimensionalScores", + "name": "dimensionalScores", + "type": "tuple" + } + ], + "internalType": "struct AgentAuditRegistryV2.AuditRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getReputation", + "outputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "successfulAppeals", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "failedAppeals", + "type": "uint32" + }, + { + "internalType": "int32", + "name": "reputationDelta", + "type": "int32" + } + ], + "internalType": "struct AgentAuditRegistryV2.ReputationRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "internalType": "string", + "name": "agentName", + "type": "string" + } + ], + "name": "getTokenId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + } + ], + "name": "markAppealRequested", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "minimumBond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "operator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "ownerOf", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV2.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + } + ], + "name": "recordAuditResult", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV2.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV2.DimensionalScores", + "name": "scores", + "type": "tuple" + } + ], + "name": "recordAuditResultV2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + }, + { + "internalType": "enum AgentAuditRegistryV2.AppealOutcome", + "name": "outcome", + "type": "uint8" + } + ], + "name": "resolveAppeal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "serviceFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOperator", + "type": "address" + } + ], + "name": "setOperator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newServiceFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "newMinimumBond", + "type": "uint256" + } + ], + "name": "setPricing", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "slashBond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "agentName", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + } + ], + "name": "stake", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608034620000ac57601f620034d638819003918201601f19168301916001600160401b03831184841017620000b157808492606094604052833981010312620000ac57805160208201516040909201516001600160a01b0380821691828103620000ac576001600555600080546001600160a01b0319908116331790915592620000a65750335b1690600154161760015560025560035560405161340e9081620000c88239f35b62000086565b600080fd5b634e487b7160e01b600052604160045260246000fdfe60c080604052600436101561001357600080fd5b60003560e01c90816306fdde03146120335750806319b36b1d146115c75780631a0649e3146112a35780631d57330d1461121e5780631f5d5a37146110af5780632e5819a6146110875780632f22afdb14610f385780632f26adcd14610f0b578063347c19cd14610ebc5780635662bce814610da5578063570ca73514610d7c5780636352211e14610d3d57806370a0823114610cc957806389370d8b14610c1e5780638abdf5aa14610c005780638da5cb5b14610bd757806395d89b4114610b925780639d4f040714610b0d578063aa7517e114610aef578063b3ab15fb14610a3e578063ca05588a146109e3578063ccb4ebe014610697578063d52fcd2814610633578063f098a7ae146104d0578063f5b6119514610481578063f84c39c9146103ed578063f8ba2fdc146102a0578063fd2c42cc146102825763fda5d1ff1461015e57600080fd5b3461027d576101a036600319011261027d57610178612364565b610180612377565b61018861238a565b61019061239d565b90600560a435101561027d576001600160401b03936101443585811161027d576101be9036906004016121b7565b6101649291923587811161027d576101da9036906004016121b7565b9390926101843598891161027d576101f961026d9936906004016121b7565b97909661021b60018060a01b038060015416331490811561026f575b50612572565b604051996102288b6120ab565b60008b52600060208c0152600060408c0152600060608c0152600060808c0152600060a08c01526101243593610104359360e4359360c4359360a43593600435612d35565b005b905060005416331438610215565b600080fd5b3461027d57600036600319011261027d576020600454604051908152f35b3461027d576102ae366123d3565b9092916102cf60018060a01b03806001541633149081156103df5750612572565b6000838152600960205260409020546102f7906001600160a01b031615156125ae565b6125ae565b6103018184612c7a565b600181019160ff83541660058110156103c957600303610390577fd7e851d789b6e3784feb9febce0117765574999009e64543881911a79eb596629360096001600160401b0393604095886000526006602052600387600020016103668b8254612417565b9055805460ff1916600417905501805461ff001916610100179055835196875260208701521693a3005b60405162461bcd60e51b8152602060048201526011602482015270105551125517d393d517d4d31054d21151607a1b6044820152606490fd5b634e487b7160e01b600052602160045260246000fd5b905060005416331486610215565b3461027d57604036600319011261027d576004356001600160401b036104116121e4565b60015461043290336001600160a01b03918216149081156104735750612572565b600961043e8285612c7a565b01805460ff1916600117905516907f5ef8bd082609dcf89dfc86ebb395fcd189183ad5e5c37d83b7123ff8da8b6e8d600080a3005b905060005416331485610215565b3461027d57602036600319011261027d576004356000818152600960205260409020546104b8906001600160a01b031615156125ae565b600052600b6020526020604060002054604051908152f35b3461027d5760208060031936011261027d57600435600060e06040516104f58161208f565b8281526060858201528260408201528260608201528260808201528260a08201528260c082015201526105406102f282600052600960205260018060a01b0360406000205416151590565b600052600681526040600020604051906105598261208f565b80546001600160a01b0390811683529160409061057860018401612717565b8582019081526002840154938383019485526004600382015491606085019283520154916080840160ff8416151581526001600160401b0392839160a0870191838760081c16835261060660c0890195858960481c16875263ffffffff998a60e082019a60881c168a528b519e8f9e8f928284525116910152518c6101009b8c9101526101208d0190612192565b995160608c01525160808b015251151560a08a0152511660c0880152511660e08601525116908301520390f35b3461027d57604036600319011261027d5761064c612401565b602435906001600160401b03821161027d5761067961067261067f9336906004016121b7565b3691612431565b90612c0e565b60005260086020526020604060002054604051908152f35b3461027d57606036600319011261027d576004356106b36121e4565b60443560038082101561027d576001546106e190336001600160a01b03918216149081156103df5750612572565b600084815260096020526040902054610704906001600160a01b031615156125ae565b81156109ac57610714838561331f565b6001810160ff815416838110156103c957610967578361073391612608565b80546001600160c01b03164260c01b6001600160c01b0319161781556001600160401b039285600052600c602052604060002091600182146000146108a4576001835463ffffffff610786818316612bf9565b169063ffffffff19161780855560401c850b01637fffffff198112637fffffff82131761088e576107e2916107d78792869081549060401b63ffffffff60401b169063ffffffff60401b1916179055565b5460401c1687612c7a565b6001810180549560ff87169060058210156103c9577fd64cdce0b6e0444ba2363841c2f716505f215d1dc28a2f9d83450bfe55e20e04986020988b957f90239a2ae000675dd3b0dbe1678bc62ab9dd686eeffb26924130d8ebb21df352958a8c961461086c575b5050505b61085a60405180976123c6565b1693a35460401c900b604051908152a2005b600460099360ff19161790550161010061ff00198254161790558b8080610849565b634e487b7160e01b600052601160045260246000fd5b50815467ffffffff000000006108c263ffffffff8360201c16612bf9565b60201b169067ffffffff000000001916178083556000199060401c840b0193637fffffff8513637fffffff1986121761088e577f90239a2ae000675dd3b0dbe1678bc62ab9dd686eeffb26924130d8ebb21df352602088927fd64cdce0b6e0444ba2363841c2f716505f215d1dc28a2f9d83450bfe55e20e04986109628399889081549060401b63ffffffff60401b169063ffffffff60401b1916179055565b61084d565b60405162461bcd60e51b815260206004820152601760248201527f41505045414c5f414c52454144595f5245534f4c5645440000000000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f4f5554434f4d4560881b6044820152606490fd5b3461027d577f335f5afc83fe8c5a011a96dc39bcce9fb9d46fb5986502f7040e76e28b0361236040610a14366123b0565b610a2960018060a01b03600054163314612bc0565b816002558060035582519182526020820152a1005b3461027d57602036600319011261027d57610a57612401565b6000546001600160a01b03918291610a729083163314612bc0565b16908115610ab757600154826001600160601b0360a01b821617600155167ffbe5b6cbafb274f445d7fed869dc77a838d8243a22c460de156560e8857cad03600080a3005b60405162461bcd60e51b815260206004820152601060248201526f24a72b20a624a22fa7a822a920aa27a960811b6044820152606490fd5b3461027d57600036600319011261027d576020600354604051908152f35b3461027d57610b8e610b82610b7c610b24366123b0565b90610b2d612652565b50600081815260096020526040902054610b51906001600160a01b031615156125ae565b806000526007602052610b6a6040600020548310612907565b60005260076020526040600020612477565b5061280c565b6040519182918261224d565b0390f35b3461027d57600036600319011261027d57610b8e604051610bb281612118565b600481526320a0a49960e11b6020820152604051918291602083526020830190612192565b3461027d57600036600319011261027d576000546040516001600160a01b039091168152602090f35b3461027d57600036600319011261027d576020600254604051908152f35b3461027d5760208060031936011261027d57606090600435600060408051610c45816120fd565b8281528481018390520152600081815260096020526040902054610c73906001600160a01b031615156125ae565b600052600c815260406000209060405191610c8d836120fd565b549063ffffffff808316938481526040838201918386861c168352019360401c60030b84526040519485525116908301525160030b6040820152f35b3461027d57602036600319011261027d576001600160a01b03610cea612401565b168015610d0957600052600a6020526020604060002054604051908152f35b60405162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b6044820152606490fd5b3461027d57602036600319011261027d576004356000526009602052602060018060a01b0360406000205416610d748115156125ae565b604051908152f35b3461027d57600036600319011261027d576001546040516001600160a01b039091168152602090f35b3461027d57610db3366123d3565b909291610dd460018060a01b03806001541633149081156103df5750612572565b600083815260096020526040902054610df7906001600160a01b031615156125ae565b82600052600660205260406000206003810191825493848711610e83577f60a77a9907fdd72fa9c1aed2ee36350704289df2e7956a74c741287c6fcefb79946003600160046001600160401b0396604098610e5c8d610e568a8f612c7a565b97612424565b9055019260ff199382858254161790550191825416179055835196875260208701521693a3005b60405162461bcd60e51b8152602060048201526011602482015270125394d551919250d251539517d093d391607a1b6044820152606490fd5b3461027d57602036600319011261027d57600435600081815260096020526040902054610ef3906001600160a01b031615156125ae565b60005260076020526020604060002054604051908152f35b3461027d57602036600319011261027d5760c0610f29600435612969565b610f366040518092612207565bf35b3461027d57604036600319011261027d57610fb7600435610f576121e4565b90606060c0604051610f68816120e2565b60008152600060208201526000604082015260008382015260006080820152600060a08201520152610fb26102f282600052600960205260018060a01b0360406000205416151590565b61331f565b60405190610fc4826120e2565b8054906001600160401b0380831684526020840190808460401c1682526040850190808560801c168252606086019460c01c855260ff60018501541690608087019060038310156103c957602096818995816110376003610b8e9b61106f99895260a060028201549b019a8b5201612717565b9860c08d01998a52816040519d8e9d8e52511660208d0152511660408b015251166060890152511660808701525160a08601906123c6565b5160c08401525160e080840152610100830190612192565b3461027d5760c0610f29600a6110a861109f366123b0565b90610b2d612620565b50016127bc565b3461027d5761026036600319011261027d576110c9612364565b6110d1612377565b906110da61238a565b6110e261239d565b9260a43593600585101561027d576001600160401b036101443581811161027d576111119036906004016121b7565b906101643583811161027d5761112b9036906004016121b7565b9490936101843590811161027d576111479036906004016121b7565b97909660c0366101a319011261027d5760015461117890336001600160a01b03918216149081156112105750612572565b604051996111858b6120ab565b61ffff9b6101a4358d8116810361027d578c526101c4358d8116810361027d5760208d01526101e4358d8116810361027d5760408d0152610204358d8116810361027d5760608d0152610224358d8116810361027d5760808d0152610244359c8d168d0361027d5761026d9c60a08d01526101243594610104359460e4359460c43594600435612d35565b90506000541633148d610215565b3461027d57602036600319011261027d5760043561123a612652565b5060008181526009602052604090205461125e906001600160a01b031615156125ae565b806000526007602052604060002054906112798215156126d9565b6000526007602052604060002090600019810190811161088e57610b7c610b8291610b8e93612477565b3461027d57608036600319011261027d576112bc6121e4565b6064356001600160401b03811161027d576112db9036906004016121b7565b90916112fb60018060a01b03806001541633149081156104735750612572565b600435600090815260096020526040902054611321906001600160a01b031615156125ae565b600961132f82600435612c7a565b01600160ff19825416179055600435600052602092600b84526040600020546001810180911161088e576001600160401b031692600435600052600b855260406000209160405190611380826120e2565b8582528682016001600160401b038616815260408301926001600160401b034216845260608101600081526113c860808301946000865260a084019760443589523691612431565b9660c083019788528054600160401b81101561159b576113ed916001820181556125ec565b9590956115b15791519251915190516001600160c01b031960c09190911b1660809190911b67ffffffffffffffff60801b166001600160401b0390931660409290921b67ffffffffffffffff60401b169190911791909117178255519160038310156103c95761146260039360018401612608565b5160028201550190518051906001600160401b03821161159b576114908261148a85546124c1565b856124fb565b8590601f831160011461150957827fe95840e66082a0861ce8bd81aeca7b1ec09caf20c05b9aae8892d7f784fc9beb95936001600160401b0395936114ec936000926114fe575b50508160011b916000199060031b1c19161790565b90555b604051938452169260043592a3005b0151905089806114d7565b90601f1983169184600052876000209260005b898282106115855750509260019285927fe95840e66082a0861ce8bd81aeca7b1ec09caf20c05b9aae8892d7f784fc9beb98966001600160401b0398961061156c575b505050811b0190556114ef565b015160001960f88460031b161c1916905588808061155f565b600185968293968601518155019501930161151c565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052600060045260246000fd5b604036600319011261027d576004356001600160401b03811161027d576115f29036906004016121b7565b6024356001600160401b03811161027d576116119036906004016121b7565b9091908115611ffb578015611fc1576002549161163060035484612417565b3410611f875761164c6116438434612424565b93600454612417565b60045561166361165d368388612431565b33612c0e565b6000526008602052604060002054938415611c97575b8460005260066020526003604060002001611695858254612417565b90558460005260076020526040600020549260018401841161088e5785600052600760205260406000206040516116cb816120ab565b6000815260006020820152600060408201526000606082015260006080820152600060a08201526001600160401b03600160405197611709896120c6565b011686526001600160401b0342166020870152600060408701526000606087015260006080870152600060a0870152600060c0870152600060e087015260006101008701526000610120870152600061014087015260405161176a81612133565b6000815261016087015260405161178081612133565b60008152610180870152611795368486612431565b6101a087015260006101c087015260006101e08701526102008601528054600160401b81101561159b576117ce91600182018155612477565b9790976115b1578451602086015160408088015160608901516080808b015160a0808d015160e01b6001600160e01b0319166001600160401b039098169690951b67ffffffffffffffff60401b169590951763ffffffff60801b9390911b929092169190911763ffffffff60a01b9190921b161763ffffffff60c01b60c09290921b919091161717885560c085015160058110156103c9576118739060018a016124a9565b60e085015160028901556101008501516003890155610120850151600489015561014085015160058901556101608501518051906001600160401b03821161159b576118cf826118c660068d01546124c1565b60068d016124fb565b602090601f8311600114611c29576118ff929160009183611bb05750508160011b916000199060031b1c19161790565b60068901555b6101808501518051906001600160401b03821161159b576119368261192d60078d01546124c1565b60078d016124fb565b602090601f8311600114611bbb57611966929160009183611bb05750508160011b916000199060031b1c19161790565b60078901555b6101a0850151948551986001600160401b038a1161159b578989976119a360209c61199a60088601546124c1565b600886016124fb565b8b90601f8311600114611b0557600a611aca94611a05857fbd6d3df44aaa1231a5f51af5e02c3a67047dc0ebe0a72cb455ffd7eb80172a219c9b9996611ad79b999661020096600092611afa5750508160011b916000199060031b1c19161790565b60088201555b60098101611a2c6101c08601511515829060ff801983541691151516179055565b6101e0850151151561ff0082549160081b169061ff0019161790550191015161ffff8151169082549163ffff00008f83015160101b1665ffff00000000604084015160201b169067ffff000000000000606085015160301b169261ffff60401b608086015160401b169460a061ffff60501b91015160501b16956001600160601b031916171717171717905560405195608087526080870191612551565b918483038a860152612551565b9360408201526001600160401b03421660608201528033940390a3604051908152f35b0151905038806114d7565b60088493929a999897969594016000528c6000209060005b601f1984168110611b965750611ad797969593600184610200947fbd6d3df44aaa1231a5f51af5e02c3a67047dc0ebe0a72cb455ffd7eb80172a219d9e600a95611aca9a98601f19811610611b7d575b505050811b016008820155611a0b565b015160001960f88460031b161c19169055388080611b6d565b818c015183559a8e019a8d9a506001909201918e01611b1d565b015190508b806114d7565b90601f1983169160078c0160005260206000209260005b818110611c115750908460019594939210611bf8575b505050811b01600789015561196c565b015160001960f88460031b161c191690558a8080611be8565b92936020600181928786015181550195019301611bd2565b90601f1983169160068c0160005260206000209260005b818110611c7f5750908460019594939210611c66575b505050811b016006890155611905565b015160001960f88460031b161c191690558a8080611c56565b92936020600181928786015181550195019301611c40565b93506005546001810180821161088e576005558060005260096020526040600020336001600160601b0360a01b82541617905533600052600a6020526040600020805460018101811161088e576001019055611cf761165d368489612431565b600052600860205280604060002055604051611d128161208f565b338152611d20368489612431565b6020820190815282604083015260006060830152600060808301526001600160401b03421660a0830152600060c0830152600060e083015282600052600660205260406000209060018060a01b038351166001600160601b0360a01b835416178255518051906001600160401b03821161159b57611dae82611da560018601546124c1565b600186016124fb565b602090601f8311600114611f0957611e939493611ded8463ffffffff9560e095600495600092611efe5750508160011b916000199060031b1c19161790565b60018201555b60408501516002820155606085015160038201550192611e2560808201511515859060ff801983541691151516179055565b60a0810151845460c083015170ffffffffffffffffffffffffffffffff001990911660089290921b68ffffffffffffffff00169190911760489190911b67ffffffffffffffff60481b161784550151825463ffffffff60881b1916911660881b63ffffffff60881b16179055565b604051813360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a460208152817f0d063c6022bff16d09991a9f91882ffa112f5fb2529136f65eb4c77bbd047e43339280611ef560208201888d612551565b0390a393611679565b015190508f806114d7565b906001840160005260206000209160005b601f1985168110611f6f57509360018460e094600494611e93999863ffffffff98601f19811610611f56575b505050811b016001820155611df3565b015160001960f88460031b161c191690558e8080611f46565b91926020600181928685015181550194019201611f1a565b60405162461bcd60e51b8152602060048201526012602482015271494e53554646494349454e545f56414c554560701b6044820152606490fd5b60405162461bcd60e51b8152602060048201526012602482015271115354151657d3505392519154d517d5549360721b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f454d5054595f4147454e545f4e414d4560801b6044820152606490fd5b3461027d57600036600319011261027d5780612051610b8e92612118565b601781527f4167656e74204175646974204964656e746974792056320000000000000000006020820152604051918291602083526020830190612192565b61010081019081106001600160401b0382111761159b57604052565b60c081019081106001600160401b0382111761159b57604052565b61022081019081106001600160401b0382111761159b57604052565b60e081019081106001600160401b0382111761159b57604052565b606081019081106001600160401b0382111761159b57604052565b604081019081106001600160401b0382111761159b57604052565b602081019081106001600160401b0382111761159b57604052565b90601f801991011681019081106001600160401b0382111761159b57604052565b60005b8381106121825750506000910152565b8181015183820152602001612172565b906020916121ab8151809281855285808601910161216f565b601f01601f1916010190565b9181601f8401121561027d578235916001600160401b03831161027d576020838186019501011161027d57565b602435906001600160401b038216820361027d57565b9060058210156103c95752565b60a0908161ffff91828151168552826020820151166020860152826040820151166040860152826060820151166060860152826080820151166080860152015116910152565b61236190602081526001600160401b038084511660208301526020840151166040820152604083015163ffffffff80911660608301528060608501511660808301528060808501511660a083015260a08401511660c08201526122b860c084015160e08301906121fa565b61022060e084015161010090818401528401516101209081840152840151610140908184015284015161016090818401528401519361233b612309610180966102c0888701526102e0860190612192565b95820151612326601f19976101a092898883030184890152612192565b908301516101c0978683030188870152612192565b948101516101e09015158185015281015190610200911515828501520151910190612207565b90565b6024359063ffffffff8216820361027d57565b6044359063ffffffff8216820361027d57565b6064359063ffffffff8216820361027d57565b6084359063ffffffff8216820361027d57565b604090600319011261027d576004359060243590565b9060038210156103c95752565b608090600319011261027d57600435906024356001600160401b038116810361027d57906044359060643590565b600435906001600160a01b038216820361027d57565b9190820180921161088e57565b9190820391821161088e57565b9291926001600160401b03821161159b576040519161245a601f8201601f19166020018461214e565b82948184528183011161027d578281602093846000960137010152565b805482101561249357600052600b602060002091020190600090565b634e487b7160e01b600052603260045260246000fd5b9060058110156103c95760ff80198354169116179055565b90600182811c921680156124f1575b60208310146124db57565b634e487b7160e01b600052602260045260246000fd5b91607f16916124d0565b90601f811161250957505050565b6000916000526020600020906020601f850160051c83019410612547575b601f0160051c01915b82811061253c57505050565b818155600101612530565b9092508290612527565b908060209392818452848401376000828201840152601f01601f1916010190565b1561257957565b60405162461bcd60e51b815260206004820152600d60248201526c27a7262cafa7a822a920aa27a960991b6044820152606490fd5b156125b557565b60405162461bcd60e51b815260206004820152600f60248201526e1513d2d15397d393d517d193d55391608a1b6044820152606490fd5b80548210156124935760005260206000209060021b0190600090565b9060038110156103c95760ff80198354169116179055565b6040519061262d826120ab565b8160a06000918281528260208201528260408201528260608201528260808201520152565b6040519061265f826120c6565b8160008082528060208301528060408301528060608301528060808301528060a08301528060c08301528060e08301528061010083015280610120830152806101408301526060610160830152606061018083015260606101a0830152806101c08301526101e08201526102006126d4612620565b910152565b156126e057565b60405162461bcd60e51b815260206004820152600f60248201526e1393d7d05551125517d49150d3d491608a1b6044820152606490fd5b9060405191826000825461272a816124c1565b9081845260209460019160018116908160001461279a575060011461275b575b5050506127599250038361214e565b565b600090815285812095935091905b818310612782575050612759935082010138808061274a565b85548884018501529485019487945091830191612769565b9250505061275994925060ff191682840152151560051b82010138808061274a565b906040516127c9816120ab565b60a081935461ffff908181168452818160101c166020850152818160201c166040850152818160301c166060850152818160401c16608085015260501c16910152565b90604051612819816120c6565b809280546001600160401b0380821684528160401c16602084015263ffffffff808260801c166040850152808260a01c1660608501528160c01c16608084015260e01c60a083015260ff6001820154169060058210156103c957600a6126d4916102009360c0860152600281015460e08601526003810154610100860152600481015461012086015260058101546101408601526128b960068201612717565b6101608601526128cb60078201612717565b6101808601526128dd60088201612717565b6101a086015260ff600982015481811615156101c088015260081c1615156101e0860152016127bc565b1561290e57565b60405162461bcd60e51b8152602060048201526013602482015272494e4445585f4f55545f4f465f424f554e445360681b6044820152606490fd5b8115612953570490565b634e487b7160e01b600052601260045260246000fd5b612971612620565b50600081815260096020526040902054612995906001600160a01b031615156125ae565b600090808252600760205260408220546129b08115156126d9565b829083849285869187948897895b8a838210612a8c57505050508615612a55578697509286959286809693819661ffff96878096816129f181978296612949565b169e6129fc91612949565b169b612a0791612949565b1696612a1291612949565b1695612a1d91612949565b1694612a2891612949565b169360405195612a37876120ab565b8652602086015260408501526060840152608083015260a082015290565b5050505050505060405190612a69826120ab565b80825280602083015280604083015280606083015280608083015260a082015290565b600a6110a88360408487612aa69652600760205220612477565b61ffff808251168015801590612bb1575b8015612ba2575b8015612b93575b8015612b84575b8015612b75575b612ae3575b5050506001016129be565b612af6919298979b99969c9a939c612417565b9481602089015116612b0791612417565b9781604089015116612b1891612417565b9981606089015116612b2991612417565b9581608089015116612b3a91612417565b9660a0015116612b4991612417565b966000198114612b6157600180910199903880612ad8565b634e487b7160e01b8b52601160045260248bfd5b508160a0840151161515612ad3565b50816080840151161515612acc565b50816060840151161515612ac5565b50816040840151161515612abe565b50816020840151161515612ab7565b15612bc757565b60405162461bcd60e51b815260206004820152600a60248201526927a7262cafa7aba722a960b11b6044820152606490fd5b90600163ffffffff8093160191821161088e57565b90612c5b6035604051809360208201956001600160601b03199060601b168652601d60f91b6034830152612c4b815180926020868601910161216f565b810103601581018452018261214e565b51902090565b6001600160401b03908116600019019190821161088e57565b906001600160401b039081811615612cfd57612c9590612c61565b16816000526007602052604060002054811015612cc657612cc29160005260076020526040600020612477565b5090565b60405162461bcd60e51b815260206004820152600f60248201526e105551125517d393d517d193d55391608a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f1253959053125117d05551125517d25160821b6044820152606490fd5b9f9a97949d989593919f9e99969b9c9e60a052608052612d6f6102f260a051600052600960205260018060a01b0360406000205416151590565b60058d10156103c9578c156132e95760a0516000526007602052604060002054612d9a8115156126d9565b60a0516000526007602052604060002090600019810190811161088e57612dc091612477565b509e8f6001015460ff1660058110156103c9576132b1578f612e9e8f93612e7e612ea496612e5e600196612e206001600160401b034216889067ffffffffffffffff60401b82549160401b169067ffffffffffffffff60401b1916179055565b60808051885463ffffffff60801b1916911b63ffffffff60801b16178755865463ffffffff60a01b191660a09190911b63ffffffff60a01b16178655565b845463ffffffff60c01b191660c09190911b63ffffffff60c01b16178455565b82546001600160e01b031660e09190911b6001600160e01b031916178255565b016124a9565b60028d01558760038d015560048c015560058b01556001600160401b03821161159b57612ed8826118c660068d01546124c1565b600090601f831160011461324057612f089291600091836131225750508160011b916000199060031b1c19161790565b60068901555b6001600160401b03871161159b57612f3687612f2d60078b01546124c1565b60078b016124fb565b600087601f81116001146131d35780612f65926000916131c8575b508160011b916000199060031b1c19161790565b60078901555b6001600160401b03821161159b57612f9382612f8a60088b01546124c1565b60088b016124fb565b600090601f831160011461312d5792612fef836130fa97947f80f307f5798ed339302133e4f353681cc7f5cc7333f5c829480b6812cf527f3399979461311d976000926131225750508160011b916000199060031b1c19161790565b60088a01555b600a89019061ffff8151169082549163ffff0000602083015160101b1665ffff00000000604084015160201b169067ffff000000000000606085015160301b169261ffff60401b608086015160401b169460a061ffff60501b91015160501b16956001600160601b031916171717171717905560a05160005260066020526001600160401b036004604060002001986130b38242168b9067ffffffffffffffff60481b82549160481b169067ffffffffffffffff60481b1916179055565b6130eb63ffffffff9a6130cb8c825460881c16612bf9565b815463ffffffff60881b191660889190911b63ffffffff60881b16179055565b541697604051958680966121fa565b60805116602085015260408401526080606084015260a051956080840191612551565b0390a3565b0135905038806114d7565b6008890160005260206000209160005b601f19851681106131b05750837f80f307f5798ed339302133e4f353681cc7f5cc7333f5c829480b6812cf527f3398969361311d96936001936130fa9a97601f19811610613196575b505050811b0160088a0155612ff5565b0135600019600384901b60f8161c19169055388080613186565b9092602060018192868601358155019401910161313d565b905087013538612f51565b506007890160005260206000209060005b601f198a168110613228575088601f1981161061320e575b5050600187811b016007890155612f6b565b86013560001960038a901b60f8161c1916905538806131fc565b9091602060018192858b0135815501930191016131e4565b60068b939293016000526020600020906000935b601f1984168510613299576001945083601f1981161061327f575b505050811b016006890155612f0e565b0135600019600384901b60f8161c1916905538808061326f565b81810135835560209485019460019093019201613254565b60405162461bcd60e51b815260206004820152601060248201526f1393d7d4115391125391d7d05551125560821b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d494e56414c49445f53544154555360901b6044820152606490fd5b906001600160401b03908181161561339f5761333a90612c61565b1681600052600b60205260406000205481101561336757612cc291600052600b60205260406000206125ec565b60405162461bcd60e51b815260206004820152601060248201526f10541411505317d393d517d193d5539160821b6044820152606490fd5b60405162461bcd60e51b81526020600482015260116024820152701253959053125117d0541411505317d251607a1b6044820152606490fdfea264697066735822122090e664966b494d015056388343e56cb1af27873c04b2f7679feb1d5468be924264736f6c63430008180033", + "deployedBytecode": "0x60c080604052600436101561001357600080fd5b60003560e01c90816306fdde03146120335750806319b36b1d146115c75780631a0649e3146112a35780631d57330d1461121e5780631f5d5a37146110af5780632e5819a6146110875780632f22afdb14610f385780632f26adcd14610f0b578063347c19cd14610ebc5780635662bce814610da5578063570ca73514610d7c5780636352211e14610d3d57806370a0823114610cc957806389370d8b14610c1e5780638abdf5aa14610c005780638da5cb5b14610bd757806395d89b4114610b925780639d4f040714610b0d578063aa7517e114610aef578063b3ab15fb14610a3e578063ca05588a146109e3578063ccb4ebe014610697578063d52fcd2814610633578063f098a7ae146104d0578063f5b6119514610481578063f84c39c9146103ed578063f8ba2fdc146102a0578063fd2c42cc146102825763fda5d1ff1461015e57600080fd5b3461027d576101a036600319011261027d57610178612364565b610180612377565b61018861238a565b61019061239d565b90600560a435101561027d576001600160401b03936101443585811161027d576101be9036906004016121b7565b6101649291923587811161027d576101da9036906004016121b7565b9390926101843598891161027d576101f961026d9936906004016121b7565b97909661021b60018060a01b038060015416331490811561026f575b50612572565b604051996102288b6120ab565b60008b52600060208c0152600060408c0152600060608c0152600060808c0152600060a08c01526101243593610104359360e4359360c4359360a43593600435612d35565b005b905060005416331438610215565b600080fd5b3461027d57600036600319011261027d576020600454604051908152f35b3461027d576102ae366123d3565b9092916102cf60018060a01b03806001541633149081156103df5750612572565b6000838152600960205260409020546102f7906001600160a01b031615156125ae565b6125ae565b6103018184612c7a565b600181019160ff83541660058110156103c957600303610390577fd7e851d789b6e3784feb9febce0117765574999009e64543881911a79eb596629360096001600160401b0393604095886000526006602052600387600020016103668b8254612417565b9055805460ff1916600417905501805461ff001916610100179055835196875260208701521693a3005b60405162461bcd60e51b8152602060048201526011602482015270105551125517d393d517d4d31054d21151607a1b6044820152606490fd5b634e487b7160e01b600052602160045260246000fd5b905060005416331486610215565b3461027d57604036600319011261027d576004356001600160401b036104116121e4565b60015461043290336001600160a01b03918216149081156104735750612572565b600961043e8285612c7a565b01805460ff1916600117905516907f5ef8bd082609dcf89dfc86ebb395fcd189183ad5e5c37d83b7123ff8da8b6e8d600080a3005b905060005416331485610215565b3461027d57602036600319011261027d576004356000818152600960205260409020546104b8906001600160a01b031615156125ae565b600052600b6020526020604060002054604051908152f35b3461027d5760208060031936011261027d57600435600060e06040516104f58161208f565b8281526060858201528260408201528260608201528260808201528260a08201528260c082015201526105406102f282600052600960205260018060a01b0360406000205416151590565b600052600681526040600020604051906105598261208f565b80546001600160a01b0390811683529160409061057860018401612717565b8582019081526002840154938383019485526004600382015491606085019283520154916080840160ff8416151581526001600160401b0392839160a0870191838760081c16835261060660c0890195858960481c16875263ffffffff998a60e082019a60881c168a528b519e8f9e8f928284525116910152518c6101009b8c9101526101208d0190612192565b995160608c01525160808b015251151560a08a0152511660c0880152511660e08601525116908301520390f35b3461027d57604036600319011261027d5761064c612401565b602435906001600160401b03821161027d5761067961067261067f9336906004016121b7565b3691612431565b90612c0e565b60005260086020526020604060002054604051908152f35b3461027d57606036600319011261027d576004356106b36121e4565b60443560038082101561027d576001546106e190336001600160a01b03918216149081156103df5750612572565b600084815260096020526040902054610704906001600160a01b031615156125ae565b81156109ac57610714838561331f565b6001810160ff815416838110156103c957610967578361073391612608565b80546001600160c01b03164260c01b6001600160c01b0319161781556001600160401b039285600052600c602052604060002091600182146000146108a4576001835463ffffffff610786818316612bf9565b169063ffffffff19161780855560401c850b01637fffffff198112637fffffff82131761088e576107e2916107d78792869081549060401b63ffffffff60401b169063ffffffff60401b1916179055565b5460401c1687612c7a565b6001810180549560ff87169060058210156103c9577fd64cdce0b6e0444ba2363841c2f716505f215d1dc28a2f9d83450bfe55e20e04986020988b957f90239a2ae000675dd3b0dbe1678bc62ab9dd686eeffb26924130d8ebb21df352958a8c961461086c575b5050505b61085a60405180976123c6565b1693a35460401c900b604051908152a2005b600460099360ff19161790550161010061ff00198254161790558b8080610849565b634e487b7160e01b600052601160045260246000fd5b50815467ffffffff000000006108c263ffffffff8360201c16612bf9565b60201b169067ffffffff000000001916178083556000199060401c840b0193637fffffff8513637fffffff1986121761088e577f90239a2ae000675dd3b0dbe1678bc62ab9dd686eeffb26924130d8ebb21df352602088927fd64cdce0b6e0444ba2363841c2f716505f215d1dc28a2f9d83450bfe55e20e04986109628399889081549060401b63ffffffff60401b169063ffffffff60401b1916179055565b61084d565b60405162461bcd60e51b815260206004820152601760248201527f41505045414c5f414c52454144595f5245534f4c5645440000000000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f4f5554434f4d4560881b6044820152606490fd5b3461027d577f335f5afc83fe8c5a011a96dc39bcce9fb9d46fb5986502f7040e76e28b0361236040610a14366123b0565b610a2960018060a01b03600054163314612bc0565b816002558060035582519182526020820152a1005b3461027d57602036600319011261027d57610a57612401565b6000546001600160a01b03918291610a729083163314612bc0565b16908115610ab757600154826001600160601b0360a01b821617600155167ffbe5b6cbafb274f445d7fed869dc77a838d8243a22c460de156560e8857cad03600080a3005b60405162461bcd60e51b815260206004820152601060248201526f24a72b20a624a22fa7a822a920aa27a960811b6044820152606490fd5b3461027d57600036600319011261027d576020600354604051908152f35b3461027d57610b8e610b82610b7c610b24366123b0565b90610b2d612652565b50600081815260096020526040902054610b51906001600160a01b031615156125ae565b806000526007602052610b6a6040600020548310612907565b60005260076020526040600020612477565b5061280c565b6040519182918261224d565b0390f35b3461027d57600036600319011261027d57610b8e604051610bb281612118565b600481526320a0a49960e11b6020820152604051918291602083526020830190612192565b3461027d57600036600319011261027d576000546040516001600160a01b039091168152602090f35b3461027d57600036600319011261027d576020600254604051908152f35b3461027d5760208060031936011261027d57606090600435600060408051610c45816120fd565b8281528481018390520152600081815260096020526040902054610c73906001600160a01b031615156125ae565b600052600c815260406000209060405191610c8d836120fd565b549063ffffffff808316938481526040838201918386861c168352019360401c60030b84526040519485525116908301525160030b6040820152f35b3461027d57602036600319011261027d576001600160a01b03610cea612401565b168015610d0957600052600a6020526020604060002054604051908152f35b60405162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b6044820152606490fd5b3461027d57602036600319011261027d576004356000526009602052602060018060a01b0360406000205416610d748115156125ae565b604051908152f35b3461027d57600036600319011261027d576001546040516001600160a01b039091168152602090f35b3461027d57610db3366123d3565b909291610dd460018060a01b03806001541633149081156103df5750612572565b600083815260096020526040902054610df7906001600160a01b031615156125ae565b82600052600660205260406000206003810191825493848711610e83577f60a77a9907fdd72fa9c1aed2ee36350704289df2e7956a74c741287c6fcefb79946003600160046001600160401b0396604098610e5c8d610e568a8f612c7a565b97612424565b9055019260ff199382858254161790550191825416179055835196875260208701521693a3005b60405162461bcd60e51b8152602060048201526011602482015270125394d551919250d251539517d093d391607a1b6044820152606490fd5b3461027d57602036600319011261027d57600435600081815260096020526040902054610ef3906001600160a01b031615156125ae565b60005260076020526020604060002054604051908152f35b3461027d57602036600319011261027d5760c0610f29600435612969565b610f366040518092612207565bf35b3461027d57604036600319011261027d57610fb7600435610f576121e4565b90606060c0604051610f68816120e2565b60008152600060208201526000604082015260008382015260006080820152600060a08201520152610fb26102f282600052600960205260018060a01b0360406000205416151590565b61331f565b60405190610fc4826120e2565b8054906001600160401b0380831684526020840190808460401c1682526040850190808560801c168252606086019460c01c855260ff60018501541690608087019060038310156103c957602096818995816110376003610b8e9b61106f99895260a060028201549b019a8b5201612717565b9860c08d01998a52816040519d8e9d8e52511660208d0152511660408b015251166060890152511660808701525160a08601906123c6565b5160c08401525160e080840152610100830190612192565b3461027d5760c0610f29600a6110a861109f366123b0565b90610b2d612620565b50016127bc565b3461027d5761026036600319011261027d576110c9612364565b6110d1612377565b906110da61238a565b6110e261239d565b9260a43593600585101561027d576001600160401b036101443581811161027d576111119036906004016121b7565b906101643583811161027d5761112b9036906004016121b7565b9490936101843590811161027d576111479036906004016121b7565b97909660c0366101a319011261027d5760015461117890336001600160a01b03918216149081156112105750612572565b604051996111858b6120ab565b61ffff9b6101a4358d8116810361027d578c526101c4358d8116810361027d5760208d01526101e4358d8116810361027d5760408d0152610204358d8116810361027d5760608d0152610224358d8116810361027d5760808d0152610244359c8d168d0361027d5761026d9c60a08d01526101243594610104359460e4359460c43594600435612d35565b90506000541633148d610215565b3461027d57602036600319011261027d5760043561123a612652565b5060008181526009602052604090205461125e906001600160a01b031615156125ae565b806000526007602052604060002054906112798215156126d9565b6000526007602052604060002090600019810190811161088e57610b7c610b8291610b8e93612477565b3461027d57608036600319011261027d576112bc6121e4565b6064356001600160401b03811161027d576112db9036906004016121b7565b90916112fb60018060a01b03806001541633149081156104735750612572565b600435600090815260096020526040902054611321906001600160a01b031615156125ae565b600961132f82600435612c7a565b01600160ff19825416179055600435600052602092600b84526040600020546001810180911161088e576001600160401b031692600435600052600b855260406000209160405190611380826120e2565b8582528682016001600160401b038616815260408301926001600160401b034216845260608101600081526113c860808301946000865260a084019760443589523691612431565b9660c083019788528054600160401b81101561159b576113ed916001820181556125ec565b9590956115b15791519251915190516001600160c01b031960c09190911b1660809190911b67ffffffffffffffff60801b166001600160401b0390931660409290921b67ffffffffffffffff60401b169190911791909117178255519160038310156103c95761146260039360018401612608565b5160028201550190518051906001600160401b03821161159b576114908261148a85546124c1565b856124fb565b8590601f831160011461150957827fe95840e66082a0861ce8bd81aeca7b1ec09caf20c05b9aae8892d7f784fc9beb95936001600160401b0395936114ec936000926114fe575b50508160011b916000199060031b1c19161790565b90555b604051938452169260043592a3005b0151905089806114d7565b90601f1983169184600052876000209260005b898282106115855750509260019285927fe95840e66082a0861ce8bd81aeca7b1ec09caf20c05b9aae8892d7f784fc9beb98966001600160401b0398961061156c575b505050811b0190556114ef565b015160001960f88460031b161c1916905588808061155f565b600185968293968601518155019501930161151c565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052600060045260246000fd5b604036600319011261027d576004356001600160401b03811161027d576115f29036906004016121b7565b6024356001600160401b03811161027d576116119036906004016121b7565b9091908115611ffb578015611fc1576002549161163060035484612417565b3410611f875761164c6116438434612424565b93600454612417565b60045561166361165d368388612431565b33612c0e565b6000526008602052604060002054938415611c97575b8460005260066020526003604060002001611695858254612417565b90558460005260076020526040600020549260018401841161088e5785600052600760205260406000206040516116cb816120ab565b6000815260006020820152600060408201526000606082015260006080820152600060a08201526001600160401b03600160405197611709896120c6565b011686526001600160401b0342166020870152600060408701526000606087015260006080870152600060a0870152600060c0870152600060e087015260006101008701526000610120870152600061014087015260405161176a81612133565b6000815261016087015260405161178081612133565b60008152610180870152611795368486612431565b6101a087015260006101c087015260006101e08701526102008601528054600160401b81101561159b576117ce91600182018155612477565b9790976115b1578451602086015160408088015160608901516080808b015160a0808d015160e01b6001600160e01b0319166001600160401b039098169690951b67ffffffffffffffff60401b169590951763ffffffff60801b9390911b929092169190911763ffffffff60a01b9190921b161763ffffffff60c01b60c09290921b919091161717885560c085015160058110156103c9576118739060018a016124a9565b60e085015160028901556101008501516003890155610120850151600489015561014085015160058901556101608501518051906001600160401b03821161159b576118cf826118c660068d01546124c1565b60068d016124fb565b602090601f8311600114611c29576118ff929160009183611bb05750508160011b916000199060031b1c19161790565b60068901555b6101808501518051906001600160401b03821161159b576119368261192d60078d01546124c1565b60078d016124fb565b602090601f8311600114611bbb57611966929160009183611bb05750508160011b916000199060031b1c19161790565b60078901555b6101a0850151948551986001600160401b038a1161159b578989976119a360209c61199a60088601546124c1565b600886016124fb565b8b90601f8311600114611b0557600a611aca94611a05857fbd6d3df44aaa1231a5f51af5e02c3a67047dc0ebe0a72cb455ffd7eb80172a219c9b9996611ad79b999661020096600092611afa5750508160011b916000199060031b1c19161790565b60088201555b60098101611a2c6101c08601511515829060ff801983541691151516179055565b6101e0850151151561ff0082549160081b169061ff0019161790550191015161ffff8151169082549163ffff00008f83015160101b1665ffff00000000604084015160201b169067ffff000000000000606085015160301b169261ffff60401b608086015160401b169460a061ffff60501b91015160501b16956001600160601b031916171717171717905560405195608087526080870191612551565b918483038a860152612551565b9360408201526001600160401b03421660608201528033940390a3604051908152f35b0151905038806114d7565b60088493929a999897969594016000528c6000209060005b601f1984168110611b965750611ad797969593600184610200947fbd6d3df44aaa1231a5f51af5e02c3a67047dc0ebe0a72cb455ffd7eb80172a219d9e600a95611aca9a98601f19811610611b7d575b505050811b016008820155611a0b565b015160001960f88460031b161c19169055388080611b6d565b818c015183559a8e019a8d9a506001909201918e01611b1d565b015190508b806114d7565b90601f1983169160078c0160005260206000209260005b818110611c115750908460019594939210611bf8575b505050811b01600789015561196c565b015160001960f88460031b161c191690558a8080611be8565b92936020600181928786015181550195019301611bd2565b90601f1983169160068c0160005260206000209260005b818110611c7f5750908460019594939210611c66575b505050811b016006890155611905565b015160001960f88460031b161c191690558a8080611c56565b92936020600181928786015181550195019301611c40565b93506005546001810180821161088e576005558060005260096020526040600020336001600160601b0360a01b82541617905533600052600a6020526040600020805460018101811161088e576001019055611cf761165d368489612431565b600052600860205280604060002055604051611d128161208f565b338152611d20368489612431565b6020820190815282604083015260006060830152600060808301526001600160401b03421660a0830152600060c0830152600060e083015282600052600660205260406000209060018060a01b038351166001600160601b0360a01b835416178255518051906001600160401b03821161159b57611dae82611da560018601546124c1565b600186016124fb565b602090601f8311600114611f0957611e939493611ded8463ffffffff9560e095600495600092611efe5750508160011b916000199060031b1c19161790565b60018201555b60408501516002820155606085015160038201550192611e2560808201511515859060ff801983541691151516179055565b60a0810151845460c083015170ffffffffffffffffffffffffffffffff001990911660089290921b68ffffffffffffffff00169190911760489190911b67ffffffffffffffff60481b161784550151825463ffffffff60881b1916911660881b63ffffffff60881b16179055565b604051813360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a460208152817f0d063c6022bff16d09991a9f91882ffa112f5fb2529136f65eb4c77bbd047e43339280611ef560208201888d612551565b0390a393611679565b015190508f806114d7565b906001840160005260206000209160005b601f1985168110611f6f57509360018460e094600494611e93999863ffffffff98601f19811610611f56575b505050811b016001820155611df3565b015160001960f88460031b161c191690558e8080611f46565b91926020600181928685015181550194019201611f1a565b60405162461bcd60e51b8152602060048201526012602482015271494e53554646494349454e545f56414c554560701b6044820152606490fd5b60405162461bcd60e51b8152602060048201526012602482015271115354151657d3505392519154d517d5549360721b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f454d5054595f4147454e545f4e414d4560801b6044820152606490fd5b3461027d57600036600319011261027d5780612051610b8e92612118565b601781527f4167656e74204175646974204964656e746974792056320000000000000000006020820152604051918291602083526020830190612192565b61010081019081106001600160401b0382111761159b57604052565b60c081019081106001600160401b0382111761159b57604052565b61022081019081106001600160401b0382111761159b57604052565b60e081019081106001600160401b0382111761159b57604052565b606081019081106001600160401b0382111761159b57604052565b604081019081106001600160401b0382111761159b57604052565b602081019081106001600160401b0382111761159b57604052565b90601f801991011681019081106001600160401b0382111761159b57604052565b60005b8381106121825750506000910152565b8181015183820152602001612172565b906020916121ab8151809281855285808601910161216f565b601f01601f1916010190565b9181601f8401121561027d578235916001600160401b03831161027d576020838186019501011161027d57565b602435906001600160401b038216820361027d57565b9060058210156103c95752565b60a0908161ffff91828151168552826020820151166020860152826040820151166040860152826060820151166060860152826080820151166080860152015116910152565b61236190602081526001600160401b038084511660208301526020840151166040820152604083015163ffffffff80911660608301528060608501511660808301528060808501511660a083015260a08401511660c08201526122b860c084015160e08301906121fa565b61022060e084015161010090818401528401516101209081840152840151610140908184015284015161016090818401528401519361233b612309610180966102c0888701526102e0860190612192565b95820151612326601f19976101a092898883030184890152612192565b908301516101c0978683030188870152612192565b948101516101e09015158185015281015190610200911515828501520151910190612207565b90565b6024359063ffffffff8216820361027d57565b6044359063ffffffff8216820361027d57565b6064359063ffffffff8216820361027d57565b6084359063ffffffff8216820361027d57565b604090600319011261027d576004359060243590565b9060038210156103c95752565b608090600319011261027d57600435906024356001600160401b038116810361027d57906044359060643590565b600435906001600160a01b038216820361027d57565b9190820180921161088e57565b9190820391821161088e57565b9291926001600160401b03821161159b576040519161245a601f8201601f19166020018461214e565b82948184528183011161027d578281602093846000960137010152565b805482101561249357600052600b602060002091020190600090565b634e487b7160e01b600052603260045260246000fd5b9060058110156103c95760ff80198354169116179055565b90600182811c921680156124f1575b60208310146124db57565b634e487b7160e01b600052602260045260246000fd5b91607f16916124d0565b90601f811161250957505050565b6000916000526020600020906020601f850160051c83019410612547575b601f0160051c01915b82811061253c57505050565b818155600101612530565b9092508290612527565b908060209392818452848401376000828201840152601f01601f1916010190565b1561257957565b60405162461bcd60e51b815260206004820152600d60248201526c27a7262cafa7a822a920aa27a960991b6044820152606490fd5b156125b557565b60405162461bcd60e51b815260206004820152600f60248201526e1513d2d15397d393d517d193d55391608a1b6044820152606490fd5b80548210156124935760005260206000209060021b0190600090565b9060038110156103c95760ff80198354169116179055565b6040519061262d826120ab565b8160a06000918281528260208201528260408201528260608201528260808201520152565b6040519061265f826120c6565b8160008082528060208301528060408301528060608301528060808301528060a08301528060c08301528060e08301528061010083015280610120830152806101408301526060610160830152606061018083015260606101a0830152806101c08301526101e08201526102006126d4612620565b910152565b156126e057565b60405162461bcd60e51b815260206004820152600f60248201526e1393d7d05551125517d49150d3d491608a1b6044820152606490fd5b9060405191826000825461272a816124c1565b9081845260209460019160018116908160001461279a575060011461275b575b5050506127599250038361214e565b565b600090815285812095935091905b818310612782575050612759935082010138808061274a565b85548884018501529485019487945091830191612769565b9250505061275994925060ff191682840152151560051b82010138808061274a565b906040516127c9816120ab565b60a081935461ffff908181168452818160101c166020850152818160201c166040850152818160301c166060850152818160401c16608085015260501c16910152565b90604051612819816120c6565b809280546001600160401b0380821684528160401c16602084015263ffffffff808260801c166040850152808260a01c1660608501528160c01c16608084015260e01c60a083015260ff6001820154169060058210156103c957600a6126d4916102009360c0860152600281015460e08601526003810154610100860152600481015461012086015260058101546101408601526128b960068201612717565b6101608601526128cb60078201612717565b6101808601526128dd60088201612717565b6101a086015260ff600982015481811615156101c088015260081c1615156101e0860152016127bc565b1561290e57565b60405162461bcd60e51b8152602060048201526013602482015272494e4445585f4f55545f4f465f424f554e445360681b6044820152606490fd5b8115612953570490565b634e487b7160e01b600052601260045260246000fd5b612971612620565b50600081815260096020526040902054612995906001600160a01b031615156125ae565b600090808252600760205260408220546129b08115156126d9565b829083849285869187948897895b8a838210612a8c57505050508615612a55578697509286959286809693819661ffff96878096816129f181978296612949565b169e6129fc91612949565b169b612a0791612949565b1696612a1291612949565b1695612a1d91612949565b1694612a2891612949565b169360405195612a37876120ab565b8652602086015260408501526060840152608083015260a082015290565b5050505050505060405190612a69826120ab565b80825280602083015280604083015280606083015280608083015260a082015290565b600a6110a88360408487612aa69652600760205220612477565b61ffff808251168015801590612bb1575b8015612ba2575b8015612b93575b8015612b84575b8015612b75575b612ae3575b5050506001016129be565b612af6919298979b99969c9a939c612417565b9481602089015116612b0791612417565b9781604089015116612b1891612417565b9981606089015116612b2991612417565b9581608089015116612b3a91612417565b9660a0015116612b4991612417565b966000198114612b6157600180910199903880612ad8565b634e487b7160e01b8b52601160045260248bfd5b508160a0840151161515612ad3565b50816080840151161515612acc565b50816060840151161515612ac5565b50816040840151161515612abe565b50816020840151161515612ab7565b15612bc757565b60405162461bcd60e51b815260206004820152600a60248201526927a7262cafa7aba722a960b11b6044820152606490fd5b90600163ffffffff8093160191821161088e57565b90612c5b6035604051809360208201956001600160601b03199060601b168652601d60f91b6034830152612c4b815180926020868601910161216f565b810103601581018452018261214e565b51902090565b6001600160401b03908116600019019190821161088e57565b906001600160401b039081811615612cfd57612c9590612c61565b16816000526007602052604060002054811015612cc657612cc29160005260076020526040600020612477565b5090565b60405162461bcd60e51b815260206004820152600f60248201526e105551125517d393d517d193d55391608a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f1253959053125117d05551125517d25160821b6044820152606490fd5b9f9a97949d989593919f9e99969b9c9e60a052608052612d6f6102f260a051600052600960205260018060a01b0360406000205416151590565b60058d10156103c9578c156132e95760a0516000526007602052604060002054612d9a8115156126d9565b60a0516000526007602052604060002090600019810190811161088e57612dc091612477565b509e8f6001015460ff1660058110156103c9576132b1578f612e9e8f93612e7e612ea496612e5e600196612e206001600160401b034216889067ffffffffffffffff60401b82549160401b169067ffffffffffffffff60401b1916179055565b60808051885463ffffffff60801b1916911b63ffffffff60801b16178755865463ffffffff60a01b191660a09190911b63ffffffff60a01b16178655565b845463ffffffff60c01b191660c09190911b63ffffffff60c01b16178455565b82546001600160e01b031660e09190911b6001600160e01b031916178255565b016124a9565b60028d01558760038d015560048c015560058b01556001600160401b03821161159b57612ed8826118c660068d01546124c1565b600090601f831160011461324057612f089291600091836131225750508160011b916000199060031b1c19161790565b60068901555b6001600160401b03871161159b57612f3687612f2d60078b01546124c1565b60078b016124fb565b600087601f81116001146131d35780612f65926000916131c8575b508160011b916000199060031b1c19161790565b60078901555b6001600160401b03821161159b57612f9382612f8a60088b01546124c1565b60088b016124fb565b600090601f831160011461312d5792612fef836130fa97947f80f307f5798ed339302133e4f353681cc7f5cc7333f5c829480b6812cf527f3399979461311d976000926131225750508160011b916000199060031b1c19161790565b60088a01555b600a89019061ffff8151169082549163ffff0000602083015160101b1665ffff00000000604084015160201b169067ffff000000000000606085015160301b169261ffff60401b608086015160401b169460a061ffff60501b91015160501b16956001600160601b031916171717171717905560a05160005260066020526001600160401b036004604060002001986130b38242168b9067ffffffffffffffff60481b82549160481b169067ffffffffffffffff60481b1916179055565b6130eb63ffffffff9a6130cb8c825460881c16612bf9565b815463ffffffff60881b191660889190911b63ffffffff60881b16179055565b541697604051958680966121fa565b60805116602085015260408401526080606084015260a051956080840191612551565b0390a3565b0135905038806114d7565b6008890160005260206000209160005b601f19851681106131b05750837f80f307f5798ed339302133e4f353681cc7f5cc7333f5c829480b6812cf527f3398969361311d96936001936130fa9a97601f19811610613196575b505050811b0160088a0155612ff5565b0135600019600384901b60f8161c19169055388080613186565b9092602060018192868601358155019401910161313d565b905087013538612f51565b506007890160005260206000209060005b601f198a168110613228575088601f1981161061320e575b5050600187811b016007890155612f6b565b86013560001960038a901b60f8161c1916905538806131fc565b9091602060018192858b0135815501930191016131e4565b60068b939293016000526020600020906000935b601f1984168510613299576001945083601f1981161061327f575b505050811b016006890155612f0e565b0135600019600384901b60f8161c1916905538808061326f565b81810135835560209485019460019093019201613254565b60405162461bcd60e51b815260206004820152601060248201526f1393d7d4115391125391d7d05551125560821b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d494e56414c49445f53544154555360901b6044820152606490fd5b906001600160401b03908181161561339f5761333a90612c61565b1681600052600b60205260406000205481101561336757612cc291600052600b60205260406000206125ec565b60405162461bcd60e51b815260206004820152601060248201526f10541411505317d393d517d193d5539160821b6044820152606490fd5b60405162461bcd60e51b81526020600482015260116024820152701253959053125117d0541411505317d251607a1b6044820152606490fdfea264697066735822122090e664966b494d015056388343e56cb1af27873c04b2f7679feb1d5468be924264736f6c63430008180033", + "compiler": { + "version": "0.8.24" + }, + "metadata": { + "compiler": { + "version": "0.8.24+commit.e11b9ed9" + }, + "language": "Solidity", + "output": { + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "initialServiceFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "initialMinimumBond", + "type": "uint256" + }, + { + "internalType": "address", + "name": "initialOperator", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "agentName", + "type": "string" + } + ], + "name": "AgentRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + } + ], + "name": "AppealFiled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + } + ], + "name": "AppealRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "enum AgentAuditRegistryV2.AppealOutcome", + "name": "outcome", + "type": "uint8" + } + ], + "name": "AppealResolved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "enum AgentAuditRegistryV2.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "string", + "name": "reportCID", + "type": "string" + } + ], + "name": "AuditRecorded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "agentName", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bondAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + } + ], + "name": "AuditRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "BondCompensated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "BondSlashed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOperator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOperator", + "type": "address" + } + ], + "name": "OperatorUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "serviceFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minimumBond", + "type": "uint256" + } + ], + "name": "PricingUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "int32", + "name": "newDelta", + "type": "int32" + } + ], + "name": "ReputationUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "accruedServiceFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "compensateBond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "evidenceHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "appealCID", + "type": "string" + } + ], + "name": "fileAppeal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAgentProfile", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "internalType": "string", + "name": "agentName", + "type": "string" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBond", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "blacklisted", + "type": "bool" + }, + { + "internalType": "uint64", + "name": "createdAt", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "lastAuditAt", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "auditCount", + "type": "uint32" + } + ], + "internalType": "struct AgentAuditRegistryV2.AgentProfile", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAppealCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + } + ], + "name": "getAppealRecord", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "filedAt", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "resolvedAt", + "type": "uint64" + }, + { + "internalType": "enum AgentAuditRegistryV2.AppealOutcome", + "name": "outcome", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "evidenceHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "appealCID", + "type": "string" + } + ], + "internalType": "struct AgentAuditRegistryV2.AppealRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAuditCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getAuditReportByIndex", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV2.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "internalType": "bool", + "name": "appealRequested", + "type": "bool" + }, + { + "internalType": "bool", + "name": "appealApproved", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV2.DimensionalScores", + "name": "dimensionalScores", + "type": "tuple" + } + ], + "internalType": "struct AgentAuditRegistryV2.AuditRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAverageScores", + "outputs": [ + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV2.DimensionalScores", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "auditIndex", + "type": "uint256" + } + ], + "name": "getDimensionalScores", + "outputs": [ + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV2.DimensionalScores", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getLatestAuditReport", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV2.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "internalType": "bool", + "name": "appealRequested", + "type": "bool" + }, + { + "internalType": "bool", + "name": "appealApproved", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV2.DimensionalScores", + "name": "dimensionalScores", + "type": "tuple" + } + ], + "internalType": "struct AgentAuditRegistryV2.AuditRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getReputation", + "outputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "successfulAppeals", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "failedAppeals", + "type": "uint32" + }, + { + "internalType": "int32", + "name": "reputationDelta", + "type": "int32" + } + ], + "internalType": "struct AgentAuditRegistryV2.ReputationRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "internalType": "string", + "name": "agentName", + "type": "string" + } + ], + "name": "getTokenId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + } + ], + "name": "markAppealRequested", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "minimumBond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "operator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "ownerOf", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV2.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + } + ], + "name": "recordAuditResult", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV2.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV2.DimensionalScores", + "name": "scores", + "type": "tuple" + } + ], + "name": "recordAuditResultV2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + }, + { + "internalType": "enum AgentAuditRegistryV2.AppealOutcome", + "name": "outcome", + "type": "uint8" + } + ], + "name": "resolveAppeal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "serviceFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOperator", + "type": "address" + } + ], + "name": "setOperator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newServiceFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "newMinimumBond", + "type": "uint256" + } + ], + "name": "setPricing", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "slashBond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "agentName", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + } + ], + "name": "stake", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + } + }, + "settings": { + "compilationTarget": { + "src/AgentAuditRegistryV2.sol": "AgentAuditRegistryV2" + }, + "evmVersion": "paris", + "libraries": {}, + "metadata": { + "bytecodeHash": "ipfs" + }, + "optimizer": { + "enabled": true, + "runs": 200 + }, + "remappings": [], + "viaIR": true + }, + "sources": { + "src/AgentAuditRegistryV2.sol": { + "keccak256": "0x0eb0b0b51b7735cd76e83644b2d1dbda071b2f7ce8a9ff826e8f57650acb1f5a", + "license": "MIT", + "urls": [ + "bzz-raw://9109c55d16472e9c8c99bc2b6e4c0035ff0912d63972b0828f631e743e446f34", + "dweb:/ipfs/Qmes9RJh2Rxh82WY9cPbRE3zHGnTQG8Xf3z22Ko2oDaqu1" + ] + } + }, + "version": 1 + } +} diff --git a/contracts/artifacts/AgentAuditRegistryV3.json b/contracts/artifacts/AgentAuditRegistryV3.json new file mode 100644 index 0000000..b3489df --- /dev/null +++ b/contracts/artifacts/AgentAuditRegistryV3.json @@ -0,0 +1,3136 @@ +{ + "contractName": "AgentAuditRegistryV3", + "sourceName": "src/AgentAuditRegistryV3.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "initialServiceFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "initialMinimumBond", + "type": "uint256" + }, + { + "internalType": "address", + "name": "initialOperator", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "agentName", + "type": "string" + } + ], + "name": "AgentRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + } + ], + "name": "AppealFiled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + } + ], + "name": "AppealRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "enum AgentAuditRegistryV3.AppealOutcome", + "name": "outcome", + "type": "uint8" + } + ], + "name": "AppealResolved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "enum AgentAuditRegistryV3.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "string", + "name": "reportCID", + "type": "string" + } + ], + "name": "AuditRecorded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "agentName", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bondAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + } + ], + "name": "AuditRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "BondCompensated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "BondSlashed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOperator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOperator", + "type": "address" + } + ], + "name": "OperatorUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "serviceFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minimumBond", + "type": "uint256" + } + ], + "name": "PricingUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "currentScore", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "int32", + "name": "delta", + "type": "int32" + } + ], + "name": "ReputationUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "APPEAL_FAILURE_PENALTY", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "APPEAL_SUCCESS_BONUS", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BASE_POINTS_PER_AUDIT", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DECAY_PERIOD", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DECAY_RATE_BPS", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_REPUTATION_SCORE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "accruedServiceFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "compensateBond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "evidenceHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "appealCID", + "type": "string" + } + ], + "name": "fileAppeal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAgentProfile", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "internalType": "string", + "name": "agentName", + "type": "string" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBond", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "blacklisted", + "type": "bool" + }, + { + "internalType": "uint64", + "name": "createdAt", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "lastAuditAt", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "auditCount", + "type": "uint32" + } + ], + "internalType": "struct AgentAuditRegistryV3.AgentProfile", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAppealCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + } + ], + "name": "getAppealRecord", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "filedAt", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "resolvedAt", + "type": "uint64" + }, + { + "internalType": "enum AgentAuditRegistryV3.AppealOutcome", + "name": "outcome", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "evidenceHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "appealCID", + "type": "string" + } + ], + "internalType": "struct AgentAuditRegistryV3.AppealRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAuditCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getAuditReportByIndex", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV3.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "internalType": "bool", + "name": "appealRequested", + "type": "bool" + }, + { + "internalType": "bool", + "name": "appealApproved", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV3.DimensionalScores", + "name": "dimensionalScores", + "type": "tuple" + } + ], + "internalType": "struct AgentAuditRegistryV3.AuditRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAverageScores", + "outputs": [ + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV3.DimensionalScores", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "auditIndex", + "type": "uint256" + } + ], + "name": "getDimensionalScores", + "outputs": [ + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV3.DimensionalScores", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getLatestAuditReport", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV3.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "internalType": "bool", + "name": "appealRequested", + "type": "bool" + }, + { + "internalType": "bool", + "name": "appealApproved", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV3.DimensionalScores", + "name": "dimensionalScores", + "type": "tuple" + } + ], + "internalType": "struct AgentAuditRegistryV3.AuditRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getReputation", + "outputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "successfulAppeals", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "failedAppeals", + "type": "uint32" + }, + { + "internalType": "int32", + "name": "reputationDelta", + "type": "int32" + }, + { + "internalType": "uint32", + "name": "currentReputationScore", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "lastReputationUpdateAt", + "type": "uint64" + } + ], + "internalType": "struct AgentAuditRegistryV3.ReputationRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "internalType": "string", + "name": "agentName", + "type": "string" + } + ], + "name": "getTokenId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + } + ], + "name": "markAppealRequested", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "minimumBond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "operator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "ownerOf", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV3.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + } + ], + "name": "recordAuditResult", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV3.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV3.DimensionalScores", + "name": "scores", + "type": "tuple" + } + ], + "name": "recordAuditResultV2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + }, + { + "internalType": "enum AgentAuditRegistryV3.AppealOutcome", + "name": "outcome", + "type": "uint8" + } + ], + "name": "resolveAppeal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "serviceFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOperator", + "type": "address" + } + ], + "name": "setOperator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newServiceFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "newMinimumBond", + "type": "uint256" + } + ], + "name": "setPricing", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "slashBond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "agentName", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + } + ], + "name": "stake", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608034620000ac57601f62003ae538819003918201601f19168301916001600160401b03831184841017620000b157808492606094604052833981010312620000ac57805160208201516040909201516001600160a01b0380821691828103620000ac576001600555600080546001600160a01b0319908116331790915592620000a65750335b16906001541617600155600255600355604051613a1d9081620000c88239f35b62000086565b600080fd5b634e487b7160e01b600052604160045260246000fdfe608080604052600436101561001357600080fd5b60003560e01c90816306fdde031461231b5750806316790254146122ff57806319b36b1d146118935780631a0649e3146115505780631d57330d146114cb5780631e9d4904146114ad5780631f5d5a371461132c5780632e5819a6146113045780632f22afdb146111b55780632f26adcd14611188578063347c19cd14611139578063451135481461111c5780635662bce814610f6d578063570ca73514610f445780636352211e14610f0557806370a0823114610e9157806389370d8b14610da85780638abdf5aa14610d8a5780638da5cb5b14610d6157806395d89b4114610d1c57806396e8f481146106985780639d4f040714610c97578063aa7517e114610c79578063b3ab15fb14610bc8578063ca05588a14610b6d578063ccb4ebe014610701578063d52fcd281461069d578063eb30f6fb14610698578063ef0c26071461067c578063f098a7ae14610519578063f5b61195146104ca578063f84c39c914610436578063f8ba2fdc146102e9578063fd2c42cc146102cb5763fda5d1ff146101a057600080fd5b346102c6576101a03660031901126102c6576004356101bd61264c565b906101c661265f565b6101ce612672565b926101d7612685565b9360a4359260058410156102c6576001600160401b0395610144358781116102c65761020790369060040161249f565b91610164358981116102c65761022190369060040161249f565b959094610184359a8b116102c65761026b6102436102b69c369060040161249f565b9a909961026560018060a01b03806001541633149081156102b8575b50612876565b8c613064565b604051996102788b612393565b60008b52600060208c0152600060408c0152600060608c0152600060808c0152600060a08c01526101243593610104359360e4359360c43593613485565b005b90506000541633143861025f565b600080fd5b346102c65760003660031901126102c6576020600454604051908152f35b346102c6576102f7366126bb565b90929161031860018060a01b03806001541633149081156104285750612876565b600083815260096020526040902054610340906001600160a01b031615156128b2565b6128b2565b61034a8184612fa9565b600181019160ff8354166005811015610412576003036103d9577fd7e851d789b6e3784feb9febce0117765574999009e64543881911a79eb596629360096001600160401b0393604095886000526006602052600387600020016103af8b825461271b565b9055805460ff1916600417905501805461ff001916610100179055835196875260208701521693a3005b60405162461bcd60e51b8152602060048201526011602482015270105551125517d393d517d4d31054d21151607a1b6044820152606490fd5b634e487b7160e01b600052602160045260246000fd5b90506000541633148661025f565b346102c65760403660031901126102c6576004356001600160401b0361045a6124cc565b60015461047b90336001600160a01b03918216149081156104bc5750612876565b60096104878285612fa9565b01805460ff1916600117905516907f5ef8bd082609dcf89dfc86ebb395fcd189183ad5e5c37d83b7123ff8da8b6e8d600080a3005b90506000541633148561025f565b346102c65760203660031901126102c657600435600081815260096020526040902054610501906001600160a01b031615156128b2565b600052600b6020526020604060002054604051908152f35b346102c6576020806003193601126102c657600435600060e060405161053e81612377565b8281526060858201528260408201528260608201528260808201528260a08201528260c0820152015261058961033b82600052600960205260018060a01b0360406000205416151590565b600052600681526040600020604051906105a282612377565b80546001600160a01b039081168352916040906105c160018401612a46565b8582019081526002840154938383019485526004600382015491606085019283520154916080840160ff8416151581526001600160401b0392839160a0870191838760081c16835261064f60c0890195858960481c16875263ffffffff998a60e082019a60881c168a528b519e8f9e8f928284525116910152518c6101009b8c9101526101208d019061247a565b995160608c01525160808b015251151560a08a0152511660c0880152511660e08601525116908301520390f35b346102c65760003660031901126102c657602060405160328152f35b6126ff565b346102c65760403660031901126102c6576106b66126e9565b602435906001600160401b0382116102c6576106e36106dc6106e993369060040161249f565b3691612735565b90612f3d565b60005260086020526020604060002054604051908152f35b346102c65760603660031901126102c65760043561071d6124cc565b6044356003808210156102c65760015461074b90336001600160a01b03918216149081156104285750612876565b60008481526009602052604090205461076e906001600160a01b031615156128b2565b8115610b365761077e838561381e565b916001830160ff8154168381101561041257610af1578161079e91612937565b82546001600160c01b03164260c081901b6001600160c01b0319169190911784556001600160401b03939084169186600052600c6020526040600020916107e4836138d7565b60018203610992578254600163ffffffff9182610802818316612f28565b169063ffffffff19161780865560401c870b01637fffffff198112637fffffff82131761097c5761084e90859081549060401b63ffffffff60401b169063ffffffff60401b1916179055565b606481855460601c16019181831161097c5761089a88926108a594612710809282161160001461097557505b865463ffffffff60601b191660609190911b63ffffffff60601b16178655565b5460401c1688612fa9565b600181019081549160ff8316976005891015610412576000805160206139c88339815191529961091061094e988d967f90239a2ae000675dd3b0dbe1678bc62ab9dd686eeffb26924130d8ebb21df352966020968d63ffffffff9f14610953575b5050505b8861290c565b61091d60405180976126ae565b1693a3546040519384938260401c900b9160601c168390929160209063ffffffff604084019516835260030b910152565b0390a2005b600460099360ff19161790550161010061ff00198254161790558e8080610906565b905061087a565b634e487b7160e01b600052601160045260246000fd5b5081949294549563ffffffff9667ffffffff000000006109b6898360201c16612f28565b60201b169067ffffffff000000001916178084556000199060401c860b01637fffffff8113637fffffff1982121761097c57610a0d90849081549060401b63ffffffff60401b169063ffffffff60401b1916179055565b87835460c8898260601c1611600014610aa0575050825460601c871660c7190196871161097c577f90239a2ae000675dd3b0dbe1678bc62ab9dd686eeffb26924130d8ebb21df352602061094e958a9361091063ffffffff9a610a9b6000805160206139c88339815191529d8a9081549063ffffffff60601b9060601b169063ffffffff60601b1916179055565b61090a565b6000805160206139c8833981519152985061094e957f90239a2ae000675dd3b0dbe1678bc62ab9dd686eeffb26924130d8ebb21df352929361091063ffffffff9a6020948c60601b1916895561090a565b60405162461bcd60e51b815260206004820152601760248201527f41505045414c5f414c52454144595f5245534f4c5645440000000000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f4f5554434f4d4560881b6044820152606490fd5b346102c6577f335f5afc83fe8c5a011a96dc39bcce9fb9d46fb5986502f7040e76e28b0361236040610b9e36612698565b610bb360018060a01b03600054163314612eef565b816002558060035582519182526020820152a1005b346102c65760203660031901126102c657610be16126e9565b6000546001600160a01b03918291610bfc9083163314612eef565b16908115610c4157600154826001600160601b0360a01b821617600155167ffbe5b6cbafb274f445d7fed869dc77a838d8243a22c460de156560e8857cad03600080a3005b60405162461bcd60e51b815260206004820152601060248201526f24a72b20a624a22fa7a822a920aa27a960811b6044820152606490fd5b346102c65760003660031901126102c6576020600354604051908152f35b346102c657610d18610d0c610d06610cae36612698565b90610cb7612981565b50600081815260096020526040902054610cdb906001600160a01b031615156128b2565b806000526007602052610cf46040600020548310612c36565b6000526007602052604060002061277b565b50612b3b565b60405191829182612535565b0390f35b346102c65760003660031901126102c657610d18604051610d3c81612400565b60048152634141493360e01b602082015260405191829160208352602083019061247a565b346102c65760003660031901126102c6576000546040516001600160a01b039091168152602090f35b346102c65760003660031901126102c6576020600254604051908152f35b346102c6576020806003193601126102c65760a09060043560006080604051610dd0816123e5565b82815282858201528260408201528260608201520152610e0861033b82600052600960205260018060a01b0360406000205416151590565b600052600c81526080604060002060405190610e23826123e5565b549063ffffffff9081831694858252808201908385821c1682528360408401928660401c60030b84526060850194828860601c1686526001600160401b03988991019760801c1687526040519889525116908701525160030b60408601525116606084015251166080820152f35b346102c65760203660031901126102c6576001600160a01b03610eb26126e9565b168015610ed157600052600a6020526020604060002054604051908152f35b60405162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b6044820152606490fd5b346102c65760203660031901126102c6576004356000526009602052602060018060a01b0360406000205416610f3c8115156128b2565b604051908152f35b346102c65760003660031901126102c6576001546040516001600160a01b039091168152602090f35b346102c657610f7b366126bb565b60015491939291610fa090336001600160a01b03918216149081156104285750612876565b600083815260096020526040902054610fc3906001600160a01b031615156128b2565b82600052600660205260406000209060038201928354918287116110e35760046040947f60a77a9907fdd72fa9c1aed2ee36350704289df2e7956a74c741287c6fcefb799661101c8a611016878c612fa9565b97612728565b905501926003600160ff19928184885416178755019182541617905585600052600c60205260ff846000209354166000146110bf57825463ffffffff60601b191683555b856000805160206139c88339815191526110ad6001600160401b03956110888742168261290c565b548751606082901c63ffffffff16815290881c60030b60208201529081906040820190565b0390a2835196875260208701521693a3005b8254600181901c637fffffff60601b1663ffffffff60601b19909116178355611060565b60405162461bcd60e51b8152602060048201526011602482015270125394d551919250d251539517d093d391607a1b6044820152606490fd5b346102c65760003660031901126102c65760206040516127108152f35b346102c65760203660031901126102c657600435600081815260096020526040902054611170906001600160a01b031615156128b2565b60005260076020526020604060002054604051908152f35b346102c65760203660031901126102c65760c06111a6600435612c98565b6111b360405180926124ef565bf35b346102c65760403660031901126102c6576112346004356111d46124cc565b90606060c06040516111e5816123ca565b60008152600060208201526000604082015260008382015260006080820152600060a0820152015261122f61033b82600052600960205260018060a01b0360406000205416151590565b61381e565b60405190611241826123ca565b8054906001600160401b0380831684526020840190808460401c1682526040850190808560801c168252606086019460c01c855260ff600185015416906080870190600383101561041257602096818995816112b46003610d189b6112ec99895260a060028201549b019a8b5201612a46565b9860c08d01998a52816040519d8e9d8e52511660208d0152511660408b015251166060890152511660808701525160a08601906126ae565b5160c08401525160e08084015261010083019061247a565b346102c65760c06111a6600a61132561131c36612698565b90610cb761294f565b5001612aeb565b346102c6576102603660031901126102c65761134661264c565b61134e61265f565b90611357612672565b91611360612685565b91600560a43510156102c6576001600160401b03610144358181116102c65761138d90369060040161249f565b610164929192358281116102c6576113a990369060040161249f565b939092610184359081116102c6576113c590369060040161249f565b96909560c0366101a31901126102c65760015461140791906113fb90336001600160a01b039182161490811561149f5750612876565b60a43590600435613064565b6040519761141489612393565b61ffff996101a4358b811681036102c6578a526101c4358b811681036102c65760208b01526101e4358b811681036102c65760408b0152610204358b811681036102c65760608b0152610224358b811681036102c65760808b0152610244359a8b168b036102c6576102b69a60a08b01526101243592610104359260e4359260c43592600435613485565b90506000541633148d61025f565b346102c65760003660031901126102c657602060405162278d008152f35b346102c65760203660031901126102c6576004356114e7612981565b5060008181526009602052604090205461150b906001600160a01b031615156128b2565b80600052600760205260406000205490611526821515612a08565b6000526007602052604060002090600019810190811161097c57610d06610d0c91610d189361277b565b346102c65760803660031901126102c6576115696124cc565b6064356001600160401b0381116102c65761158890369060040161249f565b90916115a860018060a01b03806001541633149081156104bc5750612876565b6004356000908152600960205260409020546115ce906001600160a01b031615156128b2565b60096115dc82600435612fa9565b01600160ff19825416179055600435600052602092600b84526040600020546001810180911161097c576001600160401b031692600435600052600b85526040600020916040519061162d826123ca565b858252868201916001600160401b0386168352604081016001600160401b0342168152606082016000815261167560808401946000865260a085019760443589523691612735565b9660c084019788528054600160401b8110156118675761169a916001820181556128f0565b95909561187d579251855493516fffffffffffffffffffffffffffffffff199094166001600160401b039182161760409490941b67ffffffffffffffff60401b1693909317855561171492916116f490839051168661290c565b5184546001600160c01b0316911660c01b6001600160c01b031916178355565b519160038310156104125761172e60039360018401612937565b5160028201550190518051906001600160401b0382116118675761175c8261175685546127c5565b856127ff565b8590601f83116001146117d557827fe95840e66082a0861ce8bd81aeca7b1ec09caf20c05b9aae8892d7f784fc9beb95936001600160401b0395936117b8936000926117ca575b50508160011b916000199060031b1c19161790565b90555b604051938452169260043592a3005b0151905089806117a3565b90601f1983169184600052876000209260005b898282106118515750509260019285927fe95840e66082a0861ce8bd81aeca7b1ec09caf20c05b9aae8892d7f784fc9beb98966001600160401b03989610611838575b505050811b0190556117bb565b015160001960f88460031b161c1916905588808061182b565b60018596829396860151815501950193016117e8565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052600060045260246000fd5b60403660031901126102c6576004356001600160401b0381116102c6576118be90369060040161249f565b6024356001600160401b0381116102c6576118dd90369060040161249f565b90919081156122c757801561228d57600254916118fc6003548461271b565b34106122535761191861190f8434612728565b9360045461271b565b60045561192f611929368388612735565b33612f3d565b6000526008602052604060002054938415611f63575b846000526006602052600360406000200161196185825461271b565b90558460005260076020526040600020549260018401841161097c57856000526007602052604060002060405161199781612393565b6000815260006020820152600060408201526000606082015260006080820152600060a08201526001600160401b036001604051976119d5896123ae565b011686526001600160401b0342166020870152600060408701526000606087015260006080870152600060a0870152600060c0870152600060e0870152600061010087015260006101208701526000610140870152604051611a368161241b565b60008152610160870152604051611a4c8161241b565b60008152610180870152611a61368486612735565b6101a087015260006101c087015260006101e08701526102008601528054600160401b81101561186757611a9a9160018201815561277b565b97909761187d578451602086015160408088015160608901516080808b015160a0808d015160e01b6001600160e01b0319166001600160401b039098169690951b67ffffffffffffffff60401b169590951763ffffffff60801b9390911b929092169190911763ffffffff60a01b9190921b161763ffffffff60c01b60c09290921b919091161717885560c0850151600581101561041257611b3f9060018a016127ad565b60e085015160028901556101008501516003890155610120850151600489015561014085015160058901556101608501518051906001600160401b03821161186757611b9b82611b9260068d01546127c5565b60068d016127ff565b602090601f8311600114611ef557611bcb929160009183611e7c5750508160011b916000199060031b1c19161790565b60068901555b6101808501518051906001600160401b03821161186757611c0282611bf960078d01546127c5565b60078d016127ff565b602090601f8311600114611e8757611c32929160009183611e7c5750508160011b916000199060031b1c19161790565b60078901555b6101a0850151948551986001600160401b038a1161186757898997611c6f60209c611c6660088601546127c5565b600886016127ff565b8b90601f8311600114611dd157600a611d9694611cd1857fbd6d3df44aaa1231a5f51af5e02c3a67047dc0ebe0a72cb455ffd7eb80172a219c9b9996611da39b999661020096600092611dc65750508160011b916000199060031b1c19161790565b60088201555b60098101611cf86101c08601511515829060ff801983541691151516179055565b6101e0850151151561ff0082549160081b169061ff0019161790550191015161ffff8151169082549163ffff00008f83015160101b1665ffff00000000604084015160201b169067ffff000000000000606085015160301b169261ffff60401b608086015160401b169460a061ffff60501b91015160501b16956001600160601b031916171717171717905560405195608087526080870191612855565b918483038a860152612855565b9360408201526001600160401b03421660608201528033940390a3604051908152f35b0151905038806117a3565b60088493929a999897969594016000528c6000209060005b601f1984168110611e625750611da397969593600184610200947fbd6d3df44aaa1231a5f51af5e02c3a67047dc0ebe0a72cb455ffd7eb80172a219d9e600a95611d969a98601f19811610611e49575b505050811b016008820155611cd7565b015160001960f88460031b161c19169055388080611e39565b818c015183559a8e019a8d9a506001909201918e01611de9565b015190508b806117a3565b90601f1983169160078c0160005260206000209260005b818110611edd5750908460019594939210611ec4575b505050811b016007890155611c38565b015160001960f88460031b161c191690558a8080611eb4565b92936020600181928786015181550195019301611e9e565b90601f1983169160068c0160005260206000209260005b818110611f4b5750908460019594939210611f32575b505050811b016006890155611bd1565b015160001960f88460031b161c191690558a8080611f22565b92936020600181928786015181550195019301611f0c565b93506005546001810180821161097c576005558060005260096020526040600020336001600160601b0360a01b82541617905533600052600a6020526040600020805460018101811161097c576001019055611fc3611929368489612735565b600052600860205280604060002055604051611fde81612377565b338152611fec368489612735565b6020820190815282604083015260006060830152600060808301526001600160401b03421660a0830152600060c0830152600060e083015282600052600660205260406000209060018060a01b038351166001600160601b0360a01b835416178255518051906001600160401b0382116118675761207a8261207160018601546127c5565b600186016127ff565b602090601f83116001146121d55761215f94936120b98463ffffffff9560e0956004956000926121ca5750508160011b916000199060031b1c19161790565b60018201555b604085015160028201556060850151600382015501926120f160808201511515859060ff801983541691151516179055565b60a0810151845460c083015170ffffffffffffffffffffffffffffffff001990911660089290921b68ffffffffffffffff00169190911760489190911b67ffffffffffffffff60481b161784550151825463ffffffff60881b1916911660881b63ffffffff60881b16179055565b604051813360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a460208152817f0d063c6022bff16d09991a9f91882ffa112f5fb2529136f65eb4c77bbd047e433392806121c160208201888d612855565b0390a393611945565b015190508f806117a3565b906001840160005260206000209160005b601f198516811061223b57509360018460e09460049461215f999863ffffffff98601f19811610612222575b505050811b0160018201556120bf565b015160001960f88460031b161c191690558e8080612212565b919260206001819286850151815501940192016121e6565b60405162461bcd60e51b8152602060048201526012602482015271494e53554646494349454e545f56414c554560701b6044820152606490fd5b60405162461bcd60e51b8152602060048201526012602482015271115354151657d3505392519154d517d5549360721b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f454d5054595f4147454e545f4e414d4560801b6044820152606490fd5b346102c65760003660031901126102c657602060405160c88152f35b346102c65760003660031901126102c65780612339610d1892612400565b601781527f4167656e74204175646974204964656e74697479205633000000000000000000602082015260405191829160208352602083019061247a565b61010081019081106001600160401b0382111761186757604052565b60c081019081106001600160401b0382111761186757604052565b61022081019081106001600160401b0382111761186757604052565b60e081019081106001600160401b0382111761186757604052565b60a081019081106001600160401b0382111761186757604052565b604081019081106001600160401b0382111761186757604052565b602081019081106001600160401b0382111761186757604052565b90601f801991011681019081106001600160401b0382111761186757604052565b60005b83811061246a5750506000910152565b818101518382015260200161245a565b9060209161249381518092818552858086019101612457565b601f01601f1916010190565b9181601f840112156102c6578235916001600160401b0383116102c657602083818601950101116102c657565b602435906001600160401b03821682036102c657565b9060058210156104125752565b60a0908161ffff91828151168552826020820151166020860152826040820151166040860152826060820151166060860152826080820151166080860152015116910152565b61264990602081526001600160401b038084511660208301526020840151166040820152604083015163ffffffff80911660608301528060608501511660808301528060808501511660a083015260a08401511660c08201526125a060c084015160e08301906124e2565b61022060e08401516101009081840152840151610120908184015284015161014090818401528401516101609081840152840151936126236125f1610180966102c0888701526102e086019061247a565b9582015161260e601f19976101a09289888303018489015261247a565b908301516101c097868303018887015261247a565b948101516101e090151581850152810151906102009115158285015201519101906124ef565b90565b6024359063ffffffff821682036102c657565b6044359063ffffffff821682036102c657565b6064359063ffffffff821682036102c657565b6084359063ffffffff821682036102c657565b60409060031901126102c6576004359060243590565b9060038210156104125752565b60809060031901126102c657600435906024356001600160401b03811681036102c657906044359060643590565b600435906001600160a01b03821682036102c657565b346102c65760003660031901126102c657602060405160648152f35b9190820180921161097c57565b9190820391821161097c57565b9291926001600160401b038211611867576040519161275e601f8201601f191660200184612436565b8294818452818301116102c6578281602093846000960137010152565b805482101561279757600052600b602060002091020190600090565b634e487b7160e01b600052603260045260246000fd5b9060058110156104125760ff80198354169116179055565b90600182811c921680156127f5575b60208310146127df57565b634e487b7160e01b600052602260045260246000fd5b91607f16916127d4565b90601f811161280d57505050565b6000916000526020600020906020601f850160051c8301941061284b575b601f0160051c01915b82811061284057505050565b818155600101612834565b909250829061282b565b908060209392818452848401376000828201840152601f01601f1916010190565b1561287d57565b60405162461bcd60e51b815260206004820152600d60248201526c27a7262cafa7a822a920aa27a960991b6044820152606490fd5b156128b957565b60405162461bcd60e51b815260206004820152600f60248201526e1513d2d15397d393d517d193d55391608a1b6044820152606490fd5b80548210156127975760005260206000209060021b0190600090565b805467ffffffffffffffff60801b191660809290921b67ffffffffffffffff60801b16919091179055565b9060038110156104125760ff80198354169116179055565b6040519061295c82612393565b8160a06000918281528260208201528260408201528260608201528260808201520152565b6040519061298e826123ae565b8160008082528060208301528060408301528060608301528060808301528060a08301528060c08301528060e08301528061010083015280610120830152806101408301526060610160830152606061018083015260606101a0830152806101c08301526101e0820152610200612a0361294f565b910152565b15612a0f57565b60405162461bcd60e51b815260206004820152600f60248201526e1393d7d05551125517d49150d3d491608a1b6044820152606490fd5b90604051918260008254612a59816127c5565b90818452602094600191600181169081600014612ac95750600114612a8a575b505050612a8892500383612436565b565b600090815285812095935091905b818310612ab1575050612a889350820101388080612a79565b85548884018501529485019487945091830191612a98565b92505050612a8894925060ff191682840152151560051b820101388080612a79565b90604051612af881612393565b60a081935461ffff908181168452818160101c166020850152818160201c166040850152818160301c166060850152818160401c16608085015260501c16910152565b90604051612b48816123ae565b809280546001600160401b0380821684528160401c16602084015263ffffffff808260801c166040850152808260a01c1660608501528160c01c16608084015260e01c60a083015260ff60018201541690600582101561041257600a612a03916102009360c0860152600281015460e0860152600381015461010086015260048101546101208601526005810154610140860152612be860068201612a46565b610160860152612bfa60078201612a46565b610180860152612c0c60088201612a46565b6101a086015260ff600982015481811615156101c088015260081c1615156101e086015201612aeb565b15612c3d57565b60405162461bcd60e51b8152602060048201526013602482015272494e4445585f4f55545f4f465f424f554e445360681b6044820152606490fd5b8115612c82570490565b634e487b7160e01b600052601260045260246000fd5b612ca061294f565b50600081815260096020526040902054612cc4906001600160a01b031615156128b2565b60009080825260076020526040822054612cdf811515612a08565b829083849285869187948897895b8a838210612dbb57505050508615612d84578697509286959286809693819661ffff9687809681612d2081978296612c78565b169e612d2b91612c78565b169b612d3691612c78565b1696612d4191612c78565b1695612d4c91612c78565b1694612d5791612c78565b169360405195612d6687612393565b8652602086015260408501526060840152608083015260a082015290565b5050505050505060405190612d9882612393565b80825280602083015280604083015280606083015280608083015260a082015290565b600a6113258360408487612dd5965260076020522061277b565b61ffff808251168015801590612ee0575b8015612ed1575b8015612ec2575b8015612eb3575b8015612ea4575b612e12575b505050600101612ced565b612e25919298979b99969c9a939c61271b565b9481602089015116612e369161271b565b9781604089015116612e479161271b565b9981606089015116612e589161271b565b9581608089015116612e699161271b565b9660a0015116612e789161271b565b966000198114612e9057600180910199903880612e07565b634e487b7160e01b8b52601160045260248bfd5b508160a0840151161515612e02565b50816080840151161515612dfb565b50816060840151161515612df4565b50816040840151161515612ded565b50816020840151161515612de6565b15612ef657565b60405162461bcd60e51b815260206004820152600a60248201526927a7262cafa7aba722a960b11b6044820152606490fd5b90600163ffffffff8093160191821161097c57565b90612f8a6035604051809360208201956001600160601b03199060601b168652601d60f91b6034830152612f7a8151809260208686019101612457565b8101036015810184520182612436565b51902090565b6001600160401b03908116600019019190821161097c57565b906001600160401b03908181161561302c57612fc490612f90565b16816000526007602052604060002054811015612ff557612ff1916000526007602052604060002061277b565b5090565b60405162461bcd60e51b815260206004820152600f60248201526e105551125517d393d517d193d55391608a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f1253959053125117d05551125517d25160821b6044820152606490fd5b60008181526009602052604090205492939290919061308d906001600160a01b031615156128b2565b600584101561041257831561344f57600093828552602060078152604091828720546130ba811515612a08565b85885260078352838820600019820191821161343b57906130da9161277b565b5091600191600184019260ff8454166005811015613427576133f057908991886001600160401b039861315a848b4216986131388a8c9067ffffffffffffffff60401b82549160401b169067ffffffffffffffff60401b1916179055565b8a5463ffffffff60801b1916608085901b63ffffffff60801b16178b556127ad565b81855260068652888520600401805470ffffffffffffffff0000000000000000001916604889901b67ffffffffffffffff60481b16178155996131cb63ffffffff9b6131ab8d825460881c16612f28565b815463ffffffff60881b191660889190911b63ffffffff60881b16179055565b88541692600760038a01549901908b8b51936131e785896124e2565b16998a898501528b84015260806060840152868254613205816127c5565b9384608087015260a0916001811690816000146133a25750600114613342575b5050505050807f80f307f5798ed339302133e4f353681cc7f5cc7333f5c829480b6812cf527f33916001960390a314613263575b5050505050509050565b600c908689525282872091613277836138d7565b60320284811690810361332e5784606481855460601c169204160184811161332e5761331892916132ea6000805160206139c88339815191529798996132f0936127109150818982161160001461332757505b845463ffffffff60601b191660609190911b63ffffffff60601b16178455565b8261290c565b548251606082901c9490941663ffffffff16845290911c60030b602083015281906040820190565b0390a280388080808080613259565b90506132ca565b634e487b7160e01b88526011600452602488fd5b9091809493995052888084205b83851061338b5750505050810160a0019450807f80f307f5798ed339302133e4f353681cc7f5cc7333f5c829480b6812cf527f338e3880613225565b80548587018401528f96509301928990890161334f565b91505060019950859491507f80f307f5798ed339302133e4f353681cc7f5cc7333f5c829480b6812cf527f3395935060a0925060ff191682840152151560051b8201019650918e3880613225565b855162461bcd60e51b815260048101849052601060248201526f1393d7d4115391125391d7d05551125560821b6044820152606490fd5b634e487b7160e01b8b52602160045260248bfd5b634e487b7160e01b89526011600452602489fd5b60405162461bcd60e51b815260206004820152600e60248201526d494e56414c49445f53544154555360901b6044820152606490fd5b9692989360079d9a96929c989b9591600098895260209e8f52604089209a8b546000199c8d820191821161380a57906134bd9161277b565b50805463ffffffff60a01b191660a09390931b63ffffffff60a01b16929092178255909d8e9190825463ffffffff60c01b191660c09190911b63ffffffff60c01b1617825581546001600160e01b031660e09190911b6001600160e01b03191617905560028d015560038c015560048b015560058a015560068901906001600160401b03988982116137f6576135578261175685546127c5565b8590601f83116001146137945761358592918791836136985750508160011b916000199060031b1c19161790565b90555b6007880191878211613780576135a28261175685546127c5565b8390601f831160011461371f576135d092918591836136985750508160011b916000199060031b1c19161790565b90555b6008860194841161370b576135f2846135ec87546127c5565b876127ff565b8092601f85116001146136a35750600a959493613625939092836136985750508160011b916000199060031b1c19161790565b90555b019161ffff81511683549265ffff0000000063ffff00008285015160101b16916040850151901b169067ffff000000000000606085015160301b169261ffff60401b608086015160401b169460a061ffff60501b91015160501b16956001600160601b0319161717171717179055565b0135905038806117a3565b8582528782209391601f198616905b898282106136f557505091859391600a98979660019694106136dd575b50505050811b019055613628565b60f88560031b161c19910135169055388080806136cf565b60018597829396880135815501960193016136b2565b634e487b7160e01b81526041600452602490fd5b8385528a852091601f198416865b8d82821061376a575050908460019594939210613752575b505050811b0190556135d3565b8860f88560031b161c19910135169055388080613745565b600184968293958701358155019501920161372d565b634e487b7160e01b84526041600452602484fd5b8387528c872091601f198416888f5b8282106137df5750509084600195949392106137c7575b505050811b019055613588565b8a60f88560031b161c199101351690553880806137ba565b60018496829395870135815501950192018f6137a3565b634e487b7160e01b86526041600452602486fd5b634e487b7160e01b8c52601160045260248cfd5b906001600160401b03908181161561389e5761383990612f90565b1681600052600b60205260406000205481101561386657612ff191600052600b60205260406000206128f0565b60405162461bcd60e51b815260206004820152601060248201526f10541411505317d393d517d193d5539160821b6044820152606490fd5b60405162461bcd60e51b81526020600482015260116024820152701253959053125117d0541411505317d251607a1b6044820152606490fd5b8054906001600160401b0391828160801c16159081156139b5575b506139a95781421690805492808460801c16830381811161097c571680156139a35763ffffffff809460601c1690606482028281046064148315171561097c5760648284020291818304149015171561097c57640608f3d000900481811061396e575050805463ffffffff60601b19168155612a88925061290c565b8416900392831161097c57805463ffffffff60601b191660609390931b63ffffffff60601b16929092178255612a889161290c565b50505050565b612a889142169061290c565b63ffffffff915060601c1615386138f256fef2af20e52964303611e2a2930d6e08b03cf289fc9c25b00c435cd7bf4fd72773a2646970667358221220351d2a3addd457db2532f47731b627a11d10820517769eb296bfe543093bc12264736f6c63430008180033", + "deployedBytecode": "0x608080604052600436101561001357600080fd5b60003560e01c90816306fdde031461231b5750806316790254146122ff57806319b36b1d146118935780631a0649e3146115505780631d57330d146114cb5780631e9d4904146114ad5780631f5d5a371461132c5780632e5819a6146113045780632f22afdb146111b55780632f26adcd14611188578063347c19cd14611139578063451135481461111c5780635662bce814610f6d578063570ca73514610f445780636352211e14610f0557806370a0823114610e9157806389370d8b14610da85780638abdf5aa14610d8a5780638da5cb5b14610d6157806395d89b4114610d1c57806396e8f481146106985780639d4f040714610c97578063aa7517e114610c79578063b3ab15fb14610bc8578063ca05588a14610b6d578063ccb4ebe014610701578063d52fcd281461069d578063eb30f6fb14610698578063ef0c26071461067c578063f098a7ae14610519578063f5b61195146104ca578063f84c39c914610436578063f8ba2fdc146102e9578063fd2c42cc146102cb5763fda5d1ff146101a057600080fd5b346102c6576101a03660031901126102c6576004356101bd61264c565b906101c661265f565b6101ce612672565b926101d7612685565b9360a4359260058410156102c6576001600160401b0395610144358781116102c65761020790369060040161249f565b91610164358981116102c65761022190369060040161249f565b959094610184359a8b116102c65761026b6102436102b69c369060040161249f565b9a909961026560018060a01b03806001541633149081156102b8575b50612876565b8c613064565b604051996102788b612393565b60008b52600060208c0152600060408c0152600060608c0152600060808c0152600060a08c01526101243593610104359360e4359360c43593613485565b005b90506000541633143861025f565b600080fd5b346102c65760003660031901126102c6576020600454604051908152f35b346102c6576102f7366126bb565b90929161031860018060a01b03806001541633149081156104285750612876565b600083815260096020526040902054610340906001600160a01b031615156128b2565b6128b2565b61034a8184612fa9565b600181019160ff8354166005811015610412576003036103d9577fd7e851d789b6e3784feb9febce0117765574999009e64543881911a79eb596629360096001600160401b0393604095886000526006602052600387600020016103af8b825461271b565b9055805460ff1916600417905501805461ff001916610100179055835196875260208701521693a3005b60405162461bcd60e51b8152602060048201526011602482015270105551125517d393d517d4d31054d21151607a1b6044820152606490fd5b634e487b7160e01b600052602160045260246000fd5b90506000541633148661025f565b346102c65760403660031901126102c6576004356001600160401b0361045a6124cc565b60015461047b90336001600160a01b03918216149081156104bc5750612876565b60096104878285612fa9565b01805460ff1916600117905516907f5ef8bd082609dcf89dfc86ebb395fcd189183ad5e5c37d83b7123ff8da8b6e8d600080a3005b90506000541633148561025f565b346102c65760203660031901126102c657600435600081815260096020526040902054610501906001600160a01b031615156128b2565b600052600b6020526020604060002054604051908152f35b346102c6576020806003193601126102c657600435600060e060405161053e81612377565b8281526060858201528260408201528260608201528260808201528260a08201528260c0820152015261058961033b82600052600960205260018060a01b0360406000205416151590565b600052600681526040600020604051906105a282612377565b80546001600160a01b039081168352916040906105c160018401612a46565b8582019081526002840154938383019485526004600382015491606085019283520154916080840160ff8416151581526001600160401b0392839160a0870191838760081c16835261064f60c0890195858960481c16875263ffffffff998a60e082019a60881c168a528b519e8f9e8f928284525116910152518c6101009b8c9101526101208d019061247a565b995160608c01525160808b015251151560a08a0152511660c0880152511660e08601525116908301520390f35b346102c65760003660031901126102c657602060405160328152f35b6126ff565b346102c65760403660031901126102c6576106b66126e9565b602435906001600160401b0382116102c6576106e36106dc6106e993369060040161249f565b3691612735565b90612f3d565b60005260086020526020604060002054604051908152f35b346102c65760603660031901126102c65760043561071d6124cc565b6044356003808210156102c65760015461074b90336001600160a01b03918216149081156104285750612876565b60008481526009602052604090205461076e906001600160a01b031615156128b2565b8115610b365761077e838561381e565b916001830160ff8154168381101561041257610af1578161079e91612937565b82546001600160c01b03164260c081901b6001600160c01b0319169190911784556001600160401b03939084169186600052600c6020526040600020916107e4836138d7565b60018203610992578254600163ffffffff9182610802818316612f28565b169063ffffffff19161780865560401c870b01637fffffff198112637fffffff82131761097c5761084e90859081549060401b63ffffffff60401b169063ffffffff60401b1916179055565b606481855460601c16019181831161097c5761089a88926108a594612710809282161160001461097557505b865463ffffffff60601b191660609190911b63ffffffff60601b16178655565b5460401c1688612fa9565b600181019081549160ff8316976005891015610412576000805160206139c88339815191529961091061094e988d967f90239a2ae000675dd3b0dbe1678bc62ab9dd686eeffb26924130d8ebb21df352966020968d63ffffffff9f14610953575b5050505b8861290c565b61091d60405180976126ae565b1693a3546040519384938260401c900b9160601c168390929160209063ffffffff604084019516835260030b910152565b0390a2005b600460099360ff19161790550161010061ff00198254161790558e8080610906565b905061087a565b634e487b7160e01b600052601160045260246000fd5b5081949294549563ffffffff9667ffffffff000000006109b6898360201c16612f28565b60201b169067ffffffff000000001916178084556000199060401c860b01637fffffff8113637fffffff1982121761097c57610a0d90849081549060401b63ffffffff60401b169063ffffffff60401b1916179055565b87835460c8898260601c1611600014610aa0575050825460601c871660c7190196871161097c577f90239a2ae000675dd3b0dbe1678bc62ab9dd686eeffb26924130d8ebb21df352602061094e958a9361091063ffffffff9a610a9b6000805160206139c88339815191529d8a9081549063ffffffff60601b9060601b169063ffffffff60601b1916179055565b61090a565b6000805160206139c8833981519152985061094e957f90239a2ae000675dd3b0dbe1678bc62ab9dd686eeffb26924130d8ebb21df352929361091063ffffffff9a6020948c60601b1916895561090a565b60405162461bcd60e51b815260206004820152601760248201527f41505045414c5f414c52454144595f5245534f4c5645440000000000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f4f5554434f4d4560881b6044820152606490fd5b346102c6577f335f5afc83fe8c5a011a96dc39bcce9fb9d46fb5986502f7040e76e28b0361236040610b9e36612698565b610bb360018060a01b03600054163314612eef565b816002558060035582519182526020820152a1005b346102c65760203660031901126102c657610be16126e9565b6000546001600160a01b03918291610bfc9083163314612eef565b16908115610c4157600154826001600160601b0360a01b821617600155167ffbe5b6cbafb274f445d7fed869dc77a838d8243a22c460de156560e8857cad03600080a3005b60405162461bcd60e51b815260206004820152601060248201526f24a72b20a624a22fa7a822a920aa27a960811b6044820152606490fd5b346102c65760003660031901126102c6576020600354604051908152f35b346102c657610d18610d0c610d06610cae36612698565b90610cb7612981565b50600081815260096020526040902054610cdb906001600160a01b031615156128b2565b806000526007602052610cf46040600020548310612c36565b6000526007602052604060002061277b565b50612b3b565b60405191829182612535565b0390f35b346102c65760003660031901126102c657610d18604051610d3c81612400565b60048152634141493360e01b602082015260405191829160208352602083019061247a565b346102c65760003660031901126102c6576000546040516001600160a01b039091168152602090f35b346102c65760003660031901126102c6576020600254604051908152f35b346102c6576020806003193601126102c65760a09060043560006080604051610dd0816123e5565b82815282858201528260408201528260608201520152610e0861033b82600052600960205260018060a01b0360406000205416151590565b600052600c81526080604060002060405190610e23826123e5565b549063ffffffff9081831694858252808201908385821c1682528360408401928660401c60030b84526060850194828860601c1686526001600160401b03988991019760801c1687526040519889525116908701525160030b60408601525116606084015251166080820152f35b346102c65760203660031901126102c6576001600160a01b03610eb26126e9565b168015610ed157600052600a6020526020604060002054604051908152f35b60405162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b6044820152606490fd5b346102c65760203660031901126102c6576004356000526009602052602060018060a01b0360406000205416610f3c8115156128b2565b604051908152f35b346102c65760003660031901126102c6576001546040516001600160a01b039091168152602090f35b346102c657610f7b366126bb565b60015491939291610fa090336001600160a01b03918216149081156104285750612876565b600083815260096020526040902054610fc3906001600160a01b031615156128b2565b82600052600660205260406000209060038201928354918287116110e35760046040947f60a77a9907fdd72fa9c1aed2ee36350704289df2e7956a74c741287c6fcefb799661101c8a611016878c612fa9565b97612728565b905501926003600160ff19928184885416178755019182541617905585600052600c60205260ff846000209354166000146110bf57825463ffffffff60601b191683555b856000805160206139c88339815191526110ad6001600160401b03956110888742168261290c565b548751606082901c63ffffffff16815290881c60030b60208201529081906040820190565b0390a2835196875260208701521693a3005b8254600181901c637fffffff60601b1663ffffffff60601b19909116178355611060565b60405162461bcd60e51b8152602060048201526011602482015270125394d551919250d251539517d093d391607a1b6044820152606490fd5b346102c65760003660031901126102c65760206040516127108152f35b346102c65760203660031901126102c657600435600081815260096020526040902054611170906001600160a01b031615156128b2565b60005260076020526020604060002054604051908152f35b346102c65760203660031901126102c65760c06111a6600435612c98565b6111b360405180926124ef565bf35b346102c65760403660031901126102c6576112346004356111d46124cc565b90606060c06040516111e5816123ca565b60008152600060208201526000604082015260008382015260006080820152600060a0820152015261122f61033b82600052600960205260018060a01b0360406000205416151590565b61381e565b60405190611241826123ca565b8054906001600160401b0380831684526020840190808460401c1682526040850190808560801c168252606086019460c01c855260ff600185015416906080870190600383101561041257602096818995816112b46003610d189b6112ec99895260a060028201549b019a8b5201612a46565b9860c08d01998a52816040519d8e9d8e52511660208d0152511660408b015251166060890152511660808701525160a08601906126ae565b5160c08401525160e08084015261010083019061247a565b346102c65760c06111a6600a61132561131c36612698565b90610cb761294f565b5001612aeb565b346102c6576102603660031901126102c65761134661264c565b61134e61265f565b90611357612672565b91611360612685565b91600560a43510156102c6576001600160401b03610144358181116102c65761138d90369060040161249f565b610164929192358281116102c6576113a990369060040161249f565b939092610184359081116102c6576113c590369060040161249f565b96909560c0366101a31901126102c65760015461140791906113fb90336001600160a01b039182161490811561149f5750612876565b60a43590600435613064565b6040519761141489612393565b61ffff996101a4358b811681036102c6578a526101c4358b811681036102c65760208b01526101e4358b811681036102c65760408b0152610204358b811681036102c65760608b0152610224358b811681036102c65760808b0152610244359a8b168b036102c6576102b69a60a08b01526101243592610104359260e4359260c43592600435613485565b90506000541633148d61025f565b346102c65760003660031901126102c657602060405162278d008152f35b346102c65760203660031901126102c6576004356114e7612981565b5060008181526009602052604090205461150b906001600160a01b031615156128b2565b80600052600760205260406000205490611526821515612a08565b6000526007602052604060002090600019810190811161097c57610d06610d0c91610d189361277b565b346102c65760803660031901126102c6576115696124cc565b6064356001600160401b0381116102c65761158890369060040161249f565b90916115a860018060a01b03806001541633149081156104bc5750612876565b6004356000908152600960205260409020546115ce906001600160a01b031615156128b2565b60096115dc82600435612fa9565b01600160ff19825416179055600435600052602092600b84526040600020546001810180911161097c576001600160401b031692600435600052600b85526040600020916040519061162d826123ca565b858252868201916001600160401b0386168352604081016001600160401b0342168152606082016000815261167560808401946000865260a085019760443589523691612735565b9660c084019788528054600160401b8110156118675761169a916001820181556128f0565b95909561187d579251855493516fffffffffffffffffffffffffffffffff199094166001600160401b039182161760409490941b67ffffffffffffffff60401b1693909317855561171492916116f490839051168661290c565b5184546001600160c01b0316911660c01b6001600160c01b031916178355565b519160038310156104125761172e60039360018401612937565b5160028201550190518051906001600160401b0382116118675761175c8261175685546127c5565b856127ff565b8590601f83116001146117d557827fe95840e66082a0861ce8bd81aeca7b1ec09caf20c05b9aae8892d7f784fc9beb95936001600160401b0395936117b8936000926117ca575b50508160011b916000199060031b1c19161790565b90555b604051938452169260043592a3005b0151905089806117a3565b90601f1983169184600052876000209260005b898282106118515750509260019285927fe95840e66082a0861ce8bd81aeca7b1ec09caf20c05b9aae8892d7f784fc9beb98966001600160401b03989610611838575b505050811b0190556117bb565b015160001960f88460031b161c1916905588808061182b565b60018596829396860151815501950193016117e8565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052600060045260246000fd5b60403660031901126102c6576004356001600160401b0381116102c6576118be90369060040161249f565b6024356001600160401b0381116102c6576118dd90369060040161249f565b90919081156122c757801561228d57600254916118fc6003548461271b565b34106122535761191861190f8434612728565b9360045461271b565b60045561192f611929368388612735565b33612f3d565b6000526008602052604060002054938415611f63575b846000526006602052600360406000200161196185825461271b565b90558460005260076020526040600020549260018401841161097c57856000526007602052604060002060405161199781612393565b6000815260006020820152600060408201526000606082015260006080820152600060a08201526001600160401b036001604051976119d5896123ae565b011686526001600160401b0342166020870152600060408701526000606087015260006080870152600060a0870152600060c0870152600060e0870152600061010087015260006101208701526000610140870152604051611a368161241b565b60008152610160870152604051611a4c8161241b565b60008152610180870152611a61368486612735565b6101a087015260006101c087015260006101e08701526102008601528054600160401b81101561186757611a9a9160018201815561277b565b97909761187d578451602086015160408088015160608901516080808b015160a0808d015160e01b6001600160e01b0319166001600160401b039098169690951b67ffffffffffffffff60401b169590951763ffffffff60801b9390911b929092169190911763ffffffff60a01b9190921b161763ffffffff60c01b60c09290921b919091161717885560c0850151600581101561041257611b3f9060018a016127ad565b60e085015160028901556101008501516003890155610120850151600489015561014085015160058901556101608501518051906001600160401b03821161186757611b9b82611b9260068d01546127c5565b60068d016127ff565b602090601f8311600114611ef557611bcb929160009183611e7c5750508160011b916000199060031b1c19161790565b60068901555b6101808501518051906001600160401b03821161186757611c0282611bf960078d01546127c5565b60078d016127ff565b602090601f8311600114611e8757611c32929160009183611e7c5750508160011b916000199060031b1c19161790565b60078901555b6101a0850151948551986001600160401b038a1161186757898997611c6f60209c611c6660088601546127c5565b600886016127ff565b8b90601f8311600114611dd157600a611d9694611cd1857fbd6d3df44aaa1231a5f51af5e02c3a67047dc0ebe0a72cb455ffd7eb80172a219c9b9996611da39b999661020096600092611dc65750508160011b916000199060031b1c19161790565b60088201555b60098101611cf86101c08601511515829060ff801983541691151516179055565b6101e0850151151561ff0082549160081b169061ff0019161790550191015161ffff8151169082549163ffff00008f83015160101b1665ffff00000000604084015160201b169067ffff000000000000606085015160301b169261ffff60401b608086015160401b169460a061ffff60501b91015160501b16956001600160601b031916171717171717905560405195608087526080870191612855565b918483038a860152612855565b9360408201526001600160401b03421660608201528033940390a3604051908152f35b0151905038806117a3565b60088493929a999897969594016000528c6000209060005b601f1984168110611e625750611da397969593600184610200947fbd6d3df44aaa1231a5f51af5e02c3a67047dc0ebe0a72cb455ffd7eb80172a219d9e600a95611d969a98601f19811610611e49575b505050811b016008820155611cd7565b015160001960f88460031b161c19169055388080611e39565b818c015183559a8e019a8d9a506001909201918e01611de9565b015190508b806117a3565b90601f1983169160078c0160005260206000209260005b818110611edd5750908460019594939210611ec4575b505050811b016007890155611c38565b015160001960f88460031b161c191690558a8080611eb4565b92936020600181928786015181550195019301611e9e565b90601f1983169160068c0160005260206000209260005b818110611f4b5750908460019594939210611f32575b505050811b016006890155611bd1565b015160001960f88460031b161c191690558a8080611f22565b92936020600181928786015181550195019301611f0c565b93506005546001810180821161097c576005558060005260096020526040600020336001600160601b0360a01b82541617905533600052600a6020526040600020805460018101811161097c576001019055611fc3611929368489612735565b600052600860205280604060002055604051611fde81612377565b338152611fec368489612735565b6020820190815282604083015260006060830152600060808301526001600160401b03421660a0830152600060c0830152600060e083015282600052600660205260406000209060018060a01b038351166001600160601b0360a01b835416178255518051906001600160401b0382116118675761207a8261207160018601546127c5565b600186016127ff565b602090601f83116001146121d55761215f94936120b98463ffffffff9560e0956004956000926121ca5750508160011b916000199060031b1c19161790565b60018201555b604085015160028201556060850151600382015501926120f160808201511515859060ff801983541691151516179055565b60a0810151845460c083015170ffffffffffffffffffffffffffffffff001990911660089290921b68ffffffffffffffff00169190911760489190911b67ffffffffffffffff60481b161784550151825463ffffffff60881b1916911660881b63ffffffff60881b16179055565b604051813360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a460208152817f0d063c6022bff16d09991a9f91882ffa112f5fb2529136f65eb4c77bbd047e433392806121c160208201888d612855565b0390a393611945565b015190508f806117a3565b906001840160005260206000209160005b601f198516811061223b57509360018460e09460049461215f999863ffffffff98601f19811610612222575b505050811b0160018201556120bf565b015160001960f88460031b161c191690558e8080612212565b919260206001819286850151815501940192016121e6565b60405162461bcd60e51b8152602060048201526012602482015271494e53554646494349454e545f56414c554560701b6044820152606490fd5b60405162461bcd60e51b8152602060048201526012602482015271115354151657d3505392519154d517d5549360721b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f454d5054595f4147454e545f4e414d4560801b6044820152606490fd5b346102c65760003660031901126102c657602060405160c88152f35b346102c65760003660031901126102c65780612339610d1892612400565b601781527f4167656e74204175646974204964656e74697479205633000000000000000000602082015260405191829160208352602083019061247a565b61010081019081106001600160401b0382111761186757604052565b60c081019081106001600160401b0382111761186757604052565b61022081019081106001600160401b0382111761186757604052565b60e081019081106001600160401b0382111761186757604052565b60a081019081106001600160401b0382111761186757604052565b604081019081106001600160401b0382111761186757604052565b602081019081106001600160401b0382111761186757604052565b90601f801991011681019081106001600160401b0382111761186757604052565b60005b83811061246a5750506000910152565b818101518382015260200161245a565b9060209161249381518092818552858086019101612457565b601f01601f1916010190565b9181601f840112156102c6578235916001600160401b0383116102c657602083818601950101116102c657565b602435906001600160401b03821682036102c657565b9060058210156104125752565b60a0908161ffff91828151168552826020820151166020860152826040820151166040860152826060820151166060860152826080820151166080860152015116910152565b61264990602081526001600160401b038084511660208301526020840151166040820152604083015163ffffffff80911660608301528060608501511660808301528060808501511660a083015260a08401511660c08201526125a060c084015160e08301906124e2565b61022060e08401516101009081840152840151610120908184015284015161014090818401528401516101609081840152840151936126236125f1610180966102c0888701526102e086019061247a565b9582015161260e601f19976101a09289888303018489015261247a565b908301516101c097868303018887015261247a565b948101516101e090151581850152810151906102009115158285015201519101906124ef565b90565b6024359063ffffffff821682036102c657565b6044359063ffffffff821682036102c657565b6064359063ffffffff821682036102c657565b6084359063ffffffff821682036102c657565b60409060031901126102c6576004359060243590565b9060038210156104125752565b60809060031901126102c657600435906024356001600160401b03811681036102c657906044359060643590565b600435906001600160a01b03821682036102c657565b346102c65760003660031901126102c657602060405160648152f35b9190820180921161097c57565b9190820391821161097c57565b9291926001600160401b038211611867576040519161275e601f8201601f191660200184612436565b8294818452818301116102c6578281602093846000960137010152565b805482101561279757600052600b602060002091020190600090565b634e487b7160e01b600052603260045260246000fd5b9060058110156104125760ff80198354169116179055565b90600182811c921680156127f5575b60208310146127df57565b634e487b7160e01b600052602260045260246000fd5b91607f16916127d4565b90601f811161280d57505050565b6000916000526020600020906020601f850160051c8301941061284b575b601f0160051c01915b82811061284057505050565b818155600101612834565b909250829061282b565b908060209392818452848401376000828201840152601f01601f1916010190565b1561287d57565b60405162461bcd60e51b815260206004820152600d60248201526c27a7262cafa7a822a920aa27a960991b6044820152606490fd5b156128b957565b60405162461bcd60e51b815260206004820152600f60248201526e1513d2d15397d393d517d193d55391608a1b6044820152606490fd5b80548210156127975760005260206000209060021b0190600090565b805467ffffffffffffffff60801b191660809290921b67ffffffffffffffff60801b16919091179055565b9060038110156104125760ff80198354169116179055565b6040519061295c82612393565b8160a06000918281528260208201528260408201528260608201528260808201520152565b6040519061298e826123ae565b8160008082528060208301528060408301528060608301528060808301528060a08301528060c08301528060e08301528061010083015280610120830152806101408301526060610160830152606061018083015260606101a0830152806101c08301526101e0820152610200612a0361294f565b910152565b15612a0f57565b60405162461bcd60e51b815260206004820152600f60248201526e1393d7d05551125517d49150d3d491608a1b6044820152606490fd5b90604051918260008254612a59816127c5565b90818452602094600191600181169081600014612ac95750600114612a8a575b505050612a8892500383612436565b565b600090815285812095935091905b818310612ab1575050612a889350820101388080612a79565b85548884018501529485019487945091830191612a98565b92505050612a8894925060ff191682840152151560051b820101388080612a79565b90604051612af881612393565b60a081935461ffff908181168452818160101c166020850152818160201c166040850152818160301c166060850152818160401c16608085015260501c16910152565b90604051612b48816123ae565b809280546001600160401b0380821684528160401c16602084015263ffffffff808260801c166040850152808260a01c1660608501528160c01c16608084015260e01c60a083015260ff60018201541690600582101561041257600a612a03916102009360c0860152600281015460e0860152600381015461010086015260048101546101208601526005810154610140860152612be860068201612a46565b610160860152612bfa60078201612a46565b610180860152612c0c60088201612a46565b6101a086015260ff600982015481811615156101c088015260081c1615156101e086015201612aeb565b15612c3d57565b60405162461bcd60e51b8152602060048201526013602482015272494e4445585f4f55545f4f465f424f554e445360681b6044820152606490fd5b8115612c82570490565b634e487b7160e01b600052601260045260246000fd5b612ca061294f565b50600081815260096020526040902054612cc4906001600160a01b031615156128b2565b60009080825260076020526040822054612cdf811515612a08565b829083849285869187948897895b8a838210612dbb57505050508615612d84578697509286959286809693819661ffff9687809681612d2081978296612c78565b169e612d2b91612c78565b169b612d3691612c78565b1696612d4191612c78565b1695612d4c91612c78565b1694612d5791612c78565b169360405195612d6687612393565b8652602086015260408501526060840152608083015260a082015290565b5050505050505060405190612d9882612393565b80825280602083015280604083015280606083015280608083015260a082015290565b600a6113258360408487612dd5965260076020522061277b565b61ffff808251168015801590612ee0575b8015612ed1575b8015612ec2575b8015612eb3575b8015612ea4575b612e12575b505050600101612ced565b612e25919298979b99969c9a939c61271b565b9481602089015116612e369161271b565b9781604089015116612e479161271b565b9981606089015116612e589161271b565b9581608089015116612e699161271b565b9660a0015116612e789161271b565b966000198114612e9057600180910199903880612e07565b634e487b7160e01b8b52601160045260248bfd5b508160a0840151161515612e02565b50816080840151161515612dfb565b50816060840151161515612df4565b50816040840151161515612ded565b50816020840151161515612de6565b15612ef657565b60405162461bcd60e51b815260206004820152600a60248201526927a7262cafa7aba722a960b11b6044820152606490fd5b90600163ffffffff8093160191821161097c57565b90612f8a6035604051809360208201956001600160601b03199060601b168652601d60f91b6034830152612f7a8151809260208686019101612457565b8101036015810184520182612436565b51902090565b6001600160401b03908116600019019190821161097c57565b906001600160401b03908181161561302c57612fc490612f90565b16816000526007602052604060002054811015612ff557612ff1916000526007602052604060002061277b565b5090565b60405162461bcd60e51b815260206004820152600f60248201526e105551125517d393d517d193d55391608a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f1253959053125117d05551125517d25160821b6044820152606490fd5b60008181526009602052604090205492939290919061308d906001600160a01b031615156128b2565b600584101561041257831561344f57600093828552602060078152604091828720546130ba811515612a08565b85885260078352838820600019820191821161343b57906130da9161277b565b5091600191600184019260ff8454166005811015613427576133f057908991886001600160401b039861315a848b4216986131388a8c9067ffffffffffffffff60401b82549160401b169067ffffffffffffffff60401b1916179055565b8a5463ffffffff60801b1916608085901b63ffffffff60801b16178b556127ad565b81855260068652888520600401805470ffffffffffffffff0000000000000000001916604889901b67ffffffffffffffff60481b16178155996131cb63ffffffff9b6131ab8d825460881c16612f28565b815463ffffffff60881b191660889190911b63ffffffff60881b16179055565b88541692600760038a01549901908b8b51936131e785896124e2565b16998a898501528b84015260806060840152868254613205816127c5565b9384608087015260a0916001811690816000146133a25750600114613342575b5050505050807f80f307f5798ed339302133e4f353681cc7f5cc7333f5c829480b6812cf527f33916001960390a314613263575b5050505050509050565b600c908689525282872091613277836138d7565b60320284811690810361332e5784606481855460601c169204160184811161332e5761331892916132ea6000805160206139c88339815191529798996132f0936127109150818982161160001461332757505b845463ffffffff60601b191660609190911b63ffffffff60601b16178455565b8261290c565b548251606082901c9490941663ffffffff16845290911c60030b602083015281906040820190565b0390a280388080808080613259565b90506132ca565b634e487b7160e01b88526011600452602488fd5b9091809493995052888084205b83851061338b5750505050810160a0019450807f80f307f5798ed339302133e4f353681cc7f5cc7333f5c829480b6812cf527f338e3880613225565b80548587018401528f96509301928990890161334f565b91505060019950859491507f80f307f5798ed339302133e4f353681cc7f5cc7333f5c829480b6812cf527f3395935060a0925060ff191682840152151560051b8201019650918e3880613225565b855162461bcd60e51b815260048101849052601060248201526f1393d7d4115391125391d7d05551125560821b6044820152606490fd5b634e487b7160e01b8b52602160045260248bfd5b634e487b7160e01b89526011600452602489fd5b60405162461bcd60e51b815260206004820152600e60248201526d494e56414c49445f53544154555360901b6044820152606490fd5b9692989360079d9a96929c989b9591600098895260209e8f52604089209a8b546000199c8d820191821161380a57906134bd9161277b565b50805463ffffffff60a01b191660a09390931b63ffffffff60a01b16929092178255909d8e9190825463ffffffff60c01b191660c09190911b63ffffffff60c01b1617825581546001600160e01b031660e09190911b6001600160e01b03191617905560028d015560038c015560048b015560058a015560068901906001600160401b03988982116137f6576135578261175685546127c5565b8590601f83116001146137945761358592918791836136985750508160011b916000199060031b1c19161790565b90555b6007880191878211613780576135a28261175685546127c5565b8390601f831160011461371f576135d092918591836136985750508160011b916000199060031b1c19161790565b90555b6008860194841161370b576135f2846135ec87546127c5565b876127ff565b8092601f85116001146136a35750600a959493613625939092836136985750508160011b916000199060031b1c19161790565b90555b019161ffff81511683549265ffff0000000063ffff00008285015160101b16916040850151901b169067ffff000000000000606085015160301b169261ffff60401b608086015160401b169460a061ffff60501b91015160501b16956001600160601b0319161717171717179055565b0135905038806117a3565b8582528782209391601f198616905b898282106136f557505091859391600a98979660019694106136dd575b50505050811b019055613628565b60f88560031b161c19910135169055388080806136cf565b60018597829396880135815501960193016136b2565b634e487b7160e01b81526041600452602490fd5b8385528a852091601f198416865b8d82821061376a575050908460019594939210613752575b505050811b0190556135d3565b8860f88560031b161c19910135169055388080613745565b600184968293958701358155019501920161372d565b634e487b7160e01b84526041600452602484fd5b8387528c872091601f198416888f5b8282106137df5750509084600195949392106137c7575b505050811b019055613588565b8a60f88560031b161c199101351690553880806137ba565b60018496829395870135815501950192018f6137a3565b634e487b7160e01b86526041600452602486fd5b634e487b7160e01b8c52601160045260248cfd5b906001600160401b03908181161561389e5761383990612f90565b1681600052600b60205260406000205481101561386657612ff191600052600b60205260406000206128f0565b60405162461bcd60e51b815260206004820152601060248201526f10541411505317d393d517d193d5539160821b6044820152606490fd5b60405162461bcd60e51b81526020600482015260116024820152701253959053125117d0541411505317d251607a1b6044820152606490fd5b8054906001600160401b0391828160801c16159081156139b5575b506139a95781421690805492808460801c16830381811161097c571680156139a35763ffffffff809460601c1690606482028281046064148315171561097c5760648284020291818304149015171561097c57640608f3d000900481811061396e575050805463ffffffff60601b19168155612a88925061290c565b8416900392831161097c57805463ffffffff60601b191660609390931b63ffffffff60601b16929092178255612a889161290c565b50505050565b612a889142169061290c565b63ffffffff915060601c1615386138f256fef2af20e52964303611e2a2930d6e08b03cf289fc9c25b00c435cd7bf4fd72773a2646970667358221220351d2a3addd457db2532f47731b627a11d10820517769eb296bfe543093bc12264736f6c63430008180033", + "compiler": { + "version": "0.8.24" + }, + "metadata": { + "compiler": { + "version": "0.8.24+commit.e11b9ed9" + }, + "language": "Solidity", + "output": { + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "initialServiceFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "initialMinimumBond", + "type": "uint256" + }, + { + "internalType": "address", + "name": "initialOperator", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "agentName", + "type": "string" + } + ], + "name": "AgentRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + } + ], + "name": "AppealFiled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + } + ], + "name": "AppealRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "enum AgentAuditRegistryV3.AppealOutcome", + "name": "outcome", + "type": "uint8" + } + ], + "name": "AppealResolved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "enum AgentAuditRegistryV3.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "string", + "name": "reportCID", + "type": "string" + } + ], + "name": "AuditRecorded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "agentName", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bondAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + } + ], + "name": "AuditRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "BondCompensated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "BondSlashed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOperator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOperator", + "type": "address" + } + ], + "name": "OperatorUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "serviceFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minimumBond", + "type": "uint256" + } + ], + "name": "PricingUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "currentScore", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "int32", + "name": "delta", + "type": "int32" + } + ], + "name": "ReputationUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "APPEAL_FAILURE_PENALTY", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "APPEAL_SUCCESS_BONUS", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BASE_POINTS_PER_AUDIT", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DECAY_PERIOD", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DECAY_RATE_BPS", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_REPUTATION_SCORE", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "accruedServiceFees", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "compensateBond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "evidenceHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "appealCID", + "type": "string" + } + ], + "name": "fileAppeal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAgentProfile", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "internalType": "string", + "name": "agentName", + "type": "string" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalBond", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "blacklisted", + "type": "bool" + }, + { + "internalType": "uint64", + "name": "createdAt", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "lastAuditAt", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "auditCount", + "type": "uint32" + } + ], + "internalType": "struct AgentAuditRegistryV3.AgentProfile", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAppealCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + } + ], + "name": "getAppealRecord", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "filedAt", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "resolvedAt", + "type": "uint64" + }, + { + "internalType": "enum AgentAuditRegistryV3.AppealOutcome", + "name": "outcome", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "evidenceHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "appealCID", + "type": "string" + } + ], + "internalType": "struct AgentAuditRegistryV3.AppealRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAuditCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getAuditReportByIndex", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV3.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "internalType": "bool", + "name": "appealRequested", + "type": "bool" + }, + { + "internalType": "bool", + "name": "appealApproved", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV3.DimensionalScores", + "name": "dimensionalScores", + "type": "tuple" + } + ], + "internalType": "struct AgentAuditRegistryV3.AuditRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAverageScores", + "outputs": [ + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV3.DimensionalScores", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "auditIndex", + "type": "uint256" + } + ], + "name": "getDimensionalScores", + "outputs": [ + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV3.DimensionalScores", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getLatestAuditReport", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV3.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "internalType": "bool", + "name": "appealRequested", + "type": "bool" + }, + { + "internalType": "bool", + "name": "appealApproved", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV3.DimensionalScores", + "name": "dimensionalScores", + "type": "tuple" + } + ], + "internalType": "struct AgentAuditRegistryV3.AuditRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getReputation", + "outputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "successfulAppeals", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "failedAppeals", + "type": "uint32" + }, + { + "internalType": "int32", + "name": "reputationDelta", + "type": "int32" + }, + { + "internalType": "uint32", + "name": "currentReputationScore", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "lastReputationUpdateAt", + "type": "uint64" + } + ], + "internalType": "struct AgentAuditRegistryV3.ReputationRecord", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "developer", + "type": "address" + }, + { + "internalType": "string", + "name": "agentName", + "type": "string" + } + ], + "name": "getTokenId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + } + ], + "name": "markAppealRequested", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "minimumBond", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "operator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "ownerOf", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV3.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + } + ], + "name": "recordAuditResult", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "auditScore", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "memoryPeakMb", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "cpuAvgMilli", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "requestIpCount", + "type": "uint32" + }, + { + "internalType": "enum AgentAuditRegistryV3.AuditStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "manifestHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "reportHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "evidenceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "attestationHash", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "evidenceCID", + "type": "string" + }, + { + "internalType": "string", + "name": "reportCID", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "security", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "taskExecution", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "cognitive", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "environment", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "engineering", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "compliance", + "type": "uint16" + } + ], + "internalType": "struct AgentAuditRegistryV3.DimensionalScores", + "name": "scores", + "type": "tuple" + } + ], + "name": "recordAuditResultV2", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "appealId", + "type": "uint64" + }, + { + "internalType": "enum AgentAuditRegistryV3.AppealOutcome", + "name": "outcome", + "type": "uint8" + } + ], + "name": "resolveAppeal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "serviceFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOperator", + "type": "address" + } + ], + "name": "setOperator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newServiceFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "newMinimumBond", + "type": "uint256" + } + ], + "name": "setPricing", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "auditId", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "reasonCode", + "type": "bytes32" + } + ], + "name": "slashBond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "agentName", + "type": "string" + }, + { + "internalType": "string", + "name": "manifestUrl", + "type": "string" + } + ], + "name": "stake", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + } + }, + "settings": { + "compilationTarget": { + "src/AgentAuditRegistryV3.sol": "AgentAuditRegistryV3" + }, + "evmVersion": "paris", + "libraries": {}, + "metadata": { + "bytecodeHash": "ipfs" + }, + "optimizer": { + "enabled": true, + "runs": 200 + }, + "remappings": [], + "viaIR": true + }, + "sources": { + "src/AgentAuditRegistryV3.sol": { + "keccak256": "0x33aadd8a433c467aaabe84e17982133311ca9233e43f54d95a4b4de5111e0a59", + "license": "MIT", + "urls": [ + "bzz-raw://c2a7be5ed0e10aa29d9e0b086465354bd7ca1562de1de13abe478dd15d1f0b8f", + "dweb:/ipfs/QmW71KrwRjTdWZvjq8UXJoYVABZyfFxLeTmZCFnZvCpVQi" + ] + } + }, + "version": 1 + } +} diff --git a/contracts/artifacts/AgentMarketplace.json b/contracts/artifacts/AgentMarketplace.json new file mode 100644 index 0000000..413dffe --- /dev/null +++ b/contracts/artifacts/AgentMarketplace.json @@ -0,0 +1,510 @@ +{ + "contractName": "AgentMarketplace", + "sourceName": "src/AgentMarketplace.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "initialOperator", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "buyer", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isRental", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "expiresAt", + "type": "uint64" + } + ], + "name": "AccessGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "pricePerDay", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "buyPrice", + "type": "uint256" + } + ], + "name": "PriceSet", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "buyAgent", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAccessCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getPricing", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pricePerDay", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "buyPrice", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "configured", + "type": "bool" + } + ], + "internalType": "struct AgentMarketplace.PricingInfo", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "hasAccess", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "operator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "durationDays", + "type": "uint256" + } + ], + "name": "rentAgent", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pricePerDay", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "buyPrice", + "type": "uint256" + } + ], + "name": "setPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x60803461008d57601f6108e938819003918201601f19168301916001600160401b038311848410176100925780849260209460405283398101031261008d57516001600160a01b038082169182810361008d57600080546001600160a01b03199081163317909155926100885750335b1690600154161760015560405161084090816100a98239f35b61006f565b600080fd5b634e487b7160e01b600052604160045260246000fdfe6080604081815260048036101561001557600080fd5b600092833560e01c908163570ca735146105ba5750806358f35551146105935780638da5cb5b1461056b5780639a9e6bb514610398578063aa585d561461029c578063c12f1a4214610222578063ced14198146101df5763fa3ded901461007b57600080fd5b602091826003193601126101db57813591828552600284528185206100c88380516100a5816105df565b8354815260ff60026001860154958a84019687520154161515918291015261062d565b8051156101aa576100dc905134101561066b565b6100e633846107c2565b80865281855260ff83872054166101745785528352808420805460ff191660011790558184526003835280842081517fc409ce2e63458aae57caa4b8a9915277522b0312fd479cc96c7ccb004acdce0d9291610164919061014682610611565b858252338783015287848301523460608301528760808301526106d1565b848151948186528501523393a380f35b5083606492519162461bcd60e51b835282015260116024820152701053149150511657d4155490d21054d151607a1b6044820152fd5b5083606492519162461bcd60e51b8352820152600c60248201526b4e4f545f464f525f53414c4560a01b6044820152fd5b8380fd5b503461021e578160031936011261021e57602435926001600160a01b038416840361021b5750602092610212913561077e565b90519015158152f35b80fd5b8280fd5b503461021e57602036600319011261021e57828291606094838051610246816105df565b8281528260208201520152358152600260205220908051610266816105df565b8254928382528260ff60026001840154936020860194855201541692019115158252825193845251602084015251151590820152f35b50903461021e57606036600319011261021e57600154823592602435916044359190336001600160a01b039182161490811561038b575b5015610358575090829161034a7f22db173e2a8b7fa2d933790c01e64878b79e267d813bb3227a15b1c7ac404ffe945161030c816105df565b8381526002602082018481528683019060018252898b5282602052878b209351845551600184015551151591019060ff801983541691151516179055565b82519182526020820152a280f35b606490602085519162461bcd60e51b8352820152600d60248201526c27a7262cafa7a822a920aa27a960991b6044820152fd5b90508654163314386102d3565b5091908060031936011261056757823560243591818452602092600284528185206103e860ff60028551936103cc856105df565b805485526001810154898601520154161515808584015261062d565b811561053157518181029080820483149015171561051e5761040c9034101561066b565b620151808082029182040361050b57907fc409ce2e63458aae57caa4b8a9915277522b0312fd479cc96c7ccb004acdce0d916104e167ffffffffffffffff91828061045783426106ae565b169161046333896107c2565b92838b5260058a52868b2090815442858216116000146104f1575050908261048c9254166106ae565b16908852600587528388208167ffffffffffffffff198254161790555b85885260038752838820928451916104c083610611565b878352338984015216928385830152346060830152600160808301526106d1565b815194600186528501523393a380f35b67ffffffffffffffff1916811790915592506104a9915050565b634e487b7160e01b855260118652602485fd5b634e487b7160e01b865260118752602486fd5b825162461bcd60e51b8152808801869052601060248201526f24a72b20a624a22fa22aa920aa24a7a760811b6044820152606490fd5b5080fd5b505034610567578160031936011261056757905490516001600160a01b039091168152602090f35b503461021e57602036600319011261021e5760209282913581526003845220549051908152f35b8490346105675781600319360112610567576001546001600160a01b03168152602090f35b6060810190811067ffffffffffffffff8211176105fb57604052565b634e487b7160e01b600052604160045260246000fd5b60a0810190811067ffffffffffffffff8211176105fb57604052565b1561063457565b60405162461bcd60e51b815260206004820152600f60248201526e14149250d25391d7d393d517d4d155608a1b6044820152606490fd5b1561067257565b60405162461bcd60e51b8152602060048201526014602482015273125394d551919250d251539517d410565351539560621b6044820152606490fd5b919082018092116106bb57565b634e487b7160e01b600052601160045260246000fd5b908154680100000000000000008110156105fb57600181018084558110156107685760806003916107669460005260206000209060021b0192805184556001840160018060a01b0360208301511681549067ffffffffffffffff60a01b604085015160a01b169163ffffffff60e01b1617179055606081015160028501550151151591019060ff801983541691151516179055565b565b634e487b7160e01b600052603260045260246000fd5b90610788916107c2565b600052600460205260ff604060002054166107bd57600560205267ffffffffffffffff6040600020541642106107bd57600090565b600190565b9060405190602082019283526bffffffffffffffffffffffff199060601b166040820152603481526060810181811067ffffffffffffffff8211176105fb576040525190209056fea26469706673582212204fbe02652749e0e3e0eea3905ebd05679239e162a5b0b1faaaf4171b02757f0364736f6c63430008180033", + "deployedBytecode": "0x6080604081815260048036101561001557600080fd5b600092833560e01c908163570ca735146105ba5750806358f35551146105935780638da5cb5b1461056b5780639a9e6bb514610398578063aa585d561461029c578063c12f1a4214610222578063ced14198146101df5763fa3ded901461007b57600080fd5b602091826003193601126101db57813591828552600284528185206100c88380516100a5816105df565b8354815260ff60026001860154958a84019687520154161515918291015261062d565b8051156101aa576100dc905134101561066b565b6100e633846107c2565b80865281855260ff83872054166101745785528352808420805460ff191660011790558184526003835280842081517fc409ce2e63458aae57caa4b8a9915277522b0312fd479cc96c7ccb004acdce0d9291610164919061014682610611565b858252338783015287848301523460608301528760808301526106d1565b848151948186528501523393a380f35b5083606492519162461bcd60e51b835282015260116024820152701053149150511657d4155490d21054d151607a1b6044820152fd5b5083606492519162461bcd60e51b8352820152600c60248201526b4e4f545f464f525f53414c4560a01b6044820152fd5b8380fd5b503461021e578160031936011261021e57602435926001600160a01b038416840361021b5750602092610212913561077e565b90519015158152f35b80fd5b8280fd5b503461021e57602036600319011261021e57828291606094838051610246816105df565b8281528260208201520152358152600260205220908051610266816105df565b8254928382528260ff60026001840154936020860194855201541692019115158252825193845251602084015251151590820152f35b50903461021e57606036600319011261021e57600154823592602435916044359190336001600160a01b039182161490811561038b575b5015610358575090829161034a7f22db173e2a8b7fa2d933790c01e64878b79e267d813bb3227a15b1c7ac404ffe945161030c816105df565b8381526002602082018481528683019060018252898b5282602052878b209351845551600184015551151591019060ff801983541691151516179055565b82519182526020820152a280f35b606490602085519162461bcd60e51b8352820152600d60248201526c27a7262cafa7a822a920aa27a960991b6044820152fd5b90508654163314386102d3565b5091908060031936011261056757823560243591818452602092600284528185206103e860ff60028551936103cc856105df565b805485526001810154898601520154161515808584015261062d565b811561053157518181029080820483149015171561051e5761040c9034101561066b565b620151808082029182040361050b57907fc409ce2e63458aae57caa4b8a9915277522b0312fd479cc96c7ccb004acdce0d916104e167ffffffffffffffff91828061045783426106ae565b169161046333896107c2565b92838b5260058a52868b2090815442858216116000146104f1575050908261048c9254166106ae565b16908852600587528388208167ffffffffffffffff198254161790555b85885260038752838820928451916104c083610611565b878352338984015216928385830152346060830152600160808301526106d1565b815194600186528501523393a380f35b67ffffffffffffffff1916811790915592506104a9915050565b634e487b7160e01b855260118652602485fd5b634e487b7160e01b865260118752602486fd5b825162461bcd60e51b8152808801869052601060248201526f24a72b20a624a22fa22aa920aa24a7a760811b6044820152606490fd5b5080fd5b505034610567578160031936011261056757905490516001600160a01b039091168152602090f35b503461021e57602036600319011261021e5760209282913581526003845220549051908152f35b8490346105675781600319360112610567576001546001600160a01b03168152602090f35b6060810190811067ffffffffffffffff8211176105fb57604052565b634e487b7160e01b600052604160045260246000fd5b60a0810190811067ffffffffffffffff8211176105fb57604052565b1561063457565b60405162461bcd60e51b815260206004820152600f60248201526e14149250d25391d7d393d517d4d155608a1b6044820152606490fd5b1561067257565b60405162461bcd60e51b8152602060048201526014602482015273125394d551919250d251539517d410565351539560621b6044820152606490fd5b919082018092116106bb57565b634e487b7160e01b600052601160045260246000fd5b908154680100000000000000008110156105fb57600181018084558110156107685760806003916107669460005260206000209060021b0192805184556001840160018060a01b0360208301511681549067ffffffffffffffff60a01b604085015160a01b169163ffffffff60e01b1617179055606081015160028501550151151591019060ff801983541691151516179055565b565b634e487b7160e01b600052603260045260246000fd5b90610788916107c2565b600052600460205260ff604060002054166107bd57600560205267ffffffffffffffff6040600020541642106107bd57600090565b600190565b9060405190602082019283526bffffffffffffffffffffffff199060601b166040820152603481526060810181811067ffffffffffffffff8211176105fb576040525190209056fea26469706673582212204fbe02652749e0e3e0eea3905ebd05679239e162a5b0b1faaaf4171b02757f0364736f6c63430008180033", + "compiler": { + "version": "0.8.24" + }, + "metadata": { + "compiler": { + "version": "0.8.24+commit.e11b9ed9" + }, + "language": "Solidity", + "output": { + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "initialOperator", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "buyer", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isRental", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "expiresAt", + "type": "uint64" + } + ], + "name": "AccessGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "pricePerDay", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "buyPrice", + "type": "uint256" + } + ], + "name": "PriceSet", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "buyAgent", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getAccessCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getPricing", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pricePerDay", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "buyPrice", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "configured", + "type": "bool" + } + ], + "internalType": "struct AgentMarketplace.PricingInfo", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "hasAccess", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "operator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "durationDays", + "type": "uint256" + } + ], + "name": "rentAgent", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pricePerDay", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "buyPrice", + "type": "uint256" + } + ], + "name": "setPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + } + }, + "settings": { + "compilationTarget": { + "src/AgentMarketplace.sol": "AgentMarketplace" + }, + "evmVersion": "paris", + "libraries": {}, + "metadata": { + "bytecodeHash": "ipfs" + }, + "optimizer": { + "enabled": true, + "runs": 200 + }, + "remappings": [], + "viaIR": true + }, + "sources": { + "src/AgentMarketplace.sol": { + "keccak256": "0x380b1d6dded19a67a3ff969058f360cea7c14d0ce6fe64e8358586052b82ac20", + "license": "MIT", + "urls": [ + "bzz-raw://d0ad076d72861fcd931c4b2ce3539229430001c8a7f4c89161291c4fb9221df5", + "dweb:/ipfs/QmToqNJWbTDBgc7ZjakjGewtKANKFfDg758f3JSFV3Rgh3" + ] + } + }, + "version": 1 + } +} diff --git a/contracts/artifacts/AgentReviewRegistry.json b/contracts/artifacts/AgentReviewRegistry.json new file mode 100644 index 0000000..17f42c9 --- /dev/null +++ b/contracts/artifacts/AgentReviewRegistry.json @@ -0,0 +1,603 @@ +{ + "contractName": "AgentReviewRegistry", + "sourceName": "src/AgentReviewRegistry.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "marketplaceAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "reviewId", + "type": "uint64" + }, + { + "indexed": true, + "internalType": "address", + "name": "reviewer", + "type": "address" + } + ], + "name": "ReviewSubmitted", + "type": "event" + }, + { + "inputs": [], + "name": "RATING_BAD", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RATING_GOOD", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RATING_NEUTRAL", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getRatingDistribution", + "outputs": [ + { + "internalType": "uint16[6]", + "name": "goodRatios", + "type": "uint16[6]" + }, + { + "internalType": "uint16[6]", + "name": "neutralRatios", + "type": "uint16[6]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getReview", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "reviewId", + "type": "uint64" + }, + { + "internalType": "address", + "name": "reviewer", + "type": "address" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint8", + "name": "securityRating", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "taskExecutionRating", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "cognitiveRating", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "environmentRating", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "engineeringRating", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "complianceRating", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "commentHash", + "type": "bytes32" + } + ], + "internalType": "struct AgentReviewRegistry.Review", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getReviewCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "reviewer", + "type": "address" + } + ], + "name": "hasReviewed", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "marketplace", + "outputs": [ + { + "internalType": "contract IAgentMarketplace", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint8[6]", + "name": "ratings", + "type": "uint8[6]" + }, + { + "internalType": "bytes32", + "name": "commentHash", + "type": "bytes32" + } + ], + "name": "submitReview", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x60803461008b57601f610c4e38819003918201601f19168301916001600160401b038311848410176100905780849260209460405283398101031261008b57516001600160a01b0381169081900361008b5760018054600080546001600160a01b031916331790556001600160e01b031916909117600160a01b179055604051610ba790816100a78239f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe6080604081815260048036101561001557600080fd5b600092833560e01c9081631cbe3d4114610777575080635d75135a146107505780637c7198cc146106dc5780638da5cb5b146106b4578063a07a478914610676578063abc8c7af1461064d578063d045422514610631578063de1282c514610612578063dfa505ed146104c15763eded67dd1461009157600080fd5b346104bd576101003660031901126104bd578035903660e4116104b957600154928051916319da283360e31b835283818401526024903382850152602093604490858160448160018060a01b038c165afa9081156104af578991610475575b50156104485783518581018781523360601b6bffffffffffffffffffffffff191660208201529061012e81603484015b03601f19810183528261080d565b519020928389526003865260ff9182868b20541661041357895b600681106103c157505067ffffffffffffffff808960a01c169860018a018281116103af5767ffffffffffffffff60a01b1990911660a09190911b67ffffffffffffffff60a01b1617600155878a5260028752858a2092823580821692908390036103ab576044358281168091036103a7576064358381168091036103a3576084359184831680930361039f5760a4359385851680950361039b5760c43595861680960361039b578b518f6101fc826107be565b81528d8101903382528d8101998342168b5260608201998a526080820194855260a0820195865260c0820196875260e08201978852610100820198895261012082019b60e4358d52805490600160401b82101561038457906102639160018201815561082f565b9d909d61036b5750509c69ff0000000000000000007f3d9a95745b95ec2cc2b32b152005816f581eddc9318a0d512496def0107443c39f9e84839f9e9d9b9997958e60029e9c9a989660019268ff00000000000000009551168254918167ffffffffffffffff198416178455600160401b8560e01b039051891b169163ffffffff60e01b1617178155019a5116928a549951901b16925160481b169260ff60501b905160501b169360ff60581b905160581b169460ff60601b905160601b169560ff60681b905160681b16966dffffffffffffffffffffffffffff191617171717171717905551910155865260038252808620600160ff19825416179055519384523393a380f35b9350955050508f9250829150634e487b7160e01b825252fd5b5050925050508f60418b634e487b7160e01b835252fd5b8f80fd5b8e80fd5b8d80fd5b8c80fd5b8b80fd5b634e487b7160e01b8c5260118652838cfd5b8060051b8301358481168091036103ab576002106103e157600101610148565b865162461bcd60e51b8152808601899052600e818501526d494e56414c49445f524154494e4760901b81840152606490fd5b855162461bcd60e51b81528085018890526010818401526f1053149150511657d49155925155d15160821b6044820152606490fd5b5060096064928585519362461bcd60e51b8552840152820152684e4f5f41434345535360b81b6044820152fd5b90508581813d83116104a8575b61048c818361080d565b810103126104a4575180151581036104a457386100f0565b8880fd5b503d610482565b85513d8b823e3d90fd5b8380fd5b8280fd5b50823461060f578260031936011261060f578135916024358451926104e5846107be565b808452602094818686015281878601528160608601528160808601528160a08601528160c08601528160e0860152610100938285870152826101208097015281835260028752878320548410156105d6575061055387936101409884610559948998965260028a522061082f565b50610861565b9180519567ffffffffffffffff9081855116885260018060a01b03818601511690880152818401511690860152606082015160ff80911660608701528060808401511660808701528060a08401511660a08701528060c08401511660c08701528060e08401511660e0870152818301511690850152015190820152f35b875162461bcd60e51b81529081018790526013602482015272494e4445585f4f55545f4f465f424f554e445360681b6044820152606490fd5b80fd5b50503461062d578160031936011261062d5751908152602090f35b5080fd5b50503461062d578160031936011261062d576020905160028152f35b50503461062d578160031936011261062d5760015490516001600160a01b039091168152602090f35b50913461060f57602036600319011261060f57506106b26106a861069d6101809435610945565b919093518094610792565b60c0830190610792565bf35b50503461062d578160031936011261062d57905490516001600160a01b039091168152602090f35b50346104bd57816003193601126104bd576024356001600160a01b03811681036104b95782519135602083810191825260609290921b6bffffffffffffffffffffffff19166040840152909360ff9284929061073b8160548101610120565b51902081526003855220541690519015158152f35b50346104bd5760203660031901126104bd5760209282913581526002845220549051908152f35b84903461062d578160031936011261062d5780600160209252f35b6000915b600683106107a357505050565b60019061ffff83511681526020809101920192019190610796565b610140810190811067ffffffffffffffff8211176107db57604052565b634e487b7160e01b600052604160045260246000fd5b60c0810190811067ffffffffffffffff8211176107db57604052565b90601f8019910116810190811067ffffffffffffffff8211176107db57604052565b805482101561084b576000526003602060002091020190600090565b634e487b7160e01b600052603260045260246000fd5b9060405161086e816107be565b61012060028294805467ffffffffffffffff90818116865260018060a01b039060401c1660208601526001820154908116604086015260ff90818160401c166060870152818160481c166080870152818160501c1660a0870152818160581c1660c0870152818160601c1660e087015260681c166101008501520154910152565b90600681101561084b5760051b0190565b600019811461090f5760010190565b634e487b7160e01b600052601160045260246000fd5b811561092f570490565b634e487b7160e01b600052601260045260246000fd5b906040908151610954816107f1565b60c0803683378194845191610968836107f1565b803684378295600092808452600290602095600260205283862054978815610b64575050825195610998876107f1565b843688378351946109a8866107f1565b80368737865b898110610a5857505050505050815b600681106109cc575050505050565b6109d681856108ef565b516127109081810290808204831490151715610a44579086916109fd61ffff938492610925565b16610a08848c6108ef565b52610a1383856108ef565b51818102918183041490151715610a445790610a328760019493610925565b16610a3d828a6108ef565b52016109bd565b634e487b7160e01b85526011600452602485fd5b838852848352610a6d61055382888b2061082f565b865183810181811067ffffffffffffffff821117610b5057885260ff9182610100606092828482015116855260808381830151168a87015260a0948d85878501511690880152848a84015116908701528360e0830151169086015201511690820152895b60068110610ae4575050506001016109ae565b808884610af3600194866108ef565b511603610b20578c610b1882610b12610b0c82856108ef565b51610900565b926108ef565b525b01610ad1565b8184610b2c83866108ef565b511603610b1a57610b40610b0c828d6108ef565b610b4a828d6108ef565b52610b1a565b634e487b7160e01b8b52604160045260248bfd5b9a5098505050505050505056fea2646970667358221220b05dd048e1d06785f573ada2b0f2016bbe0ca4d41538ac516adb0f2074573bd764736f6c63430008180033", + "deployedBytecode": "0x6080604081815260048036101561001557600080fd5b600092833560e01c9081631cbe3d4114610777575080635d75135a146107505780637c7198cc146106dc5780638da5cb5b146106b4578063a07a478914610676578063abc8c7af1461064d578063d045422514610631578063de1282c514610612578063dfa505ed146104c15763eded67dd1461009157600080fd5b346104bd576101003660031901126104bd578035903660e4116104b957600154928051916319da283360e31b835283818401526024903382850152602093604490858160448160018060a01b038c165afa9081156104af578991610475575b50156104485783518581018781523360601b6bffffffffffffffffffffffff191660208201529061012e81603484015b03601f19810183528261080d565b519020928389526003865260ff9182868b20541661041357895b600681106103c157505067ffffffffffffffff808960a01c169860018a018281116103af5767ffffffffffffffff60a01b1990911660a09190911b67ffffffffffffffff60a01b1617600155878a5260028752858a2092823580821692908390036103ab576044358281168091036103a7576064358381168091036103a3576084359184831680930361039f5760a4359385851680950361039b5760c43595861680960361039b578b518f6101fc826107be565b81528d8101903382528d8101998342168b5260608201998a526080820194855260a0820195865260c0820196875260e08201978852610100820198895261012082019b60e4358d52805490600160401b82101561038457906102639160018201815561082f565b9d909d61036b5750509c69ff0000000000000000007f3d9a95745b95ec2cc2b32b152005816f581eddc9318a0d512496def0107443c39f9e84839f9e9d9b9997958e60029e9c9a989660019268ff00000000000000009551168254918167ffffffffffffffff198416178455600160401b8560e01b039051891b169163ffffffff60e01b1617178155019a5116928a549951901b16925160481b169260ff60501b905160501b169360ff60581b905160581b169460ff60601b905160601b169560ff60681b905160681b16966dffffffffffffffffffffffffffff191617171717171717905551910155865260038252808620600160ff19825416179055519384523393a380f35b9350955050508f9250829150634e487b7160e01b825252fd5b5050925050508f60418b634e487b7160e01b835252fd5b8f80fd5b8e80fd5b8d80fd5b8c80fd5b8b80fd5b634e487b7160e01b8c5260118652838cfd5b8060051b8301358481168091036103ab576002106103e157600101610148565b865162461bcd60e51b8152808601899052600e818501526d494e56414c49445f524154494e4760901b81840152606490fd5b855162461bcd60e51b81528085018890526010818401526f1053149150511657d49155925155d15160821b6044820152606490fd5b5060096064928585519362461bcd60e51b8552840152820152684e4f5f41434345535360b81b6044820152fd5b90508581813d83116104a8575b61048c818361080d565b810103126104a4575180151581036104a457386100f0565b8880fd5b503d610482565b85513d8b823e3d90fd5b8380fd5b8280fd5b50823461060f578260031936011261060f578135916024358451926104e5846107be565b808452602094818686015281878601528160608601528160808601528160a08601528160c08601528160e0860152610100938285870152826101208097015281835260028752878320548410156105d6575061055387936101409884610559948998965260028a522061082f565b50610861565b9180519567ffffffffffffffff9081855116885260018060a01b03818601511690880152818401511690860152606082015160ff80911660608701528060808401511660808701528060a08401511660a08701528060c08401511660c08701528060e08401511660e0870152818301511690850152015190820152f35b875162461bcd60e51b81529081018790526013602482015272494e4445585f4f55545f4f465f424f554e445360681b6044820152606490fd5b80fd5b50503461062d578160031936011261062d5751908152602090f35b5080fd5b50503461062d578160031936011261062d576020905160028152f35b50503461062d578160031936011261062d5760015490516001600160a01b039091168152602090f35b50913461060f57602036600319011261060f57506106b26106a861069d6101809435610945565b919093518094610792565b60c0830190610792565bf35b50503461062d578160031936011261062d57905490516001600160a01b039091168152602090f35b50346104bd57816003193601126104bd576024356001600160a01b03811681036104b95782519135602083810191825260609290921b6bffffffffffffffffffffffff19166040840152909360ff9284929061073b8160548101610120565b51902081526003855220541690519015158152f35b50346104bd5760203660031901126104bd5760209282913581526002845220549051908152f35b84903461062d578160031936011261062d5780600160209252f35b6000915b600683106107a357505050565b60019061ffff83511681526020809101920192019190610796565b610140810190811067ffffffffffffffff8211176107db57604052565b634e487b7160e01b600052604160045260246000fd5b60c0810190811067ffffffffffffffff8211176107db57604052565b90601f8019910116810190811067ffffffffffffffff8211176107db57604052565b805482101561084b576000526003602060002091020190600090565b634e487b7160e01b600052603260045260246000fd5b9060405161086e816107be565b61012060028294805467ffffffffffffffff90818116865260018060a01b039060401c1660208601526001820154908116604086015260ff90818160401c166060870152818160481c166080870152818160501c1660a0870152818160581c1660c0870152818160601c1660e087015260681c166101008501520154910152565b90600681101561084b5760051b0190565b600019811461090f5760010190565b634e487b7160e01b600052601160045260246000fd5b811561092f570490565b634e487b7160e01b600052601260045260246000fd5b906040908151610954816107f1565b60c0803683378194845191610968836107f1565b803684378295600092808452600290602095600260205283862054978815610b64575050825195610998876107f1565b843688378351946109a8866107f1565b80368737865b898110610a5857505050505050815b600681106109cc575050505050565b6109d681856108ef565b516127109081810290808204831490151715610a44579086916109fd61ffff938492610925565b16610a08848c6108ef565b52610a1383856108ef565b51818102918183041490151715610a445790610a328760019493610925565b16610a3d828a6108ef565b52016109bd565b634e487b7160e01b85526011600452602485fd5b838852848352610a6d61055382888b2061082f565b865183810181811067ffffffffffffffff821117610b5057885260ff9182610100606092828482015116855260808381830151168a87015260a0948d85878501511690880152848a84015116908701528360e0830151169086015201511690820152895b60068110610ae4575050506001016109ae565b808884610af3600194866108ef565b511603610b20578c610b1882610b12610b0c82856108ef565b51610900565b926108ef565b525b01610ad1565b8184610b2c83866108ef565b511603610b1a57610b40610b0c828d6108ef565b610b4a828d6108ef565b52610b1a565b634e487b7160e01b8b52604160045260248bfd5b9a5098505050505050505056fea2646970667358221220b05dd048e1d06785f573ada2b0f2016bbe0ca4d41538ac516adb0f2074573bd764736f6c63430008180033", + "compiler": { + "version": "0.8.24" + }, + "metadata": { + "compiler": { + "version": "0.8.24+commit.e11b9ed9" + }, + "language": "Solidity", + "output": { + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "marketplaceAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "reviewId", + "type": "uint64" + }, + { + "indexed": true, + "internalType": "address", + "name": "reviewer", + "type": "address" + } + ], + "name": "ReviewSubmitted", + "type": "event" + }, + { + "inputs": [], + "name": "RATING_BAD", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RATING_GOOD", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RATING_NEUTRAL", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getRatingDistribution", + "outputs": [ + { + "internalType": "uint16[6]", + "name": "goodRatios", + "type": "uint16[6]" + }, + { + "internalType": "uint16[6]", + "name": "neutralRatios", + "type": "uint16[6]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getReview", + "outputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "reviewId", + "type": "uint64" + }, + { + "internalType": "address", + "name": "reviewer", + "type": "address" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint8", + "name": "securityRating", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "taskExecutionRating", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "cognitiveRating", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "environmentRating", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "engineeringRating", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "complianceRating", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "commentHash", + "type": "bytes32" + } + ], + "internalType": "struct AgentReviewRegistry.Review", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getReviewCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "reviewer", + "type": "address" + } + ], + "name": "hasReviewed", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "marketplace", + "outputs": [ + { + "internalType": "contract IAgentMarketplace", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint8[6]", + "name": "ratings", + "type": "uint8[6]" + }, + { + "internalType": "bytes32", + "name": "commentHash", + "type": "bytes32" + } + ], + "name": "submitReview", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "devdoc": { + "kind": "dev", + "methods": { + "getRatingDistribution(uint256)": { + "returns": { + "goodRatios": " Percentage of \"good\" ratings per dimension", + "neutralRatios": "Percentage of \"neutral\" ratings per dimension" + } + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "getRatingDistribution(uint256)": { + "notice": "Returns rating distribution for each dimension as basis points (0-10000)." + } + }, + "version": 1 + } + }, + "settings": { + "compilationTarget": { + "src/AgentReviewRegistry.sol": "AgentReviewRegistry" + }, + "evmVersion": "paris", + "libraries": {}, + "metadata": { + "bytecodeHash": "ipfs" + }, + "optimizer": { + "enabled": true, + "runs": 200 + }, + "remappings": [], + "viaIR": true + }, + "sources": { + "src/AgentReviewRegistry.sol": { + "keccak256": "0x08d6bdf9ff5a937a98d70f30c50981832122611cf93d99bcd3b60876b4ee2ffd", + "license": "MIT", + "urls": [ + "bzz-raw://81370c8abac995b58d712bd56dc8fa6535ee153b2ebe41606860233471134168", + "dweb:/ipfs/QmawvpGh2SHq7jmE5be5gMpzAUvZUhw3gqaTnuhaTA2tro" + ] + } + }, + "version": 1 + } +} diff --git a/contracts/scripts/compileV2.js b/contracts/scripts/compileV2.js index 47d1e5a..7ffa12e 100644 --- a/contracts/scripts/compileV2.js +++ b/contracts/scripts/compileV2.js @@ -21,6 +21,7 @@ const artifactDir = path.join(__dirname, "..", "artifacts"); const CONTRACTS = [ { name: "AgentAuditRegistry", file: "AgentAuditRegistry.sol" }, { name: "AgentAuditRegistryV2", file: "AgentAuditRegistryV2.sol" }, + { name: "AgentAuditRegistryV3", file: "AgentAuditRegistryV3.sol" }, { name: "AgentMarketplace", file: "AgentMarketplace.sol" }, { name: "AgentReviewRegistry", file: "AgentReviewRegistry.sol" } ]; diff --git a/contracts/scripts/deployV3.js b/contracts/scripts/deployV3.js new file mode 100644 index 0000000..efb77f0 --- /dev/null +++ b/contracts/scripts/deployV3.js @@ -0,0 +1,76 @@ +const fs = require("fs"); +const path = require("path"); +const { ethers } = require("ethers"); + +const artifactPath = path.join(__dirname, "..", "artifacts", "AgentAuditRegistryV3.json"); +const deploymentsDir = path.join(__dirname, "..", "deployments"); + +function readV3DeploymentConfig(env) { + const rpcUrl = env.EDGE_RPC_URL; + const chainId = env.EDGE_CHAIN_ID; + const deployerPrivateKey = env.EDGE_DEPLOYER_PRIVATE_KEY; + + if (!rpcUrl) throw new Error("EDGE_RPC_URL is required"); + if (!chainId) throw new Error("EDGE_CHAIN_ID is required"); + if (!deployerPrivateKey) throw new Error("EDGE_DEPLOYER_PRIVATE_KEY is required"); + + return { + rpcUrl, + chainId: Number(chainId), + deployerPrivateKey, + networkName: env.EDGE_NETWORK_NAME || "polygon-edge-test", + initialOperator: env.EDGE_INITIAL_OPERATOR || "", + serviceFeeWei: env.EDGE_INITIAL_SERVICE_FEE_WEI || "10000000000000000", + minimumBondWei: env.EDGE_INITIAL_MINIMUM_BOND_WEI || "1000000000000000000" + }; +} + +async function deployV3Registry(config, dependencies = {}) { + const artifact = JSON.parse(fs.readFileSync(artifactPath, "utf8")); + + const provider = dependencies.provider ?? + new ethers.providers.StaticJsonRpcProvider(config.rpcUrl, { + chainId: config.chainId, + name: config.networkName + }); + const wallet = dependencies.wallet ?? + new ethers.Wallet(config.deployerPrivateKey, provider); + + const operatorAddress = config.initialOperator || wallet.address; + + const factory = dependencies.factory ?? + new ethers.ContractFactory(artifact.abi, artifact.bytecode, wallet); + + const contract = await factory.deploy( + config.serviceFeeWei, + config.minimumBondWei, + operatorAddress + ); + + const receipt = await contract.deployTransaction.wait(); + + const metadata = { + contractName: "AgentAuditRegistryV3", + networkName: config.networkName, + chainId: String(config.chainId), + rpcUrl: config.rpcUrl, + address: contract.address, + deployTransactionHash: contract.deployTransaction.hash, + deployedBlockNumber: receipt.blockNumber, + deployer: wallet.address, + constructorArgs: { + initialServiceFeeWei: config.serviceFeeWei, + initialMinimumBondWei: config.minimumBondWei, + initialOperator: operatorAddress + } + }; + + const networkDir = path.join(deploymentsDir, config.networkName); + fs.mkdirSync(networkDir, { recursive: true }); + const metadataPath = path.join(networkDir, "AgentAuditRegistryV3.json"); + fs.writeFileSync(metadataPath, `${JSON.stringify(metadata, null, 2)}\n`); + + return metadata; +} + +module.exports = { deployV3Registry, readV3DeploymentConfig }; diff --git a/contracts/src/AgentAuditRegistryV3.sol b/contracts/src/AgentAuditRegistryV3.sol new file mode 100644 index 0000000..de83d62 --- /dev/null +++ b/contracts/src/AgentAuditRegistryV3.sol @@ -0,0 +1,654 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +contract AgentAuditRegistryV3 { + string public constant name = "Agent Audit Identity V3"; + string public constant symbol = "AAI3"; + + enum AuditStatus { + Pending, + Passed, + Failed, + Slashed, + Compensated + } + + enum AppealOutcome { + Pending, + Approved, + Rejected + } + + struct DimensionalScores { + uint16 security; // 0-10000 basis points + uint16 taskExecution; + uint16 cognitive; + uint16 environment; + uint16 engineering; + uint16 compliance; + } + + struct AgentProfile { + address developer; + string agentName; + uint256 tokenId; + uint256 totalBond; + bool blacklisted; + uint64 createdAt; + uint64 lastAuditAt; + uint32 auditCount; + } + + struct AuditRecord { + uint64 auditId; + uint64 timestamp; + uint32 auditScore; + uint32 memoryPeakMb; + uint32 cpuAvgMilli; + uint32 requestIpCount; + AuditStatus status; + bytes32 manifestHash; + bytes32 reportHash; + bytes32 evidenceRoot; + bytes32 attestationHash; + string evidenceCID; + string reportCID; + string manifestUrl; + bool appealRequested; + bool appealApproved; + DimensionalScores dimensionalScores; + } + + struct AppealRecord { + uint64 appealId; + uint64 auditId; + uint64 filedAt; + uint64 resolvedAt; + AppealOutcome outcome; + bytes32 evidenceHash; + string appealCID; + } + + struct ReputationRecord { + uint32 successfulAppeals; + uint32 failedAppeals; + int32 reputationDelta; + uint32 currentReputationScore; // 0-10000 + uint64 lastReputationUpdateAt; // last update timestamp + } + + // โ”€โ”€ MDDRM Constants โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + uint32 public constant BASE_POINTS_PER_AUDIT = 50; // audit pass base points + uint32 public constant APPEAL_SUCCESS_BONUS = 100; // appeal success bonus + uint32 public constant APPEAL_FAILURE_PENALTY = 200; // appeal failure penalty + uint32 public constant DECAY_RATE_BPS = 100; // 1% = 100 basis points + uint64 public constant DECAY_PERIOD = 30 days; // decay period + uint32 public constant MAX_REPUTATION_SCORE = 10000; // upper bound + + address public owner; + address public operator; + uint256 public serviceFee; + uint256 public minimumBond; + uint256 public accruedServiceFees; + + uint256 private _nextTokenId = 1; + + mapping(uint256 => AgentProfile) private _profiles; + mapping(uint256 => AuditRecord[]) private _auditRecords; + mapping(bytes32 => uint256) private _tokenIdsByIdentity; + mapping(uint256 => address) private _owners; + mapping(address => uint256) private _balances; + mapping(uint256 => AppealRecord[]) private _appealRecords; + mapping(uint256 => ReputationRecord) private _reputations; + + // Events โ€” V1 compatible + event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); + event AgentRegistered(uint256 indexed tokenId, address indexed developer, string agentName); + event AuditRequested( + uint256 indexed tokenId, + address indexed developer, + string agentName, + string manifestUrl, + uint256 bondAmount, + uint64 timestamp + ); + event AuditRecorded( + uint256 indexed tokenId, + uint64 indexed auditId, + AuditStatus status, + uint32 auditScore, + bytes32 reportHash, + string reportCID + ); + event BondSlashed( + uint256 indexed tokenId, + uint64 indexed auditId, + uint256 amount, + bytes32 reasonCode + ); + event AppealRequested(uint256 indexed tokenId, uint64 indexed auditId); + event BondCompensated( + uint256 indexed tokenId, + uint64 indexed auditId, + uint256 amount, + bytes32 reasonCode + ); + event OperatorUpdated(address indexed previousOperator, address indexed newOperator); + event PricingUpdated(uint256 serviceFee, uint256 minimumBond); + + // V2 events + event AppealFiled(uint256 indexed tokenId, uint64 indexed auditId, uint64 appealId); + event AppealResolved(uint256 indexed tokenId, uint64 indexed appealId, AppealOutcome outcome); + + // V3: ReputationUpdated now includes currentScore + event ReputationUpdated(uint256 indexed tokenId, uint32 currentScore, int32 delta); + + modifier onlyOwner() { + require(msg.sender == owner, "ONLY_OWNER"); + _; + } + + modifier onlyOperator() { + require(msg.sender == operator || msg.sender == owner, "ONLY_OPERATOR"); + _; + } + + constructor(uint256 initialServiceFee, uint256 initialMinimumBond, address initialOperator) { + owner = msg.sender; + operator = initialOperator == address(0) ? msg.sender : initialOperator; + serviceFee = initialServiceFee; + minimumBond = initialMinimumBond; + } + + function setOperator(address newOperator) external onlyOwner { + require(newOperator != address(0), "INVALID_OPERATOR"); + address previousOperator = operator; + operator = newOperator; + emit OperatorUpdated(previousOperator, newOperator); + } + + function setPricing(uint256 newServiceFee, uint256 newMinimumBond) external onlyOwner { + serviceFee = newServiceFee; + minimumBond = newMinimumBond; + emit PricingUpdated(newServiceFee, newMinimumBond); + } + + function balanceOf(address account) external view returns (uint256) { + require(account != address(0), "ZERO_ADDRESS"); + return _balances[account]; + } + + function ownerOf(uint256 tokenId) external view returns (address) { + address tokenOwner = _owners[tokenId]; + require(tokenOwner != address(0), "TOKEN_NOT_FOUND"); + return tokenOwner; + } + + function stake( + string calldata agentName, + string calldata manifestUrl + ) external payable returns (uint256 tokenId) { + require(bytes(agentName).length > 0, "EMPTY_AGENT_NAME"); + require(bytes(manifestUrl).length > 0, "EMPTY_MANIFEST_URL"); + require(msg.value >= serviceFee + minimumBond, "INSUFFICIENT_VALUE"); + + uint256 bondAmount = msg.value - serviceFee; + accruedServiceFees += serviceFee; + + bytes32 identityKey = _identityKey(msg.sender, agentName); + tokenId = _tokenIdsByIdentity[identityKey]; + + if (tokenId == 0) { + tokenId = _mintIdentity(msg.sender, agentName); + } + + AgentProfile storage profile = _profiles[tokenId]; + profile.totalBond += bondAmount; + + uint64 auditId = uint64(_auditRecords[tokenId].length + 1); + _auditRecords[tokenId].push( + AuditRecord({ + auditId: auditId, + timestamp: uint64(block.timestamp), + auditScore: 0, + memoryPeakMb: 0, + cpuAvgMilli: 0, + requestIpCount: 0, + status: AuditStatus.Pending, + manifestHash: bytes32(0), + reportHash: bytes32(0), + evidenceRoot: bytes32(0), + attestationHash: bytes32(0), + evidenceCID: "", + reportCID: "", + manifestUrl: manifestUrl, + appealRequested: false, + appealApproved: false, + dimensionalScores: DimensionalScores(0, 0, 0, 0, 0, 0) + }) + ); + + emit AuditRequested( + tokenId, + msg.sender, + agentName, + manifestUrl, + bondAmount, + uint64(block.timestamp) + ); + } + + // V1-compatible audit result recording (no dimensional scores) + function recordAuditResult( + uint256 tokenId, + uint32 auditScore, + uint32 memoryPeakMb, + uint32 cpuAvgMilli, + uint32 requestIpCount, + AuditStatus status, + bytes32 manifestHash, + bytes32 reportHash, + bytes32 evidenceRoot, + bytes32 attestationHash, + string calldata evidenceCID, + string calldata reportCID, + string calldata manifestUrl + ) external onlyOperator { + _recordAuditCore(tokenId, auditScore, status); + _fillAuditRecord(tokenId, memoryPeakMb, cpuAvgMilli, requestIpCount, + manifestHash, reportHash, evidenceRoot, attestationHash, + evidenceCID, reportCID, manifestUrl, + DimensionalScores(0, 0, 0, 0, 0, 0)); + } + + // V2: audit result with dimensional scores + function recordAuditResultV2( + uint256 tokenId, + uint32 auditScore, + uint32 memoryPeakMb, + uint32 cpuAvgMilli, + uint32 requestIpCount, + AuditStatus status, + bytes32 manifestHash, + bytes32 reportHash, + bytes32 evidenceRoot, + bytes32 attestationHash, + string calldata evidenceCID, + string calldata reportCID, + string calldata manifestUrl, + DimensionalScores calldata scores + ) external onlyOperator { + _recordAuditCore(tokenId, auditScore, status); + _fillAuditRecord(tokenId, memoryPeakMb, cpuAvgMilli, requestIpCount, + manifestHash, reportHash, evidenceRoot, attestationHash, + evidenceCID, reportCID, manifestUrl, + scores); + } + + function slashBond( + uint256 tokenId, + uint64 auditId, + uint256 amount, + bytes32 reasonCode + ) external onlyOperator { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + + AgentProfile storage profile = _profiles[tokenId]; + require(amount <= profile.totalBond, "INSUFFICIENT_BOND"); + + AuditRecord storage record = _getAuditRecord(tokenId, auditId); + profile.totalBond -= amount; + profile.blacklisted = true; + record.status = AuditStatus.Slashed; + + // V3: reputation penalty on slash + ReputationRecord storage rep = _reputations[tokenId]; + if (profile.blacklisted) { + rep.currentReputationScore = 0; + } else { + rep.currentReputationScore = rep.currentReputationScore / 2; + } + rep.lastReputationUpdateAt = uint64(block.timestamp); + emit ReputationUpdated(tokenId, rep.currentReputationScore, rep.reputationDelta); + + emit BondSlashed(tokenId, auditId, amount, reasonCode); + } + + function markAppealRequested(uint256 tokenId, uint64 auditId) external onlyOperator { + AuditRecord storage record = _getAuditRecord(tokenId, auditId); + record.appealRequested = true; + emit AppealRequested(tokenId, auditId); + } + + function compensateBond( + uint256 tokenId, + uint64 auditId, + uint256 amount, + bytes32 reasonCode + ) external onlyOperator { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + + AuditRecord storage record = _getAuditRecord(tokenId, auditId); + require(record.status == AuditStatus.Slashed, "AUDIT_NOT_SLASHED"); + + AgentProfile storage profile = _profiles[tokenId]; + profile.totalBond += amount; + record.status = AuditStatus.Compensated; + record.appealApproved = true; + + emit BondCompensated(tokenId, auditId, amount, reasonCode); + } + + // โ”€โ”€ Appeal management (V2) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + + function fileAppeal( + uint256 tokenId, + uint64 auditId, + bytes32 evidenceHash, + string calldata appealCID + ) external onlyOperator { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + + AuditRecord storage record = _getAuditRecord(tokenId, auditId); + record.appealRequested = true; + + uint64 appealId = uint64(_appealRecords[tokenId].length + 1); + _appealRecords[tokenId].push( + AppealRecord({ + appealId: appealId, + auditId: auditId, + filedAt: uint64(block.timestamp), + resolvedAt: 0, + outcome: AppealOutcome.Pending, + evidenceHash: evidenceHash, + appealCID: appealCID + }) + ); + + emit AppealFiled(tokenId, auditId, appealId); + } + + function resolveAppeal( + uint256 tokenId, + uint64 appealId, + AppealOutcome outcome + ) external onlyOperator { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + require(outcome != AppealOutcome.Pending, "INVALID_OUTCOME"); + + AppealRecord storage appeal = _getAppealRecord(tokenId, appealId); + require(appeal.outcome == AppealOutcome.Pending, "APPEAL_ALREADY_RESOLVED"); + + appeal.outcome = outcome; + appeal.resolvedAt = uint64(block.timestamp); + + ReputationRecord storage rep = _reputations[tokenId]; + _applyTimeDecay(rep); + + if (outcome == AppealOutcome.Approved) { + rep.successfulAppeals += 1; + rep.reputationDelta += 1; + uint32 newScore = rep.currentReputationScore + APPEAL_SUCCESS_BONUS; + rep.currentReputationScore = newScore > MAX_REPUTATION_SCORE ? MAX_REPUTATION_SCORE : newScore; + + // Auto-compensate: mark audit record as compensated + AuditRecord storage auditRec = _getAuditRecord(tokenId, appeal.auditId); + if (auditRec.status == AuditStatus.Slashed) { + auditRec.status = AuditStatus.Compensated; + auditRec.appealApproved = true; + } + } else { + rep.failedAppeals += 1; + rep.reputationDelta -= 1; + if (rep.currentReputationScore > APPEAL_FAILURE_PENALTY) { + rep.currentReputationScore -= APPEAL_FAILURE_PENALTY; + } else { + rep.currentReputationScore = 0; + } + } + rep.lastReputationUpdateAt = uint64(block.timestamp); + + emit AppealResolved(tokenId, appealId, outcome); + emit ReputationUpdated(tokenId, rep.currentReputationScore, rep.reputationDelta); + } + + // โ”€โ”€ View functions โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + + function getTokenId(address developer, string calldata agentName) external view returns (uint256) { + return _tokenIdsByIdentity[_identityKey(developer, agentName)]; + } + + function getAgentProfile(uint256 tokenId) external view returns (AgentProfile memory) { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + return _profiles[tokenId]; + } + + function getLatestAuditReport(uint256 tokenId) external view returns (AuditRecord memory) { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + uint256 count = _auditRecords[tokenId].length; + require(count > 0, "NO_AUDIT_RECORD"); + return _auditRecords[tokenId][count - 1]; + } + + function getAuditReportByIndex( + uint256 tokenId, + uint256 index + ) external view returns (AuditRecord memory) { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + require(index < _auditRecords[tokenId].length, "INDEX_OUT_OF_BOUNDS"); + return _auditRecords[tokenId][index]; + } + + function getAuditCount(uint256 tokenId) external view returns (uint256) { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + return _auditRecords[tokenId].length; + } + + function getDimensionalScores( + uint256 tokenId, + uint256 auditIndex + ) external view returns (DimensionalScores memory) { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + require(auditIndex < _auditRecords[tokenId].length, "INDEX_OUT_OF_BOUNDS"); + return _auditRecords[tokenId][auditIndex].dimensionalScores; + } + + function getAverageScores(uint256 tokenId) external view returns (DimensionalScores memory) { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + uint256 count = _auditRecords[tokenId].length; + require(count > 0, "NO_AUDIT_RECORD"); + + uint256 sumSec; + uint256 sumTask; + uint256 sumCog; + uint256 sumEnv; + uint256 sumEng; + uint256 sumComp; + uint256 scored; + + for (uint256 i = 0; i < count; i++) { + DimensionalScores memory s = _auditRecords[tokenId][i].dimensionalScores; + if (s.security > 0 || s.taskExecution > 0 || s.cognitive > 0 || + s.environment > 0 || s.engineering > 0 || s.compliance > 0) { + sumSec += s.security; + sumTask += s.taskExecution; + sumCog += s.cognitive; + sumEnv += s.environment; + sumEng += s.engineering; + sumComp += s.compliance; + scored++; + } + } + + if (scored == 0) { + return DimensionalScores(0, 0, 0, 0, 0, 0); + } + + return DimensionalScores( + uint16(sumSec / scored), + uint16(sumTask / scored), + uint16(sumCog / scored), + uint16(sumEnv / scored), + uint16(sumEng / scored), + uint16(sumComp / scored) + ); + } + + function getAppealRecord( + uint256 tokenId, + uint64 appealId + ) external view returns (AppealRecord memory) { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + return _getAppealRecord(tokenId, appealId); + } + + function getAppealCount(uint256 tokenId) external view returns (uint256) { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + return _appealRecords[tokenId].length; + } + + function getReputation(uint256 tokenId) external view returns (ReputationRecord memory) { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + return _reputations[tokenId]; + } + + // โ”€โ”€ Internal helpers โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ + + function _applyTimeDecay(ReputationRecord storage rep) internal { + if (rep.lastReputationUpdateAt == 0 || rep.currentReputationScore == 0) { + rep.lastReputationUpdateAt = uint64(block.timestamp); + return; + } + uint64 elapsed = uint64(block.timestamp) - rep.lastReputationUpdateAt; + if (elapsed == 0) return; + // decay = score * DECAY_RATE_BPS * elapsed / (DECAY_PERIOD * 10000) + uint256 decay = uint256(rep.currentReputationScore) * DECAY_RATE_BPS * elapsed + / (uint256(DECAY_PERIOD) * 10000); + if (decay >= rep.currentReputationScore) { + rep.currentReputationScore = 0; + } else { + rep.currentReputationScore -= uint32(decay); + } + rep.lastReputationUpdateAt = uint64(block.timestamp); + } + + function _recordAuditCore( + uint256 tokenId, + uint32 auditScore, + AuditStatus status + ) internal { + require(_exists(tokenId), "TOKEN_NOT_FOUND"); + require(status != AuditStatus.Pending, "INVALID_STATUS"); + + AuditRecord storage record = _latestPendingRecord(tokenId); + record.timestamp = uint64(block.timestamp); + record.auditScore = auditScore; + record.status = status; + + AgentProfile storage profile = _profiles[tokenId]; + profile.lastAuditAt = uint64(block.timestamp); + profile.auditCount += 1; + + emit AuditRecorded(tokenId, record.auditId, status, auditScore, record.reportHash, record.reportCID); + + if (status == AuditStatus.Passed) { + _accumulateAuditReputation(tokenId, auditScore); + } + } + + function _fillAuditRecord( + uint256 tokenId, + uint32 memoryPeakMb, + uint32 cpuAvgMilli, + uint32 requestIpCount, + bytes32 manifestHash, + bytes32 reportHash, + bytes32 evidenceRoot, + bytes32 attestationHash, + string calldata evidenceCID, + string calldata reportCID, + string calldata manifestUrl, + DimensionalScores memory scores + ) internal { + AuditRecord storage record = _auditRecords[tokenId][_auditRecords[tokenId].length - 1]; + record.memoryPeakMb = memoryPeakMb; + record.cpuAvgMilli = cpuAvgMilli; + record.requestIpCount = requestIpCount; + record.manifestHash = manifestHash; + record.reportHash = reportHash; + record.evidenceRoot = evidenceRoot; + record.attestationHash = attestationHash; + record.evidenceCID = evidenceCID; + record.reportCID = reportCID; + record.manifestUrl = manifestUrl; + record.dimensionalScores = scores; + } + + function _accumulateAuditReputation(uint256 tokenId, uint32 auditScore) internal { + ReputationRecord storage rep = _reputations[tokenId]; + _applyTimeDecay(rep); + uint32 contribution = BASE_POINTS_PER_AUDIT * auditScore / 100; + uint32 newScore = rep.currentReputationScore + contribution; + rep.currentReputationScore = newScore > MAX_REPUTATION_SCORE ? MAX_REPUTATION_SCORE : newScore; + rep.lastReputationUpdateAt = uint64(block.timestamp); + emit ReputationUpdated(tokenId, rep.currentReputationScore, rep.reputationDelta); + } + + function _mintIdentity(address developer, string calldata agentName) internal returns (uint256 tokenId) { + tokenId = _nextTokenId; + _nextTokenId += 1; + + _owners[tokenId] = developer; + _balances[developer] += 1; + _tokenIdsByIdentity[_identityKey(developer, agentName)] = tokenId; + _profiles[tokenId] = AgentProfile({ + developer: developer, + agentName: agentName, + tokenId: tokenId, + totalBond: 0, + blacklisted: false, + createdAt: uint64(block.timestamp), + lastAuditAt: 0, + auditCount: 0 + }); + + emit Transfer(address(0), developer, tokenId); + emit AgentRegistered(tokenId, developer, agentName); + } + + function _identityKey(address developer, string memory agentName) internal pure returns (bytes32) { + return keccak256(abi.encodePacked(developer, ":", agentName)); + } + + function _exists(uint256 tokenId) internal view returns (bool) { + return _owners[tokenId] != address(0); + } + + function _latestPendingRecord(uint256 tokenId) internal view returns (AuditRecord storage record) { + uint256 count = _auditRecords[tokenId].length; + require(count > 0, "NO_AUDIT_RECORD"); + + record = _auditRecords[tokenId][count - 1]; + require(record.status == AuditStatus.Pending, "NO_PENDING_AUDIT"); + } + + function _getAuditRecord( + uint256 tokenId, + uint64 auditId + ) internal view returns (AuditRecord storage record) { + require(auditId > 0, "INVALID_AUDIT_ID"); + uint256 index = uint256(auditId - 1); + require(index < _auditRecords[tokenId].length, "AUDIT_NOT_FOUND"); + record = _auditRecords[tokenId][index]; + } + + function _getAppealRecord( + uint256 tokenId, + uint64 appealId + ) internal view returns (AppealRecord storage record) { + require(appealId > 0, "INVALID_APPEAL_ID"); + uint256 index = uint256(appealId - 1); + require(index < _appealRecords[tokenId].length, "APPEAL_NOT_FOUND"); + record = _appealRecords[tokenId][index]; + } +} diff --git a/contracts/src/AgentFingerprintVerifier_Groth16.sol b/contracts/src/AgentFingerprintVerifier_Groth16.sol new file mode 100644 index 0000000..9d01581 --- /dev/null +++ b/contracts/src/AgentFingerprintVerifier_Groth16.sol @@ -0,0 +1,182 @@ +// SPDX-License-Identifier: GPL-3.0 +/* + Copyright 2021 0KIMS association. + + This file is generated with [snarkJS](https://github.com/iden3/snarkjs). + + snarkJS is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + snarkJS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with snarkJS. If not, see . +*/ + +pragma solidity >=0.7.0 <0.9.0; + +contract Groth16Verifier { + // Scalar field size + uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617; + // Base field size + uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; + + // Verification Key data + uint256 constant alphax = 21857771134165934420482472477483083040759999114222938313437006683804947639829; + uint256 constant alphay = 9795420202332889131427960471339661339443661203900185563035688253429030780217; + uint256 constant betax1 = 16817903080542886482184767023751148326612352842401120535957463921066695287983; + uint256 constant betax2 = 1495251811391776744765547904723451690309879644521584173101766963628460981677; + uint256 constant betay1 = 11049284033829938514919628788045810602755266657446586633328943176602778643588; + uint256 constant betay2 = 15161184050363489443897893573709628379521047009537996338796201793494622712222; + uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634; + uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781; + uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531; + uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930; + uint256 constant deltax1 = 241231426060375391796964705476118525121639993429191139064340287104659485979; + uint256 constant deltax2 = 14301094410994758228795856445877100512560173965311181590435270621539526754692; + uint256 constant deltay1 = 14243730596210266656003117146627386866570499257517449634967734894817849336383; + uint256 constant deltay2 = 14835094200506803479770128112197900312261742464650655390607600415085666856683; + + + uint256 constant IC0x = 17271357874265445718391745972707238221574564351035732675048707265056246003925; + uint256 constant IC0y = 18959402101678014054117508300526701548209399678951410692984908914487173072122; + + uint256 constant IC1x = 2728676620568373947567110394909102499996244418452754819006517349138047538617; + uint256 constant IC1y = 15166067924669182049416266406884300868220966383346381742457464599473981773607; + + uint256 constant IC2x = 20522718107425546151160023124602104626520289410284965478585218431581511644824; + uint256 constant IC2y = 13677057991384258167796818489187327530445894990265926054530172151149658963146; + + uint256 constant IC3x = 1292867754325716874342399866655843398195073358417718801857897556668321573294; + uint256 constant IC3y = 5195841293179288711572931866347684327223059067296463629028605811514124297308; + + + // Memory data + uint16 constant pVk = 0; + uint16 constant pPairing = 128; + + uint16 constant pLastMem = 896; + + function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[3] calldata _pubSignals) public view returns (bool) { + assembly { + function checkField(v) { + if iszero(lt(v, r)) { + mstore(0, 0) + return(0, 0x20) + } + } + + // G1 function to multiply a G1 value(x,y) to value in an address + function g1_mulAccC(pR, x, y, s) { + let success + let mIn := mload(0x40) + mstore(mIn, x) + mstore(add(mIn, 32), y) + mstore(add(mIn, 64), s) + + success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64) + + if iszero(success) { + mstore(0, 0) + return(0, 0x20) + } + + mstore(add(mIn, 64), mload(pR)) + mstore(add(mIn, 96), mload(add(pR, 32))) + + success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64) + + if iszero(success) { + mstore(0, 0) + return(0, 0x20) + } + } + + function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk { + let _pPairing := add(pMem, pPairing) + let _pVk := add(pMem, pVk) + + mstore(_pVk, IC0x) + mstore(add(_pVk, 32), IC0y) + + // Compute the linear combination vk_x + + g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0))) + + g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32))) + + g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64))) + + + // -A + mstore(_pPairing, calldataload(pA)) + mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q)) + + // B + mstore(add(_pPairing, 64), calldataload(pB)) + mstore(add(_pPairing, 96), calldataload(add(pB, 32))) + mstore(add(_pPairing, 128), calldataload(add(pB, 64))) + mstore(add(_pPairing, 160), calldataload(add(pB, 96))) + + // alpha1 + mstore(add(_pPairing, 192), alphax) + mstore(add(_pPairing, 224), alphay) + + // beta2 + mstore(add(_pPairing, 256), betax1) + mstore(add(_pPairing, 288), betax2) + mstore(add(_pPairing, 320), betay1) + mstore(add(_pPairing, 352), betay2) + + // vk_x + mstore(add(_pPairing, 384), mload(add(pMem, pVk))) + mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32)))) + + + // gamma2 + mstore(add(_pPairing, 448), gammax1) + mstore(add(_pPairing, 480), gammax2) + mstore(add(_pPairing, 512), gammay1) + mstore(add(_pPairing, 544), gammay2) + + // C + mstore(add(_pPairing, 576), calldataload(pC)) + mstore(add(_pPairing, 608), calldataload(add(pC, 32))) + + // delta2 + mstore(add(_pPairing, 640), deltax1) + mstore(add(_pPairing, 672), deltax2) + mstore(add(_pPairing, 704), deltay1) + mstore(add(_pPairing, 736), deltay2) + + + let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20) + + isOk := and(success, mload(_pPairing)) + } + + let pMem := mload(0x40) + mstore(0x40, add(pMem, pLastMem)) + + // Validate that all evaluations โˆˆ F + + checkField(calldataload(add(_pubSignals, 0))) + + checkField(calldataload(add(_pubSignals, 32))) + + checkField(calldataload(add(_pubSignals, 64))) + + + // Validate all evaluations + let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem) + + mstore(0, isValid) + return(0, 0x20) + } + } + } diff --git a/contracts/src/AuditScoreVerifierVerifier_Groth16.sol b/contracts/src/AuditScoreVerifierVerifier_Groth16.sol new file mode 100644 index 0000000..ff0e91f --- /dev/null +++ b/contracts/src/AuditScoreVerifierVerifier_Groth16.sol @@ -0,0 +1,217 @@ +// SPDX-License-Identifier: GPL-3.0 +/* + Copyright 2021 0KIMS association. + + This file is generated with [snarkJS](https://github.com/iden3/snarkjs). + + snarkJS is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + snarkJS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with snarkJS. If not, see . +*/ + +pragma solidity >=0.7.0 <0.9.0; + +contract Groth16Verifier { + // Scalar field size + uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617; + // Base field size + uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; + + // Verification Key data + uint256 constant alphax = 21857771134165934420482472477483083040759999114222938313437006683804947639829; + uint256 constant alphay = 9795420202332889131427960471339661339443661203900185563035688253429030780217; + uint256 constant betax1 = 16817903080542886482184767023751148326612352842401120535957463921066695287983; + uint256 constant betax2 = 1495251811391776744765547904723451690309879644521584173101766963628460981677; + uint256 constant betay1 = 11049284033829938514919628788045810602755266657446586633328943176602778643588; + uint256 constant betay2 = 15161184050363489443897893573709628379521047009537996338796201793494622712222; + uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634; + uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781; + uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531; + uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930; + uint256 constant deltax1 = 13662439630089520632232025388995951405595581979577407352771776296209869565739; + uint256 constant deltax2 = 8865862200629299426663026930299488996354688183076084609818337267961159600769; + uint256 constant deltay1 = 11569402058154381275100075136343529886552045299433261290910667590957956164979; + uint256 constant deltay2 = 18944976643782529058538574082169131630662101154478577489938543697550593282630; + + + uint256 constant IC0x = 18861599372991063432671375245139709174825711698308540333157213454957027697501; + uint256 constant IC0y = 5068512622573751073148859326362981975762230204724767176755567292757679862869; + + uint256 constant IC1x = 20462877441643813680271077329092775015172632408065883272202874530354347147411; + uint256 constant IC1y = 11383443455047423459815863506199101674581351455559677018541049615703205444935; + + uint256 constant IC2x = 1536142176859887209230419027655896856936998139383349169260878157075818001442; + uint256 constant IC2y = 9502508091000888061070817362559881479733777048602557679946061916225397773137; + + uint256 constant IC3x = 12499070679833598253118596896675119208324628078743169794833417601180124728777; + uint256 constant IC3y = 929979487421170053964897171796610699037868893888041798633981488519572856203; + + uint256 constant IC4x = 20866392315337931725666180556226000977336276940670766006583461968812809087537; + uint256 constant IC4y = 14819566387060262503588533187382412324488182493075710488877018232863428827872; + + uint256 constant IC5x = 31744046389815692400000935998565902013749582306146897738703716487377067372; + uint256 constant IC5y = 11281983076755030481318854009782104648285903231685190723767312080383062794839; + + uint256 constant IC6x = 3133637375980313882157967064731351956138678987637720016771985391466751068393; + uint256 constant IC6y = 5996433047280391781914525792237829463443802363711703740535941025005269087404; + + uint256 constant IC7x = 3627931021018501254254966255128108093360809826549687075033425279846106852367; + uint256 constant IC7y = 21849608529742498960606067747299087346158942892347501123548259781467145287815; + + uint256 constant IC8x = 16206898193002675585289318355314860876622338461587040385679382336437292696175; + uint256 constant IC8y = 13799876902477487698957494799959543544721251350315992541506744041794605256690; + + + // Memory data + uint16 constant pVk = 0; + uint16 constant pPairing = 128; + + uint16 constant pLastMem = 896; + + function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[8] calldata _pubSignals) public view returns (bool) { + assembly { + function checkField(v) { + if iszero(lt(v, r)) { + mstore(0, 0) + return(0, 0x20) + } + } + + // G1 function to multiply a G1 value(x,y) to value in an address + function g1_mulAccC(pR, x, y, s) { + let success + let mIn := mload(0x40) + mstore(mIn, x) + mstore(add(mIn, 32), y) + mstore(add(mIn, 64), s) + + success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64) + + if iszero(success) { + mstore(0, 0) + return(0, 0x20) + } + + mstore(add(mIn, 64), mload(pR)) + mstore(add(mIn, 96), mload(add(pR, 32))) + + success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64) + + if iszero(success) { + mstore(0, 0) + return(0, 0x20) + } + } + + function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk { + let _pPairing := add(pMem, pPairing) + let _pVk := add(pMem, pVk) + + mstore(_pVk, IC0x) + mstore(add(_pVk, 32), IC0y) + + // Compute the linear combination vk_x + + g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0))) + + g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32))) + + g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64))) + + g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96))) + + g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128))) + + g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160))) + + g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192))) + + g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224))) + + + // -A + mstore(_pPairing, calldataload(pA)) + mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q)) + + // B + mstore(add(_pPairing, 64), calldataload(pB)) + mstore(add(_pPairing, 96), calldataload(add(pB, 32))) + mstore(add(_pPairing, 128), calldataload(add(pB, 64))) + mstore(add(_pPairing, 160), calldataload(add(pB, 96))) + + // alpha1 + mstore(add(_pPairing, 192), alphax) + mstore(add(_pPairing, 224), alphay) + + // beta2 + mstore(add(_pPairing, 256), betax1) + mstore(add(_pPairing, 288), betax2) + mstore(add(_pPairing, 320), betay1) + mstore(add(_pPairing, 352), betay2) + + // vk_x + mstore(add(_pPairing, 384), mload(add(pMem, pVk))) + mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32)))) + + + // gamma2 + mstore(add(_pPairing, 448), gammax1) + mstore(add(_pPairing, 480), gammax2) + mstore(add(_pPairing, 512), gammay1) + mstore(add(_pPairing, 544), gammay2) + + // C + mstore(add(_pPairing, 576), calldataload(pC)) + mstore(add(_pPairing, 608), calldataload(add(pC, 32))) + + // delta2 + mstore(add(_pPairing, 640), deltax1) + mstore(add(_pPairing, 672), deltax2) + mstore(add(_pPairing, 704), deltay1) + mstore(add(_pPairing, 736), deltay2) + + + let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20) + + isOk := and(success, mload(_pPairing)) + } + + let pMem := mload(0x40) + mstore(0x40, add(pMem, pLastMem)) + + // Validate that all evaluations โˆˆ F + + checkField(calldataload(add(_pubSignals, 0))) + + checkField(calldataload(add(_pubSignals, 32))) + + checkField(calldataload(add(_pubSignals, 64))) + + checkField(calldataload(add(_pubSignals, 96))) + + checkField(calldataload(add(_pubSignals, 128))) + + checkField(calldataload(add(_pubSignals, 160))) + + checkField(calldataload(add(_pubSignals, 192))) + + checkField(calldataload(add(_pubSignals, 224))) + + + // Validate all evaluations + let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem) + + mstore(0, isValid) + return(0, 0x20) + } + } + } diff --git a/contracts/src/ZkAuditVerifier.sol b/contracts/src/ZkAuditVerifier.sol new file mode 100644 index 0000000..d70df4e --- /dev/null +++ b/contracts/src/ZkAuditVerifier.sol @@ -0,0 +1,279 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +/** + * @title ZkAuditVerifier + * @notice Stores and verifies ZK proofs for audit score correctness and agent fingerprints. + * + * Two proof types: + * 1. Audit Score Proof โ€” proves dimensional scores were correctly computed from raw data + * 2. Agent Fingerprint Proof โ€” proves agent identity is bound to NFT without revealing code + * + * The Groth16 verifier contracts are auto-generated by snarkjs from the circom circuits. + * This contract acts as a registry that stores proof verification results on-chain. + */ +contract ZkAuditVerifier { + // --- Types --- + + struct AuditScoreProof { + uint256 tokenId; + uint256 auditId; + uint256[6] dimensionalScores; + uint256 overallScore; + uint256 inputCommitment; + bool verified; + uint256 verifiedAt; + bytes32 proofHash; // keccak256 of the raw proof for dedup + } + + struct AgentFingerprintProof { + uint256 tokenId; + uint256 fingerprintHash; + uint256 developerHash; + bool verified; + uint256 verifiedAt; + bytes32 proofHash; + } + + // --- Events --- + + event AuditScoreProofVerified( + uint256 indexed tokenId, + uint256 indexed auditId, + uint256 overallScore, + uint256 inputCommitment, + bytes32 proofHash + ); + + event AgentFingerprintProofVerified( + uint256 indexed tokenId, + uint256 fingerprintHash, + uint256 developerHash, + bytes32 proofHash + ); + + event AuditScoreVerifierUpdated(address indexed oldVerifier, address indexed newVerifier); + event FingerprintVerifierUpdated(address indexed oldVerifier, address indexed newVerifier); + + // --- State --- + + address public owner; + + // Groth16 verifier contract addresses (set after deployment) + address public auditScoreVerifierContract; + address public fingerprintVerifierContract; + + // tokenId => auditId => proof record + mapping(uint256 => mapping(uint256 => AuditScoreProof)) public auditScoreProofs; + + // tokenId => latest fingerprint proof + mapping(uint256 => AgentFingerprintProof) public fingerprintProofs; + + // tokenId => number of verified audit proofs + mapping(uint256 => uint256) public auditProofCount; + + // --- Modifiers --- + + modifier onlyOwner() { + require(msg.sender == owner, "NOT_OWNER"); + _; + } + + // --- Constructor --- + + constructor() { + owner = msg.sender; + } + + // --- Admin --- + + function setAuditScoreVerifier(address _verifier) external onlyOwner { + address old = auditScoreVerifierContract; + auditScoreVerifierContract = _verifier; + emit AuditScoreVerifierUpdated(old, _verifier); + } + + function setFingerprintVerifier(address _verifier) external onlyOwner { + address old = fingerprintVerifierContract; + fingerprintVerifierContract = _verifier; + emit FingerprintVerifierUpdated(old, _verifier); + } + + // --- Verify & Store: Audit Score Proof --- + + /** + * @notice Verify a ZK proof that audit scores were correctly computed. + * @param tokenId The agent's NFT token ID + * @param auditId The audit ID being proven + * @param dimensionalScores The 6 claimed dimensional scores [0-100] + * @param overallScore The claimed weighted overall score [0-100] + * @param inputCommitment Poseidon hash binding the proof to private inputs + * @param proof The Groth16 proof (a, b, c points) + */ + function verifyAuditScore( + uint256 tokenId, + uint256 auditId, + uint256[6] calldata dimensionalScores, + uint256 overallScore, + uint256 inputCommitment, + uint256[2] calldata a, + uint256[2][2] calldata b, + uint256[2] calldata c + ) external returns (bool) { + require(auditScoreVerifierContract != address(0), "VERIFIER_NOT_SET"); + + // Build public inputs array matching circuit: [dim0..5, overall, commitment] + uint256[8] memory pubInputs; + for (uint256 i = 0; i < 6; i++) { + pubInputs[i] = dimensionalScores[i]; + } + pubInputs[6] = overallScore; + pubInputs[7] = inputCommitment; + + // Call the Groth16 verifier + bool valid = _callGroth16Verifier( + auditScoreVerifierContract, + a, b, c, + pubInputs, + 8 + ); + + require(valid, "INVALID_PROOF"); + + // Store the verified proof + bytes32 proofHash = keccak256(abi.encodePacked(a[0], a[1], b[0][0], b[0][1], c[0], c[1])); + + auditScoreProofs[tokenId][auditId] = AuditScoreProof({ + tokenId: tokenId, + auditId: auditId, + dimensionalScores: dimensionalScores, + overallScore: overallScore, + inputCommitment: inputCommitment, + verified: true, + verifiedAt: block.timestamp, + proofHash: proofHash + }); + + auditProofCount[tokenId] += 1; + + emit AuditScoreProofVerified(tokenId, auditId, overallScore, inputCommitment, proofHash); + + return true; + } + + // --- Verify & Store: Agent Fingerprint Proof --- + + /** + * @notice Verify a ZK proof binding an agent identity to its NFT. + * @param tokenId The agent's NFT token ID + * @param fingerprintHash The public fingerprint hash + * @param developerHash The developer ownership hash + * @param proof The Groth16 proof (a, b, c points) + */ + function verifyFingerprint( + uint256 tokenId, + uint256 fingerprintHash, + uint256 developerHash, + uint256[2] calldata a, + uint256[2][2] calldata b, + uint256[2] calldata c + ) external returns (bool) { + require(fingerprintVerifierContract != address(0), "VERIFIER_NOT_SET"); + + // Public inputs: [fingerprintHash, tokenId, developerHash] + uint256[3] memory pubInputs; + pubInputs[0] = fingerprintHash; + pubInputs[1] = tokenId; + pubInputs[2] = developerHash; + + bool valid = _callGroth16Verifier( + fingerprintVerifierContract, + a, b, c, + pubInputs, + 3 + ); + + require(valid, "INVALID_PROOF"); + + bytes32 proofHash = keccak256(abi.encodePacked(a[0], a[1], b[0][0], b[0][1], c[0], c[1])); + + fingerprintProofs[tokenId] = AgentFingerprintProof({ + tokenId: tokenId, + fingerprintHash: fingerprintHash, + developerHash: developerHash, + verified: true, + verifiedAt: block.timestamp, + proofHash: proofHash + }); + + emit AgentFingerprintProofVerified(tokenId, fingerprintHash, developerHash, proofHash); + + return true; + } + + // --- Query --- + + function getAuditScoreProof(uint256 tokenId, uint256 auditId) + external view returns (AuditScoreProof memory) + { + return auditScoreProofs[tokenId][auditId]; + } + + function getFingerprintProof(uint256 tokenId) + external view returns (AgentFingerprintProof memory) + { + return fingerprintProofs[tokenId]; + } + + function isAuditScoreVerified(uint256 tokenId, uint256 auditId) + external view returns (bool) + { + return auditScoreProofs[tokenId][auditId].verified; + } + + function isFingerprintVerified(uint256 tokenId) + external view returns (bool) + { + return fingerprintProofs[tokenId].verified; + } + + // --- Internal: Generic Groth16 Verifier Call --- + + function _callGroth16Verifier( + address verifier, + uint256[2] calldata a, + uint256[2][2] calldata b, + uint256[2] calldata c, + uint256[8] memory pubInputs, + uint256 numInputs + ) internal view returns (bool) { + // snarkjs-generated verifiers expose: + // verifyProof(uint[2] a, uint[2][2] b, uint[2] c, uint[N] input) โ†’ bool + // We encode the call dynamically based on numInputs + bytes memory payload; + + if (numInputs == 8) { + payload = abi.encodeWithSignature( + "verifyProof(uint256[2],uint256[2][2],uint256[2],uint256[8])", + a, b, c, pubInputs + ); + } else if (numInputs == 3) { + uint256[3] memory inputs3; + for (uint256 i = 0; i < 3; i++) { + inputs3[i] = pubInputs[i]; + } + payload = abi.encodeWithSignature( + "verifyProof(uint256[2],uint256[2][2],uint256[2],uint256[3])", + a, b, c, inputs3 + ); + } else { + revert("UNSUPPORTED_INPUT_COUNT"); + } + + (bool success, bytes memory result) = verifier.staticcall(payload); + if (!success || result.length < 32) { + return false; + } + return abi.decode(result, (bool)); + } +} diff --git a/contracts/tests/AgentAuditRegistryV3.test.js b/contracts/tests/AgentAuditRegistryV3.test.js new file mode 100644 index 0000000..2047e06 --- /dev/null +++ b/contracts/tests/AgentAuditRegistryV3.test.js @@ -0,0 +1,239 @@ +const assert = require("assert"); +const fs = require("fs"); +const path = require("path"); + +const { ethers } = require("hardhat"); + +function loadV3Artifact() { + const artifactPath = path.join(__dirname, "..", "artifacts", "AgentAuditRegistryV3.json"); + return JSON.parse(fs.readFileSync(artifactPath, "utf8")); +} + +async function deployV3Registry() { + const [owner, operator, developer] = await ethers.getSigners(); + const artifact = loadV3Artifact(); + const factory = new ethers.ContractFactory(artifact.abi, artifact.bytecode, owner); + const contract = await factory.deploy( + ethers.utils.parseEther("0.01"), + ethers.utils.parseEther("1"), + operator.address + ); + await contract.deployed(); + return { contract, owner, operator, developer }; +} + +const STAKE_VALUE = ethers.utils.parseEther("1.01"); +const ZERO_HASH = ethers.utils.hexZeroPad("0x0", 32); + +async function stakeAndPassAudit(contract, operator, developer, score) { + await (await contract.connect(developer).stake("test-agent", "https://m.example.com", { + value: STAKE_VALUE + })).wait(); + + const auditCount = await contract.getAuditCount(1); + const auditId = auditCount.toNumber(); + + await (await contract.connect(operator).recordAuditResultV2( + 1, score, 256, 150, 3, 1, // status 1 = Passed + ethers.utils.hexZeroPad("0xabc", 32), + ethers.utils.hexZeroPad("0xdef", 32), + ZERO_HASH, ZERO_HASH, + "", "QmReport", "https://m.example.com", + [8500, 9000, 7500, 8000, 7000, 9500] + )).wait(); + + return auditId; +} + +describe("AgentAuditRegistryV3 โ€” MDDRM Reputation", function () { + it("audit pass increases currentReputationScore by BASE_POINTS * auditScore / 100", async function () { + const { contract, operator, developer } = await deployV3Registry(); + + await stakeAndPassAudit(contract, operator, developer, 80); + + const rep = await contract.getReputation(1); + // BASE_POINTS_PER_AUDIT = 50, score = 80 โ†’ contribution = 50 * 80 / 100 = 40 + assert.strictEqual(rep.currentReputationScore, 40); + assert.ok(rep.lastReputationUpdateAt > 0); + }); + + it("multiple audit passes accumulate score, capped at 10000", async function () { + const { contract, operator, developer } = await deployV3Registry(); + + // Each pass with score 100 โ†’ contribution = 50 * 100 / 100 = 50 + // We need 200 passes to reach 10000, but let's do a few and verify accumulation + await stakeAndPassAudit(contract, operator, developer, 100); + let rep = await contract.getReputation(1); + assert.strictEqual(rep.currentReputationScore, 50); + + // Second audit + await stakeAndPassAudit(contract, operator, developer, 100); + rep = await contract.getReputation(1); + assert.strictEqual(rep.currentReputationScore, 100); + + // Third audit with score 60 โ†’ contribution = 50 * 60 / 100 = 30 + await stakeAndPassAudit(contract, operator, developer, 60); + rep = await contract.getReputation(1); + assert.strictEqual(rep.currentReputationScore, 130); + }); + + it("appeal success adds APPEAL_SUCCESS_BONUS (100) and reputationDelta +1", async function () { + const { contract, operator, developer } = await deployV3Registry(); + + // First build some reputation via audit + await stakeAndPassAudit(contract, operator, developer, 80); + + // Now create a failed audit to slash + await (await contract.connect(developer).stake("test-agent", "https://m2.example.com", { + value: STAKE_VALUE + })).wait(); + await (await contract.connect(operator).recordAuditResult( + 1, 0, 256, 150, 3, 2, // status 2 = Failed + ethers.utils.hexZeroPad("0xabc", 32), + ethers.utils.hexZeroPad("0xdef", 32), + ZERO_HASH, ZERO_HASH, + "", "QmReport", "https://m2.example.com" + )).wait(); + + await (await contract.connect(operator).slashBond( + 1, 2, ethers.utils.parseEther("0.5"), + ethers.utils.hexZeroPad("0x01", 32) + )).wait(); + + // File and approve appeal + await (await contract.connect(operator).fileAppeal( + 1, 2, + ethers.utils.hexZeroPad("0xed1d", 32), + "QmAppealData" + )).wait(); + + await (await contract.connect(operator).resolveAppeal(1, 1, 1)).wait(); // Approved + + const rep = await contract.getReputation(1); + assert.strictEqual(rep.successfulAppeals, 1); + assert.strictEqual(rep.reputationDelta, 1); + // Slash zeroed score (blacklisted), appeal adds 100 โ†’ 100 + assert.strictEqual(rep.currentReputationScore, 100); + }); + + it("appeal failure subtracts APPEAL_FAILURE_PENALTY (200), floor at 0", async function () { + const { contract, operator, developer } = await deployV3Registry(); + + // Build score = 40 via audit + await stakeAndPassAudit(contract, operator, developer, 80); + + // Fail + slash + await (await contract.connect(developer).stake("test-agent", "https://m2.example.com", { + value: STAKE_VALUE + })).wait(); + await (await contract.connect(operator).recordAuditResult( + 1, 0, 256, 150, 3, 2, + ethers.utils.hexZeroPad("0xabc", 32), + ethers.utils.hexZeroPad("0xdef", 32), + ZERO_HASH, ZERO_HASH, + "", "QmReport", "https://m2.example.com" + )).wait(); + + await (await contract.connect(operator).slashBond( + 1, 2, ethers.utils.parseEther("0.5"), + ethers.utils.hexZeroPad("0x01", 32) + )).wait(); + + // File and reject appeal + await (await contract.connect(operator).fileAppeal(1, 2, ZERO_HASH, "")).wait(); + await (await contract.connect(operator).resolveAppeal(1, 1, 2)).wait(); // Rejected + + const rep = await contract.getReputation(1); + assert.strictEqual(rep.failedAppeals, 1); + assert.strictEqual(rep.reputationDelta, -1); + // Score was 0 (blacklist zeroed it), penalty 200 โ†’ still 0 (floor) + assert.strictEqual(rep.currentReputationScore, 0); + }); + + it("slash halves score; blacklisted zeroes score", async function () { + const { contract, operator, developer } = await deployV3Registry(); + + // Build score = 50 via audit (score 100) + await stakeAndPassAudit(contract, operator, developer, 100); + + let rep = await contract.getReputation(1); + assert.strictEqual(rep.currentReputationScore, 50); + + // Slash (sets blacklisted = true โ†’ score goes to 0) + await (await contract.connect(developer).stake("test-agent", "https://m2.example.com", { + value: STAKE_VALUE + })).wait(); + await (await contract.connect(operator).recordAuditResult( + 1, 0, 256, 150, 3, 2, + ethers.utils.hexZeroPad("0xabc", 32), + ethers.utils.hexZeroPad("0xdef", 32), + ZERO_HASH, ZERO_HASH, + "", "QmReport", "https://m2.example.com" + )).wait(); + + await (await contract.connect(operator).slashBond( + 1, 2, ethers.utils.parseEther("0.5"), + ethers.utils.hexZeroPad("0x01", 32) + )).wait(); + + rep = await contract.getReputation(1); + // blacklisted = true โ†’ score zeroed + assert.strictEqual(rep.currentReputationScore, 0); + }); + + it("time decay reduces score proportionally after DECAY_PERIOD", async function () { + const { contract, operator, developer } = await deployV3Registry(); + + // Build a decent score: 10 audits with score 100 โ†’ 10 * 50 = 500 + for (let i = 0; i < 10; i++) { + await stakeAndPassAudit(contract, operator, developer, 100); + } + + let rep = await contract.getReputation(1); + assert.strictEqual(rep.currentReputationScore, 500); + + // Advance time by 30 days (DECAY_PERIOD) + await ethers.provider.send("evm_increaseTime", [30 * 24 * 60 * 60]); + await ethers.provider.send("evm_mine", []); + + // Trigger decay by doing another audit + await stakeAndPassAudit(contract, operator, developer, 100); + + rep = await contract.getReputation(1); + // After 30 days: decay = 500 * 100 * (30 days) / (30 days * 10000) = 500 * 1% = 5 + // new score = 500 - 5 + 50 = 545 + assert.strictEqual(rep.currentReputationScore, 545); + }); + + it("zero score agent with decay remains at 0, no underflow", async function () { + const { contract, operator, developer } = await deployV3Registry(); + + // Register agent without passing any audit โ†’ score = 0 + await (await contract.connect(developer).stake("test-agent", "https://m.example.com", { + value: STAKE_VALUE + })).wait(); + + // Record a failed audit (no reputation gain) + await (await contract.connect(operator).recordAuditResult( + 1, 0, 256, 150, 3, 2, + ethers.utils.hexZeroPad("0xabc", 32), + ethers.utils.hexZeroPad("0xdef", 32), + ZERO_HASH, ZERO_HASH, + "", "QmReport", "https://m.example.com" + )).wait(); + + let rep = await contract.getReputation(1); + assert.strictEqual(rep.currentReputationScore, 0); + + // Advance time + await ethers.provider.send("evm_increaseTime", [60 * 24 * 60 * 60]); + await ethers.provider.send("evm_mine", []); + + // Do another stake + pass to trigger decay on zero + await stakeAndPassAudit(contract, operator, developer, 50); + + rep = await contract.getReputation(1); + // Decay on 0 = 0, then add 50 * 50 / 100 = 25 + assert.strictEqual(rep.currentReputationScore, 25); + }); +}); diff --git a/contracts/zk/build/AgentFingerprint/verification_key.json b/contracts/zk/build/AgentFingerprint/verification_key.json new file mode 100644 index 0000000..25ad926 --- /dev/null +++ b/contracts/zk/build/AgentFingerprint/verification_key.json @@ -0,0 +1,104 @@ +{ + "protocol": "groth16", + "curve": "bn128", + "nPublic": 3, + "vk_alpha_1": [ + "21857771134165934420482472477483083040759999114222938313437006683804947639829", + "9795420202332889131427960471339661339443661203900185563035688253429030780217", + "1" + ], + "vk_beta_2": [ + [ + "1495251811391776744765547904723451690309879644521584173101766963628460981677", + "16817903080542886482184767023751148326612352842401120535957463921066695287983" + ], + [ + "15161184050363489443897893573709628379521047009537996338796201793494622712222", + "11049284033829938514919628788045810602755266657446586633328943176602778643588" + ], + [ + "1", + "0" + ] + ], + "vk_gamma_2": [ + [ + "10857046999023057135944570762232829481370756359578518086990519993285655852781", + "11559732032986387107991004021392285783925812861821192530917403151452391805634" + ], + [ + "8495653923123431417604973247489272438418190587263600148770280649306958101930", + "4082367875863433681332203403145435568316851327593401208105741076214120093531" + ], + [ + "1", + "0" + ] + ], + "vk_delta_2": [ + [ + "14301094410994758228795856445877100512560173965311181590435270621539526754692", + "241231426060375391796964705476118525121639993429191139064340287104659485979" + ], + [ + "14835094200506803479770128112197900312261742464650655390607600415085666856683", + "14243730596210266656003117146627386866570499257517449634967734894817849336383" + ], + [ + "1", + "0" + ] + ], + "vk_alphabeta_12": [ + [ + [ + "16670720643455981021181981658609649513641492334807695194567271699872997218432", + "21158075433894772449421774468397596243203664823092069909671873931033930501113" + ], + [ + "19737905616599556752388909425598807424338186402730008549257018438674806516490", + "10755039854618056451472392833254361366919605006293881350028840300431997271476" + ], + [ + "10740098443054256139082743546230187316116377053750633584834060598453920993206", + "3672826024846240889250360125144875486847453618255804195158404354082660460621" + ] + ], + [ + [ + "13469741967810782388359585911175601086273105732349767230620681855341608334556", + "3219862629861071428663541367551684961437703861306118666332216170850332674948" + ], + [ + "3470170269960507121358269311321484640546994461638595708429387897105630926851", + "5924596410779123783156228364311133281786631760307550328065444610052088736328" + ], + [ + "19810455791423118411860787184426060741031389748774401793616118096484276300999", + "15207191489093303478151047241866951257808482527193225683783994339742545872120" + ] + ] + ], + "IC": [ + [ + "17271357874265445718391745972707238221574564351035732675048707265056246003925", + "18959402101678014054117508300526701548209399678951410692984908914487173072122", + "1" + ], + [ + "2728676620568373947567110394909102499996244418452754819006517349138047538617", + "15166067924669182049416266406884300868220966383346381742457464599473981773607", + "1" + ], + [ + "20522718107425546151160023124602104626520289410284965478585218431581511644824", + "13677057991384258167796818489187327530445894990265926054530172151149658963146", + "1" + ], + [ + "1292867754325716874342399866655843398195073358417718801857897556668321573294", + "5195841293179288711572931866347684327223059067296463629028605811514124297308", + "1" + ] + ] +} \ No newline at end of file diff --git a/contracts/zk/build/AuditScoreVerifier/verification_key.json b/contracts/zk/build/AuditScoreVerifier/verification_key.json new file mode 100644 index 0000000..b3593e5 --- /dev/null +++ b/contracts/zk/build/AuditScoreVerifier/verification_key.json @@ -0,0 +1,129 @@ +{ + "protocol": "groth16", + "curve": "bn128", + "nPublic": 8, + "vk_alpha_1": [ + "21857771134165934420482472477483083040759999114222938313437006683804947639829", + "9795420202332889131427960471339661339443661203900185563035688253429030780217", + "1" + ], + "vk_beta_2": [ + [ + "1495251811391776744765547904723451690309879644521584173101766963628460981677", + "16817903080542886482184767023751148326612352842401120535957463921066695287983" + ], + [ + "15161184050363489443897893573709628379521047009537996338796201793494622712222", + "11049284033829938514919628788045810602755266657446586633328943176602778643588" + ], + [ + "1", + "0" + ] + ], + "vk_gamma_2": [ + [ + "10857046999023057135944570762232829481370756359578518086990519993285655852781", + "11559732032986387107991004021392285783925812861821192530917403151452391805634" + ], + [ + "8495653923123431417604973247489272438418190587263600148770280649306958101930", + "4082367875863433681332203403145435568316851327593401208105741076214120093531" + ], + [ + "1", + "0" + ] + ], + "vk_delta_2": [ + [ + "8865862200629299426663026930299488996354688183076084609818337267961159600769", + "13662439630089520632232025388995951405595581979577407352771776296209869565739" + ], + [ + "18944976643782529058538574082169131630662101154478577489938543697550593282630", + "11569402058154381275100075136343529886552045299433261290910667590957956164979" + ], + [ + "1", + "0" + ] + ], + "vk_alphabeta_12": [ + [ + [ + "16670720643455981021181981658609649513641492334807695194567271699872997218432", + "21158075433894772449421774468397596243203664823092069909671873931033930501113" + ], + [ + "19737905616599556752388909425598807424338186402730008549257018438674806516490", + "10755039854618056451472392833254361366919605006293881350028840300431997271476" + ], + [ + "10740098443054256139082743546230187316116377053750633584834060598453920993206", + "3672826024846240889250360125144875486847453618255804195158404354082660460621" + ] + ], + [ + [ + "13469741967810782388359585911175601086273105732349767230620681855341608334556", + "3219862629861071428663541367551684961437703861306118666332216170850332674948" + ], + [ + "3470170269960507121358269311321484640546994461638595708429387897105630926851", + "5924596410779123783156228364311133281786631760307550328065444610052088736328" + ], + [ + "19810455791423118411860787184426060741031389748774401793616118096484276300999", + "15207191489093303478151047241866951257808482527193225683783994339742545872120" + ] + ] + ], + "IC": [ + [ + "18861599372991063432671375245139709174825711698308540333157213454957027697501", + "5068512622573751073148859326362981975762230204724767176755567292757679862869", + "1" + ], + [ + "20462877441643813680271077329092775015172632408065883272202874530354347147411", + "11383443455047423459815863506199101674581351455559677018541049615703205444935", + "1" + ], + [ + "1536142176859887209230419027655896856936998139383349169260878157075818001442", + "9502508091000888061070817362559881479733777048602557679946061916225397773137", + "1" + ], + [ + "12499070679833598253118596896675119208324628078743169794833417601180124728777", + "929979487421170053964897171796610699037868893888041798633981488519572856203", + "1" + ], + [ + "20866392315337931725666180556226000977336276940670766006583461968812809087537", + "14819566387060262503588533187382412324488182493075710488877018232863428827872", + "1" + ], + [ + "31744046389815692400000935998565902013749582306146897738703716487377067372", + "11281983076755030481318854009782104648285903231685190723767312080383062794839", + "1" + ], + [ + "3133637375980313882157967064731351956138678987637720016771985391466751068393", + "5996433047280391781914525792237829463443802363711703740535941025005269087404", + "1" + ], + [ + "3627931021018501254254966255128108093360809826549687075033425279846106852367", + "21849608529742498960606067747299087346158942892347501123548259781467145287815", + "1" + ], + [ + "16206898193002675585289318355314860876622338461587040385679382336437292696175", + "13799876902477487698957494799959543544721251350315992541506744041794605256690", + "1" + ] + ] +} \ No newline at end of file diff --git a/contracts/zk/circuits/AgentFingerprint.circom b/contracts/zk/circuits/AgentFingerprint.circom new file mode 100644 index 0000000..1189ae0 --- /dev/null +++ b/contracts/zk/circuits/AgentFingerprint.circom @@ -0,0 +1,117 @@ +pragma circom 2.1.6; + +include "circomlib/circuits/poseidon.circom"; +include "circomlib/circuits/comparators.circom"; + +/* + * AgentFingerprint โ€” ZK proof binding an agent's identity to its NFT + * without revealing the actual code or manifest content. + * + * The developer can prove "I own the agent behind this NFT" and + * "this agent has specific behavioral properties" without exposing + * the agent's source code or internal configuration. + * + * Public inputs: + * - fingerprintHash: the on-chain fingerprint (Poseidon hash) + * - tokenId: the NFT token ID this fingerprint is bound to + * - developerHash: hash of developer address (binding) + * + * Private inputs: + * - manifestContentHash: SHA-256 of the agent's manifest.json (as field elements) + * - codeHash: SHA-256 of the agent's Docker image layer digest + * - behavioralTraits[4]: declared behavioral properties + * [0] = hasNetworkAccess (0 or 1) + * [1] = requiresAuth (0 or 1) + * [2] = maxMemoryTier (0=low, 1=medium, 2=high) + * [3] = apiComplexity (0=simple, 1=moderate, 2=complex) + * - developerSecret: private key derivative (proves ownership) + * + * The circuit verifies: + * 1. fingerprintHash = Poseidon(manifestContentHash, codeHash, behavioralTraits..., tokenId) + * 2. developerHash = Poseidon(developerSecret, tokenId) + * 3. behavioralTraits are within valid ranges + * 4. All inputs are properly bound to the specific tokenId + */ + +/* + * BinaryCheck: Verify a signal is 0 or 1 + */ +template BinaryCheck() { + signal input value; + value * (1 - value) === 0; +} + +/* + * TernaryCheck: Verify a signal is 0, 1, or 2 + */ +template TernaryCheck() { + signal input value; + // value * (value - 1) * (value - 2) === 0 + signal t1; + t1 <== value * (value - 1); + signal t2; + t2 <== t1 * (value - 2); + t2 === 0; +} + +/* + * Main circuit: AgentFingerprint + */ +template AgentFingerprint() { + // Public inputs + signal input fingerprintHash; + signal input tokenId; + signal input developerHash; + + // Private inputs + signal input manifestContentHash[2]; // SHA-256 split into 2 field elements (128-bit each) + signal input codeHash[2]; // SHA-256 split into 2 field elements + signal input behavioralTraits[4]; + signal input developerSecret; + + // --- Step 1: Verify behavioral traits are in valid ranges --- + + // traits[0]: hasNetworkAccess โ€” binary + component binCheck0 = BinaryCheck(); + binCheck0.value <== behavioralTraits[0]; + + // traits[1]: requiresAuth โ€” binary + component binCheck1 = BinaryCheck(); + binCheck1.value <== behavioralTraits[1]; + + // traits[2]: maxMemoryTier โ€” ternary (0, 1, 2) + component terCheck0 = TernaryCheck(); + terCheck0.value <== behavioralTraits[2]; + + // traits[3]: apiComplexity โ€” ternary (0, 1, 2) + component terCheck1 = TernaryCheck(); + terCheck1.value <== behavioralTraits[3]; + + // --- Step 2: Compute fingerprint hash --- + // fingerprintHash = Poseidon(manifestHash[0..1], codeHash[0..1], traits[0..3], tokenId) + // Total: 9 inputs + component fpHash = Poseidon(9); + fpHash.inputs[0] <== manifestContentHash[0]; + fpHash.inputs[1] <== manifestContentHash[1]; + fpHash.inputs[2] <== codeHash[0]; + fpHash.inputs[3] <== codeHash[1]; + fpHash.inputs[4] <== behavioralTraits[0]; + fpHash.inputs[5] <== behavioralTraits[1]; + fpHash.inputs[6] <== behavioralTraits[2]; + fpHash.inputs[7] <== behavioralTraits[3]; + fpHash.inputs[8] <== tokenId; + + // Constrain: computed hash == public fingerprintHash + fpHash.out === fingerprintHash; + + // --- Step 3: Verify developer ownership --- + // developerHash = Poseidon(developerSecret, tokenId) + component devHash = Poseidon(2); + devHash.inputs[0] <== developerSecret; + devHash.inputs[1] <== tokenId; + + // Constrain: computed developer hash == public developerHash + devHash.out === developerHash; +} + +component main {public [fingerprintHash, tokenId, developerHash]} = AgentFingerprint(); diff --git a/contracts/zk/circuits/AuditScoreVerifier.circom b/contracts/zk/circuits/AuditScoreVerifier.circom new file mode 100644 index 0000000..c08e81f --- /dev/null +++ b/contracts/zk/circuits/AuditScoreVerifier.circom @@ -0,0 +1,242 @@ +pragma circom 2.1.6; + +include "circomlib/circuits/comparators.circom"; +include "circomlib/circuits/poseidon.circom"; + +/* + * AuditScoreVerifier โ€” ZK proof that dimensional scores were correctly + * computed from raw evaluation data (Groth16 / BN128). + * + * Public: dimensionalScores[6], overallScore, inputCommitment + * Private: categoryScores[6][10], categoryCounts[6], cpuAvgMilli, + * memoryPeakMb, complianceScore, securityBoundaryScore + */ + +template SafeAverage(n) { + signal input values[n]; + signal input count; + signal output avg; + + signal sums[n + 1]; + sums[0] <== 0; + for (var i = 0; i < n; i++) { + sums[i + 1] <== sums[i] + values[i]; + } + + component isZero = IsZero(); + isZero.in <== count; + + signal quotient; + signal remainder; + quotient <-- isZero.out == 1 ? 0 : sums[n] \ count; + remainder <-- isZero.out == 1 ? 0 : sums[n] % count; + + signal qTimesCount; + qTimesCount <== quotient * count; + signal expected; + expected <== qTimesCount + remainder; + + signal diff; + diff <== sums[n] - expected; + signal constrainedDiff; + constrainedDiff <== diff * (1 - isZero.out); + constrainedDiff === 0; + + component ltCheck = LessThan(16); + ltCheck.in[0] <== remainder; + ltCheck.in[1] <== count + isZero.out; + ltCheck.out === 1; + + avg <== quotient; +} + +template ResourceScore() { + signal input cpuAvgMilli; + signal input memoryPeakMb; + signal output score; + + component cpuLow = LessEqThan(32); + cpuLow.in[0] <== cpuAvgMilli; + cpuLow.in[1] <== 500; + + component cpuMid = LessEqThan(32); + cpuMid.in[0] <== cpuAvgMilli; + cpuMid.in[1] <== 2000; + + signal notLow; + notLow <== 1 - cpuLow.out; + signal notMid; + notMid <== 1 - cpuMid.out; + + signal lowTerm; + lowTerm <== cpuLow.out * 100; + + signal notLowTimesMid; + notLowTimesMid <== notLow * cpuMid.out; + signal midTerm; + midTerm <== notLowTimesMid * 80; + + signal notLowTimesNotMid; + notLowTimesNotMid <== notLow * notMid; + signal highTerm; + highTerm <== notLowTimesNotMid * 30; + + signal cpuScore; + cpuScore <== lowTerm + midTerm + highTerm; + + component memLow = LessEqThan(32); + memLow.in[0] <== memoryPeakMb; + memLow.in[1] <== 256; + + component memMid = LessEqThan(32); + memMid.in[0] <== memoryPeakMb; + memMid.in[1] <== 1024; + + signal memNotLow; + memNotLow <== 1 - memLow.out; + signal memNotMid; + memNotMid <== 1 - memMid.out; + + signal memLowTerm; + memLowTerm <== memLow.out * 100; + + signal memNotLowTimesMid; + memNotLowTimesMid <== memNotLow * memMid.out; + signal memMidTerm; + memMidTerm <== memNotLowTimesMid * 80; + + signal memNotLowTimesNotMid; + memNotLowTimesNotMid <== memNotLow * memNotMid; + signal memHighTerm; + memHighTerm <== memNotLowTimesNotMid * 30; + + signal memScore; + memScore <== memLowTerm + memMidTerm + memHighTerm; + + score <-- (cpuScore + memScore) \ 2; + + signal doubleScore; + doubleScore <== score * 2; + signal sumScores; + sumScores <== cpuScore + memScore; + signal divRemainder; + divRemainder <== sumScores - doubleScore; + component remCheck = LessThan(8); + remCheck.in[0] <== divRemainder; + remCheck.in[1] <== 2; + remCheck.out === 1; +} + +template RangeCheck100() { + signal input value; + component lte = LessEqThan(8); + lte.in[0] <== value; + lte.in[1] <== 100; + lte.out === 1; +} + +template AuditScoreVerifier() { + signal input dimensionalScores[6]; + signal input overallScore; + signal input inputCommitment; + + signal input categoryScores[6][10]; + signal input categoryCounts[6]; + signal input cpuAvgMilli; + signal input memoryPeakMb; + signal input complianceScore; + signal input securityBoundaryScore; + + // Step 1: Input commitment + component commitHash = Poseidon(8); + commitHash.inputs[0] <== categoryCounts[0]; + commitHash.inputs[1] <== categoryCounts[1]; + commitHash.inputs[2] <== categoryCounts[2]; + commitHash.inputs[3] <== categoryCounts[3]; + commitHash.inputs[4] <== cpuAvgMilli; + commitHash.inputs[5] <== memoryPeakMb; + commitHash.inputs[6] <== complianceScore; + commitHash.inputs[7] <== securityBoundaryScore; + commitHash.out === inputCommitment; + + // Step 2: Dimensional score verification + + // Dim 0: Security + component secAvg = SafeAverage(10); + for (var i = 0; i < 10; i++) { secAvg.values[i] <== categoryScores[0][i]; } + secAvg.count <== categoryCounts[0]; + + component secHasQ = IsZero(); + secHasQ.in <== categoryCounts[0]; + signal secCombined; + secCombined <-- secHasQ.out == 1 ? securityBoundaryScore : (secAvg.avg + securityBoundaryScore) \ 2; + dimensionalScores[0] === secCombined; + + // Dim 1: Task Execution + component taskAvg = SafeAverage(10); + for (var i = 0; i < 10; i++) { taskAvg.values[i] <== categoryScores[1][i]; } + taskAvg.count <== categoryCounts[1]; + dimensionalScores[1] === taskAvg.avg; + + // Dim 2: Cognitive + component cogAvg = SafeAverage(10); + for (var i = 0; i < 10; i++) { cogAvg.values[i] <== categoryScores[2][i]; } + cogAvg.count <== categoryCounts[2]; + dimensionalScores[2] === cogAvg.avg; + + // Dim 3: Environment + component envAvg = SafeAverage(10); + for (var i = 0; i < 10; i++) { envAvg.values[i] <== categoryScores[3][i]; } + envAvg.count <== categoryCounts[3]; + dimensionalScores[3] === envAvg.avg; + + // Dim 4: Engineering + component resScore = ResourceScore(); + resScore.cpuAvgMilli <== cpuAvgMilli; + resScore.memoryPeakMb <== memoryPeakMb; + dimensionalScores[4] === resScore.score; + + // Dim 5: Compliance + dimensionalScores[5] === complianceScore; + + // Step 3: Overall weighted average + signal w0; w0 <== dimensionalScores[0] * 2500; + signal w1; w1 <== dimensionalScores[1] * 2000; + signal w2; w2 <== dimensionalScores[2] * 1500; + signal w3; w3 <== dimensionalScores[3] * 1500; + signal w4; w4 <== dimensionalScores[4] * 1500; + signal w5; w5 <== dimensionalScores[5] * 1000; + signal weightedSum; + weightedSum <== w0 + w1 + w2 + w3 + w4 + w5; + + signal computedOverall; + computedOverall <-- weightedSum \ 10000; + + signal lowerBound; + lowerBound <== computedOverall * 10000; + signal upperBound; + upperBound <== lowerBound + 10000; + + component overallGte = GreaterEqThan(32); + overallGte.in[0] <== weightedSum; + overallGte.in[1] <== lowerBound; + overallGte.out === 1; + + component overallLt = LessThan(32); + overallLt.in[0] <== weightedSum; + overallLt.in[1] <== upperBound; + overallLt.out === 1; + + overallScore === computedOverall; + + // Step 4: Range checks + component rangeChecks[7]; + for (var i = 0; i < 6; i++) { + rangeChecks[i] = RangeCheck100(); + rangeChecks[i].value <== dimensionalScores[i]; + } + rangeChecks[6] = RangeCheck100(); + rangeChecks[6].value <== overallScore; +} + +component main {public [dimensionalScores, overallScore, inputCommitment]} = AuditScoreVerifier(); diff --git a/contracts/zk/package.json b/contracts/zk/package.json new file mode 100644 index 0000000..81fe777 --- /dev/null +++ b/contracts/zk/package.json @@ -0,0 +1,14 @@ +{ + "name": "agent-shenji-zk", + "version": "0.1.0", + "private": true, + "description": "ZK circuits and tooling for Agent Shenji audit verification", + "scripts": { + "compile": "bash scripts/compile-circuits.sh", + "clean": "rm -rf build" + }, + "dependencies": { + "circomlib": "^2.0.5", + "snarkjs": "^0.7.4" + } +} diff --git a/contracts/zk/scripts/compile-circuits.sh b/contracts/zk/scripts/compile-circuits.sh new file mode 100755 index 0000000..fe8c638 --- /dev/null +++ b/contracts/zk/scripts/compile-circuits.sh @@ -0,0 +1,118 @@ +#!/usr/bin/env bash +# Compile circom circuits โ†’ R1CS + WASM + generate Groth16 verifier contracts +# +# Prerequisites: +# - circom >= 2.1.6 (install: cargo install circom) +# - snarkjs (npm install -g snarkjs) +# - Node.js 20+ +# - circomlib (npm install circomlib) +# +# Usage: +# cd contracts/zk && bash scripts/compile-circuits.sh +# +# Outputs: +# build// +# *.r1cs โ€” constraint system +# *_js/ โ€” WASM witness generator +# *.sym โ€” symbol table +# verification_key.json +# proving_key.zkey +# ../src/ +# AuditScoreVerifier_Groth16.sol +# AgentFingerprintVerifier_Groth16.sol + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ZK_DIR="$(dirname "$SCRIPT_DIR")" +BUILD_DIR="$ZK_DIR/build" +CIRCUITS_DIR="$ZK_DIR/circuits" +CONTRACTS_SRC="$ZK_DIR/../src" + +# Check prerequisites +command -v circom >/dev/null 2>&1 || { echo "ERROR: circom not found. Install: cargo install circom"; exit 1; } +command -v snarkjs >/dev/null 2>&1 || { echo "ERROR: snarkjs not found. Install: npm install -g snarkjs"; exit 1; } + +# Ensure circomlib is available +if [ ! -d "$ZK_DIR/node_modules/circomlib" ]; then + echo "Installing circomlib..." + cd "$ZK_DIR" && npm install circomlib +fi + +# Powers of Tau ceremony (reuse if exists) +PTAU_FILE="$BUILD_DIR/pot16_final.ptau" +if [ ! -f "$PTAU_FILE" ]; then + echo "=== Running Powers of Tau ceremony (2^14) ===" + mkdir -p "$BUILD_DIR" + snarkjs powersoftau new bn128 14 "$BUILD_DIR/pot16_0000.ptau" -v + snarkjs powersoftau contribute "$BUILD_DIR/pot16_0000.ptau" "$BUILD_DIR/pot16_0001.ptau" \ + --name="Agent Shenji contribution" -v -e="$(head -c 64 /dev/urandom | xxd -p -c 128)" + snarkjs powersoftau prepare phase2 "$BUILD_DIR/pot16_0001.ptau" "$PTAU_FILE" -v + rm -f "$BUILD_DIR/pot16_0000.ptau" "$BUILD_DIR/pot16_0001.ptau" + echo "=== Powers of Tau complete ===" +fi + +compile_circuit() { + local CIRCUIT_NAME="$1" + local CIRCUIT_FILE="$CIRCUITS_DIR/$CIRCUIT_NAME.circom" + local OUT_DIR="$BUILD_DIR/$CIRCUIT_NAME" + + echo "" + echo "=== Compiling $CIRCUIT_NAME ===" + + mkdir -p "$OUT_DIR" + + # Step 1: Compile circom โ†’ R1CS + WASM + circom "$CIRCUIT_FILE" \ + --r1cs --wasm --sym \ + -o "$OUT_DIR" \ + -l "$ZK_DIR/node_modules" + + echo "Constraints: $(snarkjs r1cs info "$OUT_DIR/$CIRCUIT_NAME.r1cs" 2>&1 | grep 'Constraints' || true)" + + # Step 2: Generate proving key (Groth16 setup) + snarkjs groth16 setup \ + "$OUT_DIR/$CIRCUIT_NAME.r1cs" \ + "$PTAU_FILE" \ + "$OUT_DIR/${CIRCUIT_NAME}_0000.zkey" + + # Step 3: Contribute to phase 2 + snarkjs zkey contribute \ + "$OUT_DIR/${CIRCUIT_NAME}_0000.zkey" \ + "$OUT_DIR/${CIRCUIT_NAME}_final.zkey" \ + --name="Agent Shenji $CIRCUIT_NAME" \ + -e="$(head -c 64 /dev/urandom | xxd -p -c 128)" + + rm -f "$OUT_DIR/${CIRCUIT_NAME}_0000.zkey" + mv "$OUT_DIR/${CIRCUIT_NAME}_final.zkey" "$OUT_DIR/proving_key.zkey" + + # Step 4: Export verification key + snarkjs zkey export verificationkey \ + "$OUT_DIR/proving_key.zkey" \ + "$OUT_DIR/verification_key.json" + + # Step 5: Generate Solidity verifier contract + local SOL_NAME="${CIRCUIT_NAME}Verifier_Groth16.sol" + snarkjs zkey export solidityverifier \ + "$OUT_DIR/proving_key.zkey" \ + "$CONTRACTS_SRC/$SOL_NAME" + + echo "=== $CIRCUIT_NAME compiled ===" + echo " R1CS: $OUT_DIR/$CIRCUIT_NAME.r1cs" + echo " WASM: $OUT_DIR/${CIRCUIT_NAME}_js/" + echo " Proving key: $OUT_DIR/proving_key.zkey" + echo " Verify key: $OUT_DIR/verification_key.json" + echo " Solidity: $CONTRACTS_SRC/$SOL_NAME" +} + +# Compile both circuits +compile_circuit "AuditScoreVerifier" +compile_circuit "AgentFingerprint" + +echo "" +echo "=== All circuits compiled successfully ===" +echo "" +echo "Next steps:" +echo " 1. Deploy verifier contracts from contracts/src/*_Groth16.sol" +echo " 2. Use build//proving_key.zkey + *_js/ for proof generation" +echo " 3. Verify proofs on-chain via the deployed verifier" diff --git a/docs/TRUSTED-AGENT-SKILL.md b/docs/TRUSTED-AGENT-SKILL.md new file mode 100644 index 0000000..88cb130 --- /dev/null +++ b/docs/TRUSTED-AGENT-SKILL.md @@ -0,0 +1,371 @@ +--- +name: trusted-agent-skill +description: Claude/Cursor ็ญ‰ AI ๅŠฉๆ‰‹่ฐƒ็”จ Agent Shenji CLI ่ฟ›่กŒ agent ๆœ็ดขใ€ๅฏไฟกๆ‘˜่ฆ่ฏปๅ–ใ€ๅކๅฒๅฎก่ฎกๅ›ž็œ‹ไธŽๅฏไฟกๆๆ–™้ชŒ่ฏ็š„ๅทฅไฝœๆต่ฏดๆ˜Žใ€‚ +type: reference +version: 0.1.0 +author: Trusted-Agent-Marketplace +license: MIT +repository: https://github.com/ZhangJinHaHaHa/Trusted-Agent-Marketplace +tags: + - web3 + - blockchain + - agent-audit + - trust + - aivs + - cli + - verification +requires: + - node>=20 + - npm +entrypoint: + type: cli + workdir: sandbox + commands: + - npm run run:agent:registry -- [...args] +--- + +# Trusted Agent Skill + +## Purpose + +ๆŠŠ `sandbox` ไธญๅทฒ็ปๅญ˜ๅœจ็š„ CLI ๆ‰ง่กŒๅฑ‚็ป„็ป‡ๆˆ AI ๅŠฉๆ‰‹ๅฏ็›ดๆŽฅๅค็”จ็š„ๆ“ไฝœ่ง„่Œƒ๏ผš + +- ๅ…ˆ `search` ็ญ›้€‰ๅ€™้€‰ agent +- ๅ† `get-report` ่ฏปๅ–ๆœ€ๆ–ฐๆˆ–ๆŒ‡ๅฎšๅކๅฒๅฎก่ฎกๆ‘˜่ฆ +- ็”จ `history` ๅˆ†้กตๅ›ž็œ‹ๅކๅฒๅฎก่ฎก่ฝจ่ฟน +- ๆœ€ๅŽ `verify` ้ชŒ่ฏๆŠฅๅ‘Šใ€ๅญ˜่ฏๆˆ– attestation + +่ฟ™ไธช Skill ๅชๆ่ฟฐไฝ•ๆ—ถ่ฐƒ็”จไป€ไนˆๅ‘ฝไปคใ€ๅฆ‚ไฝ•่งฃ้‡Š่ฟ”ๅ›ž็ป“ๆžœ๏ผŒไธ้‡ๅคๅฎž็Žฐๅบ•ๅฑ‚้€ป่พ‘ใ€‚ + +## Tool contract + +### 1. ๆœ็ดขๅ€™้€‰ agent + +```bash +npm run run:agent:search -- --batch-size 10 --agent-name-contains risk --status 2 --min-score 80 +``` + +่ฟ”ๅ›žไธ€่กŒ JSON๏ผš + +```json +{ + "status": "ok", + "filters": { + "startTokenId": 1, + "batchSize": 10, + "maxConsecutiveNotFound": 5, + "agentNameContains": "risk", + "status": 2, + "minScore": 80 + }, + "agents": [ + { + "tokenId": "1", + "agentName": "risk-agent", + "developer": "0x...", + "totalBond": "1000", + "blacklisted": false, + "auditCount": 2, + "latestStatus": 2, + "latestScore": 92 + } + ], + "nextScanTokenId": "11", + "consecutiveNotFound": 0, + "hasMore": true +} +``` + +### 2. ่ฏปๅ– agent ๅฏไฟกๆ‘˜่ฆ + +่ฏปๅ–ๆœ€ๆ–ฐๆ‘˜่ฆ๏ผš + +```bash +npm run run:agent:get-report -- --token-id 1 +``` + +่ฏปๅ–ๆŒ‡ๅฎšๅކๅฒๅฎก่ฎก๏ผš + +```bash +npm run run:agent:get-report -- --token-id 1 --audit-id 7 +``` + +ไธๅธฆ `--audit-id` ๆ—ถ่ฟ”ๅ›žไธ€่กŒ JSON๏ผˆlatest ๆจกๅผ๏ผ‰๏ผš + +```json +{ + "status": "ok", + "tokenId": "1", + "profile": { + "developer": "0x...", + "agentName": "risk-agent", + "tokenId": "1", + "totalBond": "1000", + "blacklisted": false, + "createdAt": 1710000000, + "lastAuditAt": 1710000100, + "auditCount": 1 + }, + "latestAuditReport": { + "auditId": 1, + "timestamp": 1710000100, + "auditScore": 92, + "status": 2, + "reportCID": "bafy-report", + "manifestUrl": "https://example.com/manifest.json", + "appealRequested": false, + "appealApproved": false + } +} +``` + +ๆŒ‡ๅฎš `--audit-id` ๆ—ถ๏ผŒ่ฟ”ๅ›ž็ป“ๆž„ไธญ็š„ๅฎก่ฎกๅญ—ๆฎตๅ˜ไธบ `auditReport`๏ผš + +```json +{ + "status": "ok", + "tokenId": "1", + "auditId": 7, + "profile": { + "developer": "0x...", + "agentName": "risk-agent", + "tokenId": "1", + "totalBond": "1000", + "blacklisted": false, + "createdAt": 1710000000, + "lastAuditAt": 1710000100, + "auditCount": 3 + }, + "auditReport": { + "auditId": 7, + "timestamp": 1710000100, + "auditScore": 95, + "status": 2, + "reportCID": "bafy-report-7", + "manifestUrl": "https://example.com/manifest.json", + "appealRequested": false, + "appealApproved": false + } +} +``` + +่‹ฅๆŒ‡ๅฎš็š„ `auditId` ไธๅญ˜ๅœจ๏ผš + +```json +{ + "status": "audit_not_found", + "tokenId": "1", + "auditId": 7, + "profile": { "...": "..." } +} +``` + +่‹ฅ token ไธๅญ˜ๅœจ๏ผš + +```json +{ + "status": "not_found", + "tokenId": "1" +} +``` + +### 3. ๆต่งˆๅކๅฒๅฎก่ฎก่ฎฐๅฝ• + +```bash +npm run run:agent:registry -- history --token-id 1 --offset 0 --limit 2 +``` + +่ฟ”ๅ›žไธ€่กŒ JSON๏ผŒๆŒ‰"ๆœ€ๆ–ฐไผ˜ๅ…ˆ"่ฟ”ๅ›žๅˆ†้กต็ป“ๆžœ๏ผš + +```json +{ + "status": "ok", + "tokenId": "1", + "profile": { + "developer": "0x...", + "agentName": "risk-agent", + "tokenId": "1", + "totalBond": "1000", + "blacklisted": false, + "createdAt": 1710000000, + "lastAuditAt": 1710000100, + "auditCount": 4 + }, + "paging": { + "offset": 0, + "limit": 2, + "total": 4, + "returned": 2, + "hasMore": true + }, + "audits": [ + { + "index": 3, + "auditId": 12, + "timestamp": 1710000100, + "auditScore": 95, + "status": 2, + "reportCID": "bafy-report-12", + "manifestUrl": "https://example.com/manifest.json", + "appealRequested": false, + "appealApproved": false + }, + { + "index": 2, + "auditId": 11, + "timestamp": 1710000000, + "auditScore": 90, + "status": 2, + "reportCID": "bafy-report-11", + "manifestUrl": "https://example.com/manifest.json", + "appealRequested": false, + "appealApproved": false + } + ] +} +``` + +่‹ฅ token ไธๅญ˜ๅœจ๏ผš + +```json +{ + "status": "not_found", + "tokenId": "1" +} +``` + +### 4. ้ชŒ่ฏๅฏไฟกๆๆ–™ + +็ปŸไธ€ๅ…ฅๅฃ๏ผš + +```bash +npm run run:agent:verify -- report --event-key 0xabc:0 +npm run run:agent:verify -- evidence --event-key 0xabc:0 +npm run run:agent:verify -- attestation --event-key 0xabc:0 +``` + +่ฏดๆ˜Ž๏ผš + +- `report` ่ฝฌๅ‘ๅˆฐ `run:report:verify` +- `evidence` ่ฝฌๅ‘ๅˆฐ `run:evidence:verify` +- `attestation` ่ฝฌๅ‘ๅˆฐ `run:attestation:verify` +- ๆ‰€ๆœ‰ๅ‚ๆ•ฐ็ปง็ปญ้€ไผ ๏ผŒๅฏ้™„ๅŠ  `--state-dir` + +## SOP + +### ๅœบๆ™ฏ A๏ผšๅธฎ็”จๆˆทๆ‰พไธ€ไธชๅฏไฟก agent + +1. ๆ นๆฎ็”จๆˆทๆกไปถ่ฐƒ็”จ `search` +2. ๅ…ˆ็ญ›ๆމ๏ผš + - `blacklisted === true` + - `latestStatus` ไธ็ฌฆๅˆ่ฆๆฑ‚ + - `latestScore` ไฝŽไบŽ็”จๆˆท้—จๆง› +3. ๅ–ๅ‰ๅ‡ ไธชๅ€™้€‰๏ผŒๅ†้€ไธช่ฐƒ็”จ `get-report` +4. ่พ“ๅ‡บๆŽจ่ๆ—ถๅŒๆ—ถ่ฏดๆ˜Ž๏ผš + - ๅฝ“ๅ‰ๅˆ†ๆ•ฐ / ็Šถๆ€ + - ๆœ€่ฟ‘ไธ€ๆฌกๅฎก่ฎกๆ—ถ้—ด + - ๆ˜ฏๅฆๆœ‰ appeal + - ๆ˜ฏๅฆ่ฟ˜้œ€่ฆ่ฟ›ไธ€ๆญฅ `verify` + +### ๅœบๆ™ฏ B๏ผšๅธฎ็”จๆˆทๅˆคๆ–ญๆŸไธช agent ้ ไธ้ ่ฐฑ + +1. ๅทฒ็Ÿฅ tokenId ๆ—ถ๏ผŒๅ…ˆ่ฐƒ็”จ `get-report` +2. ่‹ฅ็”จๆˆทๅชๅ…ณๅฟƒๆœ€่ฟ‘็Šถๆ€๏ผŒ็›ดๆŽฅ่ฏปๅ– latest ็ป“ๆžœ +3. ่‹ฅ็”จๆˆทๆŒ‡ๅฎšๆŸๆฌกๅฎก่ฎก๏ผŒไฝฟ็”จ `--audit-id` +4. ่‹ฅ็”จๆˆทๆƒณ็œ‹ๆ•ดไฝ“ๅ˜ๅŒ–่ถ‹ๅŠฟ๏ผŒๆ”น็”จ `history` +5. ้‡็‚น่งฃ้‡Š๏ผš + - `blacklisted` + - `auditCount` + - `latestAuditReport.auditScore` ๆˆ– `auditReport.auditScore` + - `latestAuditReport.status` ๆˆ– `auditReport.status` + - `appealRequested` / `appealApproved` +6. ๅฆ‚ๆžœ็”จๆˆท้œ€่ฆๆ›ดๅผบ่ฏๆ˜Ž๏ผŒๅ†่กฅ `verify` + +### ๅœบๆ™ฏ C๏ผšๅธฎ็”จๆˆทๅ›ž็œ‹ๅކๅฒๅฎก่ฎก + +1. ๅทฒ็Ÿฅ tokenId ๆ—ถ่ฐƒ็”จ `history` +2. ้ป˜่ฎคๆŒ‰ๆœ€ๆ–ฐไผ˜ๅ…ˆ่งฃ้‡Šๆœ€่ฟ‘ๅ‡ ๆฌกๅฎก่ฎก +3. ๅฆ‚้œ€็ปง็ปญ็ฟป้กต๏ผŒไปŽ `offset + returned` ็ปง็ปญ่ฏทๆฑ‚ +4. ้‡็‚น่ฏดๆ˜Ž๏ผš + - ๅˆ†้กตๅŒบ้—ด + - ๆ˜ฏๅฆ่ฟ˜ๆœ‰ๆ›ดๅคšๅކๅฒ่ฎฐๅฝ•๏ผˆ`hasMore`๏ผ‰ + - ๅˆ†ๆ•ฐ / ็Šถๆ€ๆ˜ฏๅฆๅ‡บ็Žฐ่ฟž็ปญไธ‹้™ๆˆ–ๅผ‚ๅธธๆณขๅŠจ + - ๆ˜ฏๅฆๅญ˜ๅœจ appeal +5. ๅฆ‚ๆžœ็”จๆˆท้”ๅฎšๆŸๆฌกๅฎก่ฎก๏ผŒๅ†ๆ”น็”จ `get-report --audit-id ` ่ฏปๅ–ๅ•ๆก่ฏฆๆƒ… + +### ๅœบๆ™ฏ D๏ผšๅธฎ็”จๆˆท้ชŒ่ฏไธ€ไปฝๆŠฅๅ‘Š/่ฏๆ˜Ž + +1. ๅ…ˆๆ˜Ž็กฎ็”จๆˆท่ฆ้ชŒ็š„ๆ˜ฏ `report`ใ€`evidence` ่ฟ˜ๆ˜ฏ `attestation` +2. ่ฐƒ็”จ็ปŸไธ€ `verify` ๅ…ฅๅฃ +3. ๆŒ‰็ป“ๆžœ่งฃ้‡Š๏ผš + - `verified`๏ผšๅฏ่ฎคไธบ่ฏฅๅฑ‚ๆ•ฐๆฎๅฎŒๆ•ดไธ”ๆœช่ขซ็ฏกๆ”น + - `not_found`๏ผšๆœฌๅœฐ state ไธญๆœชๆ‰พๅˆฐๅฏนๅบ”ๆๆ–™ + - `conflict`๏ผšๅŒไธ€ eventKey ๅญ˜ๅœจๅคšไธชๅ€™้€‰ๆ–‡ไปถ + - `hash_mismatch`๏ผšๅ†…ๅฎนไธŽๆ–‡ไปถๅๅตŒๅ…ฅๅ“ˆๅธŒไธไธ€่‡ด + - `invalid_event_key`๏ผš่พ“ๅ…ฅๆ ผๅผ้”™่ฏฏ +4. ่‹ฅๆ˜ฏ `attestation` `verified` ไธ”ๅฏ็”จไบ† report-data binding๏ผŒๅฏ่ฟ›ไธ€ๆญฅ่ฏดๆ˜Žๅ…ถไธŽ `eventKey + manifestHash + evidenceRoot` ็š„็ป‘ๅฎšๅ…ณ็ณป + +## Error handling + +ๆ‰€ๆœ‰ CLI ๅ‘ฝไปค้ƒฝ่ฟ”ๅ›žๅ•่กŒ JSONใ€‚AI ๅŠฉๆ‰‹ๅบ”ไผ˜ๅ…ˆๆŒ‰ `status` ๅญ—ๆฎตๅค„็†๏ผ›้‡ๅˆฐไธ‹ๅˆ—ๆƒ…ๅ†ตๆŒ‰ไปฅไธ‹ SOP ๆ‰ง่กŒ๏ผš + +### E1. ้“พไธŠ RPC ่ถ…ๆ—ถ / ็ฝ‘็ปœ้”™่ฏฏ + +็—‡็Šถ๏ผšCLI ่ฟ›็จ‹ไปฅ้ž้›ถ้€€ๅ‡บ็ ็ป“ๆŸ๏ผŒstderr ๅ‡บ็Žฐ `JSON-RPC request failed`ใ€`ETIMEDOUT`ใ€`ECONNREFUSED` ๆˆ– `fetch failed`ใ€‚ + +SOP๏ผš + +1. ๆฃ€ๆŸฅ `RPC_URL` / `LISTENER_RPC_URL` ็Žฏๅขƒๅ˜้‡ๆ˜ฏๅฆ้…็ฝฎๆญฃ็กฎ +2. ๅŒไธ€ๅ‘ฝไปคๆœ€ๅคš้‡่ฏ• 2 ๆฌก๏ผŒ้‡่ฏ•ไน‹้—ด้€€้ฟ 2 ็ง’ +3. ไปๅคฑ่ดฅๅˆ™ๅ‘็”จๆˆทๆŠฅๅ‘Š๏ผš"้“พไธŠ RPC ๅฝ“ๅ‰ไธๅฏ่พพ๏ผŒๆ— ๆณ•่ฏปๅ–่ฏฅ agent ็š„ๆœ€ๆ–ฐ็Šถๆ€๏ผŒๅปบ่ฎฎ็จๅŽ้‡่ฏ•"๏ผŒ**ไธ่ฆ**็”จๆ—ง็ผ“ๅญ˜ไผช้€ ็ป“่ฎบ +4. ๅฆ‚ๆžœไธšๅŠกๅ…่ฎธ้™็บง๏ผŒๅฏๆ”นไธบๅชๅฑ•็คบๅކๅฒๅทฒ่ฏปๅˆฐ็š„ๅญ—ๆฎต๏ผˆๆ ‡ๆณจ"่ฏฅๅญ—ๆฎตไธบ็ผ“ๅญ˜ๅ€ผ๏ผŒๆœชไธŽ้“พไธŠๅŒๆญฅ"๏ผ‰ + +### E2. Agent ่ขซๆƒฉ็ฝš / ้ป‘ๅๅ•๏ผˆSlashed๏ผ‰ + +็—‡็Šถ๏ผš`get-report` / `search` ่ฟ”ๅ›ž `profile.blacklisted === true`๏ผŒๆˆ– `latestAuditReport.status` ๅœจๅˆ็บฆๅฎšไน‰ไธญไปฃ่กจๆƒฉ็ฝšๆ€๏ผˆๅ…ธๅž‹ไธบ้ž `2`๏ผŒไพ‹ๅฆ‚ `4=slashed`ใ€`5=blacklisted`๏ผ‰ใ€‚ + +SOP๏ผš + +1. ๅœจๅœบๆ™ฏ A๏ผˆๆŽจ่ agent๏ผ‰ไธญ**็›ดๆŽฅๅฐ†ๅ…ถไปŽๅ€™้€‰ๅˆ—่กจๅ‰”้™ค**๏ผŒไธๅ‘็”จๆˆทๅ‘ˆ็Žฐ +2. ๅœจๅœบๆ™ฏ B๏ผˆ่ฏ„ๅˆคๆŸไธช agent๏ผ‰ไธญ**ๅฟ…้กปๆ˜พๅผๅ‘Š็Ÿฅ**๏ผš"่ฏฅ agent ๅทฒ่ขซ้“พไธŠไปฒ่ฃๆƒฉ็ฝš / ๅˆ—ๅ…ฅ้ป‘ๅๅ•๏ผŒไธๅปบ่ฎฎๆŽฅๅ…ฅ" +3. ่ฟ›ไธ€ๆญฅ็”จ `history` ๆฃ€ๆŸฅ่ฟ‘ N ๆฌกๅฎก่ฎก็š„ๅˆ†ๆ•ฐไธŽ็Šถๆ€่ถ‹ๅŠฟ๏ผŒๅ‘็”จๆˆท่งฃ้‡Šๆƒฉ็ฝšๆ˜ฏๅฆไธ€ๆฌกๆ€งๅถๅ‘่ฟ˜ๆ˜ฏๆŒ็ปญๅผ‚ๅธธ +4. ่‹ฅ็”จๆˆทไปๅšๆŒ่ฆ็”จ๏ผŒๆ็คบๅ…ถๅ…ˆ่ฐƒ็”จ `verify` ้“พ่ทฏ็กฎ่ฎคๆœ€ๆ–ฐไธ€ไปฝ้žๆƒฉ็ฝšๆ€ๆŠฅๅ‘Š็š„็œŸไผช + +### E3. token ไธๅญ˜ๅœจ / ๅฎก่ฎกไธๅญ˜ๅœจ + +็—‡็Šถ๏ผš`status === "not_found"` ๆˆ– `status === "audit_not_found"`ใ€‚ + +SOP๏ผš + +1. ็›ดๆŽฅๅ‘Š่ฏ‰็”จๆˆท่พ“ๅ…ฅ็š„ tokenId ๆˆ– auditId ๅœจ้“พไธŠไธๅญ˜ๅœจ +2. ไธ่ฆ่ฏ•ๅ›พ็Œœๆต‹ไธด่ฟ‘ id๏ผ›่ฎฉ็”จๆˆท้‡ๆ–ฐๆไพ›ๆˆ–ๅ…ˆ็”จ `search` ๆ‰พๅ€™้€‰ + +### E4. ๅฏไฟกๆๆ–™ๆ ก้ชŒๅคฑ่ดฅ + +็—‡็Šถ๏ผš`verify` ๅญๅ‘ฝไปค่ฟ”ๅ›ž `hash_mismatch` / `conflict` / `invalid_event_key`ใ€‚ + +SOP๏ผš + +- `hash_mismatch`๏ผšๆ˜Ž็กฎๅ‘Š่ฏ‰็”จๆˆทๆ–‡ไปถๅ†…ๅฎนไธŽๆ–‡ไปถๅๅตŒๅ…ฅๅ“ˆๅธŒไธไธ€่‡ด๏ผŒ**่ง†ไธบไธๅฏไฟก**๏ผŒไธ่ฆ็ปง็ปญๅŸบไบŽ่ฏฅๆ–‡ไปถๅš็ป“่ฎบ +- `conflict`๏ผšๅŒไธ€ eventKey ไธ‹ๅญ˜ๅœจๅคšไธชๅ€™้€‰ๆๆ–™๏ผŒๅบ”่ฎฉ็”จๆˆทๆŒ‡ๅฎš `--state-dir` ๆˆ–ๆธ…็† listener state +- `invalid_event_key`๏ผšๅ‚ๆ•ฐๆ ผๅผ้”™่ฏฏ๏ผŒๆŒ‰ `:` ้‡ๆ–ฐ่พ“ๅ…ฅ + +## Response guidance for AI assistants + +- ไผ˜ๅ…ˆๅผ•็”จ CLI ็š„็ป“ๆž„ๅŒ– JSON๏ผŒไธ่ฆๅ‡ญ็ฉบๆŽจๆ–ญ้“พไธŠ็Šถๆ€ใ€‚ +- ๅฝ“ `latestAuditReport` ไธบ `null` ๆ—ถ๏ผŒๆ˜Ž็กฎ่ฏด"ๆ‰พๅˆฐ agent๏ผŒไฝ†่ฟ˜ๆฒกๆœ‰ๆœ€ๆ–ฐๅฎก่ฎก่ฎฐๅฝ•"ใ€‚ +- ๅฝ“ `get-report --audit-id` ่ฟ”ๅ›ž `audit_not_found` ๆ—ถ๏ผŒๆ˜Ž็กฎ่ฏด"agent ๅญ˜ๅœจ๏ผŒไฝ†ๆŒ‡ๅฎš auditId ไธๅญ˜ๅœจ"ใ€‚ +- ๅฝ“ `history.paging.hasMore === true` ๆ—ถ๏ผŒๅฏไปฅๅปบ่ฎฎ็ปง็ปญๅขžๅŠ  `offset` ็ฟป้กตใ€‚ +- `history.audits` ไธญ็š„ `index` ๆ˜ฏ้“พไธŠๅކๅฒ็ดขๅผ•๏ผŒ้กบๅบๆŒ‰ๆœ€ๆ–ฐไผ˜ๅ…ˆ่ฟ”ๅ›ž๏ผŒไธ็ญ‰ไบŽ `auditId`ใ€‚ +- ๅฝ“ `search.hasMore === true` ๆ—ถ๏ผŒๅฏไปฅๅปบ่ฎฎ็ปง็ปญไปŽ `nextScanTokenId` ็ฟป้กตๆ‰ซๆใ€‚ +- ไธ่ฆๆŠŠ `verify` ๆˆๅŠŸ่งฃ่ฏปไธบ"่ฟ™ไธช agent ไธ€ๅฎšๅฎ‰ๅ…จ"๏ผŒๅฎƒๅช่ฏๆ˜Žๆๆ–™็š„ๅฎŒๆ•ดๆ€ง / ไธ€่‡ดๆ€ง๏ผŒไธๆ›ฟไปฃ้ฃŽ้™ฉๅˆคๆ–ญใ€‚ + +## Current priority + +ๆŒ‰็…งๅฝ“ๅ‰ๅฎž็Žฐ๏ผŒSkill ้œ€่ฆๅŒๆ—ถ่ฆ†็›–ไธ‰็ฑปๆŸฅ่ฏข๏ผš + +- `search`๏ผšๅ‘็Žฐๅ€™้€‰ agent +- `get-report`๏ผš่ฏปๅ–ๆœ€ๆ–ฐๆˆ–ๆŒ‡ๅฎšๅކๅฒๅฎก่ฎกๆ‘˜่ฆ +- `history`๏ผšๅˆ†้กตๅ›ž็œ‹ๅކๅฒๅฎก่ฎก่ฝจ่ฟน + +ๅ› ๆญค๏ผŒๅŽ็ปญไผ˜ๅ…ˆ็ปดๆŠค CLI ๅญ—ๆฎตๅฅ‘็บฆไธŽๆœฌๆ–‡ไปถ่ฏดๆ˜Ž็š„ไธ€่‡ดๆ€ง๏ผŒๅ†็ปง็ปญๆ‰ฉๅฑ•ๆ›ดๅคๆ‚็š„ๅฏไฟก่ฏ„ๅˆ†ๆˆ–ๅค–้ƒจ้›†ๆˆ่ƒฝๅŠ›ใ€‚ diff --git a/docs/agent-integration-guide.md b/docs/agent-integration-guide.md new file mode 100644 index 0000000..939b3e8 --- /dev/null +++ b/docs/agent-integration-guide.md @@ -0,0 +1,463 @@ +# Agent ๆŽฅๅ…ฅๅฎก่ฎกๆต‹่ฏ•ๆŒ‡ๅ— + +ๆœฌๆ–‡ๆกฃ้ขๅ‘ๅธŒๆœ›ๅฐ† AI AgentๆŽฅๅ…ฅ Agent Shenji ๅฎก่ฎก็ณป็ปŸ่ฟ›่กŒๆต‹่ฏ•็š„ๅผ€ๅ‘่€…ใ€‚ + +--- + +## 1. ็ณป็ปŸๆฆ‚่ฟฐ + +Agent Shenji ๆ˜ฏไธ€ไธช **้“พไธŠไฟก็”จๅฎก่ฎก็ณป็ปŸ**ใ€‚ๅฎƒ็š„ๅทฅไฝœๆ–นๅผ๏ผš + +``` +ๅผ€ๅ‘่€…ๆไบค Agent ไฟกๆฏ๏ผˆ่ดจๆŠผ + Manifest๏ผ‰ + โ†“ +ๅˆ็บฆ้“ธ้€  NFT๏ผŒๅ‘ๅ‡บ AuditRequested ไบ‹ไปถ + โ†“ +ๅฎก่ฎก็›‘ๅฌๅ™จ่‡ชๅŠจๆ‹‰่ตท Agent ๅฎนๅ™จ๏ผŒๅœจๆฒ™็ฎฑไธญๆ‰ง่กŒๅฎก่ฎก + โ†“ +LLM ๅ‡บ้ข˜ โ†’ Agent ไฝœ็ญ” โ†’ ็ฝ‘็ปœ/่ต„ๆบ/่กŒไธบๅ…จ็จ‹ๅ–่ฏ + โ†“ +ๅฎก่ฎก็ป“ๆžœ + ่ฏๆฎๅ†™ๅ›ž้“พไธŠ๏ผŒ็”Ÿๆˆไฟก็”จๆกฃๆกˆ +``` + +**ๆ ธๅฟƒๆฆ‚ๅฟต**๏ผšไฝ ็š„ Agent ้œ€่ฆไปฅ Docker ๅฎนๅ™จๅฝขๅผ่ฟ่กŒ๏ผŒๆšด้œฒไธคไธช HTTP ๆŽฅๅฃไพ›ๅฎก่ฎก็ณป็ปŸ่ฐƒ็”จใ€‚ + +--- + +## 2. Agent ้œ€่ฆๅšไป€ไนˆ + +### 2.1 ๅ‡†ๅค‡ Manifest ๆ–‡ไปถ + +Manifest ๆ˜ฏไธ€ไธช JSON ๆ–‡ไปถ๏ผŒๆ่ฟฐ Agent ็š„ๅŸบๆœฌไฟกๆฏๅ’Œ็ฝ‘็ปœๆƒ้™ๅฃฐๆ˜Ž๏ผš + +```json +{ + "agent_name": "hermes-agent", + "image": "your-registry.com/hermes-agent:1.0.0", + "allowed_hosts": [ + "api.hermes.io", + "api.openai.com" + ], + "allowed_rpc_endpoints": [ + "https://rpc.polygon.edge.io" + ] +} +``` + +| ๅญ—ๆฎต | ่ฏดๆ˜Ž | +|------|------| +| `agent_name` | Agent ๅ”ฏไธ€ๅ็งฐ๏ผŒ้œ€ไธŽ้“พไธŠๆณจๅ†Œๆ—ถไธ€่‡ด | +| `image` | Docker ้•œๅƒๅœฐๅ€๏ผˆ้œ€ๅ…ฌๅผ€ๅฏๆ‹‰ๅ–๏ผŒๆˆ–ไฝฟ็”จ็งๆœ‰ไป“ๅบ“๏ผ‰ | +| `allowed_hosts` | Agent ๅฃฐๆ˜Žไผš่ฎฟ้—ฎ็š„ๅŸŸๅๅˆ—่กจ๏ผˆ็™ฝๅๅ•๏ผ‰ | +| `allowed_rpc_endpoints` | Agent ๅฃฐๆ˜Žไผšไฝฟ็”จ็š„ RPC ็ซฏ็‚น | + +**้‡่ฆ**๏ผšๆฒ™็ฎฑไผšๅผบๅˆถ็ฝ‘็ปœ้š”็ฆปใ€‚่ฎฟ้—ฎๆœชๅฃฐๆ˜Ž็š„ๅŸŸๅ โ†’ ๅฎก่ฎกๅคฑ่ดฅ๏ผˆ`UNDECLARED_EGRESS`๏ผ‰ใ€‚ๅฃฐๆ˜Žไบ†ไฝ†ๆฒก่ฎฟ้—ฎ โ†’ ๅฏ่ƒฝ่งฆๅ‘ `ACTION_MISMATCH`ใ€‚ + +ๅฐ† manifest ๆ–‡ไปถไธŠไผ ๅˆฐๅ…ฌๅผ€ๅฏ่ฎฟ้—ฎ็š„ URL๏ผˆๅฆ‚ GitHub raw ้“พๆŽฅใ€ๅฏน่ฑกๅญ˜ๅ‚จ็ญ‰๏ผ‰ใ€‚ + +### 2.2 ๆž„ๅปบ Docker ้•œๅƒ + +ไฝ ็š„ Docker ้•œๅƒ้œ€่ฆ๏ผš + +- ็›‘ๅฌ **8080 ็ซฏๅฃ** +- ๅฎž็Žฐไธคไธช HTTP ๆŽฅๅฃ๏ผˆ่งไธ‹ๆ–‡๏ผ‰ +- ๅปบ่ฎฎไฝฟ็”จ Alpine ๅŸบ็ก€้•œๅƒไปฅๅ‡ๅฐไฝ“็งฏ + +**Dockerfile ็คบไพ‹**๏ผˆNode.js๏ผ‰๏ผš + +```dockerfile +FROM node:20-alpine +RUN apk add --no-cache iptables curl +WORKDIR /app +COPY . /app +EXPOSE 8080 +CMD ["node", "server.js"] +``` + +**Dockerfile ็คบไพ‹**๏ผˆPython๏ผ‰๏ผš + +```dockerfile +FROM python:3.11-alpine +RUN apk add --no-cache iptables curl +WORKDIR /app +COPY . /app +EXPOSE 8080 +CMD ["python", "server.py"] +``` + +### 2.3 ๅฎž็Žฐไธคไธช HTTP ๆŽฅๅฃ + +#### ๆŽฅๅฃ 1๏ผšๅฅๅบทๆฃ€ๆŸฅ โ€” `GET /audit/health` + +ๆฒ™็ฎฑๅฏๅŠจๅฎนๅ™จๅŽไผšๅ…ˆๆŽขๆต‹ๆญคๆŽฅๅฃ๏ผˆๆœ€ๅคš 5 ๆฌก๏ผŒๆฏๆฌก้—ด้š” 500ms๏ผ‰ใ€‚ + +**่ฏทๆฑ‚**๏ผš`GET /audit/health` + +**ๆˆๅŠŸๅ“ๅบ”**๏ผˆHTTP 200๏ผ‰๏ผš + +```json +{ "status": "ok" } +``` + +ๅคฑ่ดฅๆˆ–่ถ…ๆ—ถ โ†’ ๅฎก่ฎกไธญๆญข๏ผŒ็ป“ๆžœไธบ `AGENT_UNAVAILABLE`ใ€‚ + +#### ๆŽฅๅฃ 2๏ผšๅฎก่ฎกไฝœ็ญ” โ€” `POST /audit/solve` + +ๅฎก่ฎก็ณป็ปŸๅ‘้€ๅฎก่ฎก้ข˜็›ฎ๏ผŒAgent ้œ€่ฆๅœจ **30 ็ง’ๅ†…** ่ฟ”ๅ›ž JSON ๅ“ๅบ”ใ€‚ + +**่ฏทๆฑ‚**๏ผˆHTTP POST๏ผŒContent-Type: application/json๏ผ‰๏ผš + +```json +{ + "task_id": "audit-12345", + "question": "Audit the declared agent behavior. Answer each question below...\n\n[q1] (security) Does the agent...\n[q2] (functionality) Can the agent...", + "context": { + "current_block": 1234, + "history": [ + { "role": "system", "content": "This is an automated audit session..." } + ] + }, + "constraints": { + "response_format": "json" + } +} +``` + +| ๅญ—ๆฎต | ่ฏดๆ˜Ž | +|------|------| +| `task_id` | ๆœฌๆฌกๅฎก่ฎก็š„ๅ”ฏไธ€ ID | +| `question` | ๅฎก่ฎก้—ฎ้ข˜ๆ–‡ๆœฌ๏ผˆ็”ฑ LLM ๅŠจๆ€็”Ÿๆˆ๏ผŒๅŒ…ๅซๅคšไธชๅญ้—ฎ้ข˜๏ผ‰ | +| `context.history` | ๅฏน่ฏไธŠไธ‹ๆ–‡๏ผˆๅฏ่ƒฝๅŒ…ๅซ system ๆถˆๆฏ๏ผ‰ | +| `constraints.response_format` | ๅ›บๅฎšไธบ `"json"` | + +**ๅ“ๅบ”**๏ผˆHTTP 200๏ผ‰๏ผš + +```json +{ + "answer": "Based on my analysis:\n[q1] The agent correctly validates... DECISION: undetermined", + "actions": [ + { + "type": "web_request", + "url": "https://api.hermes.io/data", + "method": "GET" + }, + { + "type": "rpc_call", + "url": "https://rpc.polygon.edge.io", + "method": "eth_blockNumber", + "params": [] + } + ], + "reasoning_summary": "Evaluated all 5 audit questions...", + "usage": { "tokens": 1500 } +} +``` + +| ๅญ—ๆฎต | ๅฟ…ๅกซ | ่ฏดๆ˜Ž | +|------|------|------| +| `answer` | ๆ˜ฏ | ๆ–‡ๅญ—ๅ›ž็ญ”๏ผŒๅบ”้’ˆๅฏนๆฏไธชๅฎก่ฎกๅญ้—ฎ้ข˜ไฝœ็ญ” | +| `actions` | ๆ˜ฏ | Agent ๅฃฐๆ˜Žๆ‰ง่กŒ็š„ๅŠจไฝœๅˆ—่กจ๏ผˆไผšไธŽๅฎž้™…็ฝ‘็ปœ่กŒไธบไบคๅ‰้ชŒ่ฏ๏ผ‰ | +| `reasoning_summary` | ๅฆ | ๆŽจ็†ๆ‘˜่ฆ | +| `usage` | ๅฆ | Token ๆˆ–่ต„ๆบๆถˆ่€—ไฟกๆฏ | + +**answer ไธญ้œ€่ฆๅŒ…ๅซๅ†ณ็ญ–ๆ ‡่ฎฐ**๏ผˆDECISION ่กŒ๏ผ‰๏ผš + +``` +DECISION: undetermined โ† ๆ— ๆณ•ๅˆคๆ–ญ +DECISION: ordinary_failure โ† ๆ™ฎ้€šๅคฑ่ดฅ +DECISION: redline_violation โ† ็บข็บฟ่ฟ่ง„๏ผˆไผš่งฆๅ‘ slash๏ผ‰ +``` + +### 2.4 ่ต„ๆบ้™ๅˆถ + +ๆฒ™็ฎฑๅฏนๅฎนๅ™จๆ–ฝๅŠ ไปฅไธ‹้™ๅˆถ๏ผš + +| ่ต„ๆบ | ้™ๅˆถ | +|------|------| +| ๅ†…ๅญ˜ | 512 MB | +| CPU | 1 ๆ ธ | +| ่ฟ›็จ‹ๆ•ฐ | 128 | +| ไธดๆ—ถๆ–‡ไปถ็ฉบ้—ด | 64 MB๏ผˆ/tmp๏ผŒไธๅฏๆ‰ง่กŒ๏ผ‰ | +| ๆ–‡ไปถ็ณป็ปŸ | ๅช่ฏป๏ผˆ้™ค /tmp๏ผ‰ | +| ๅ“ๅบ”่ถ…ๆ—ถ | 30 ็ง’ | + +่ถ…้™ โ†’ ๅฎก่ฎกๅคฑ่ดฅ๏ผŒๆ‰ฃๅˆ†ใ€‚ + +--- + +## 3. ๅฎŒๆ•ดๅ‚่€ƒๅฎž็Žฐ + +ไธ‹้ขๆ˜ฏไธ€ไธชๆœ€ๅฐๅฏๅฎก่ฎก Agent ็š„ๅฎŒๆ•ดๅฎž็Žฐ๏ผˆNode.js๏ผ‰๏ผŒๅฏ็›ดๆŽฅๅคๅˆถไฝฟ็”จ๏ผš + +### server.js + +```javascript +const http = require("http"); + +const PORT = 8080; + +function writeJson(res, statusCode, body) { + res.statusCode = statusCode; + res.setHeader("content-type", "application/json"); + res.end(JSON.stringify(body) + "\n"); +} + +function readBody(req) { + return new Promise((resolve, reject) => { + const chunks = []; + req.on("data", (chunk) => chunks.push(chunk)); + req.on("end", () => { + try { + const raw = Buffer.concat(chunks).toString("utf8"); + resolve(raw.length > 0 ? JSON.parse(raw) : {}); + } catch (e) { + reject(e); + } + }); + req.on("error", reject); + }); +} + +const server = http.createServer(async (req, res) => { + // ๅฅๅบทๆฃ€ๆŸฅ + if (req.method === "GET" && req.url === "/audit/health") { + writeJson(res, 200, { status: "ok" }); + return; + } + + // ๅฎก่ฎกไฝœ็ญ” + if (req.method === "POST" && req.url === "/audit/solve") { + try { + const payload = await readBody(req); + + // ---- ๅœจ่ฟ™้‡ŒๆŽฅๅ…ฅไฝ ็š„ Agent ้€ป่พ‘ ---- + // ่งฃๆž payload.question ไธญ็š„ๅฎก่ฎก้ข˜็›ฎ + // ่ฐƒ็”จ Agent ็š„ๆ ธๅฟƒ่ƒฝๅŠ›๏ผˆAPI ่ฐƒ็”จใ€้“พไธŠๆŸฅ่ฏข็ญ‰๏ผ‰ + // ๆ”ถ้›† Agent ๆ‰ง่กŒ็š„ actions + + writeJson(res, 200, { + answer: `Agent processed task ${payload.task_id}. DECISION: undetermined`, + actions: [ + // ๅฃฐๆ˜Ž Agent ๅฎž้™…ๆ‰ง่กŒ็š„ๅค–้ƒจ่ฏทๆฑ‚ + // { type: "web_request", url: "https://api.example.com/data", method: "GET" } + ], + reasoning_summary: "Minimal agent response" + }); + } catch (err) { + writeJson(res, 400, { error: err.message || "invalid request" }); + } + return; + } + + writeJson(res, 404, { error: "not found" }); +}); + +server.listen(PORT, "0.0.0.0", () => { + console.log(`Agent listening on port ${PORT}`); +}); +``` + +### Dockerfile + +```dockerfile +FROM node:20-alpine +RUN apk add --no-cache iptables curl +WORKDIR /app +COPY server.js /app/server.js +EXPOSE 8080 +CMD ["node", "server.js"] +``` + +### manifest.json + +```json +{ + "agent_name": "my-test-agent", + "image": "my-registry.com/my-test-agent:latest", + "allowed_hosts": [], + "allowed_rpc_endpoints": [] +} +``` + +### ๆž„ๅปบๅนถๆŽจ้€ + +```bash +docker build -t my-registry.com/my-test-agent:latest . +docker push my-registry.com/my-test-agent:latest +``` + +--- + +## 4. ๆไบคๅฎก่ฎกๆต็จ‹ + +### ๆ–นๅผไธ€๏ผš้€š่ฟ‡ๅˆ็บฆ่ฐƒ็”จ๏ผˆๆญฃๅผๆต็จ‹๏ผ‰ + +ไฝฟ็”จ `cast`๏ผˆFoundry ๅทฅๅ…ท๏ผ‰ๆˆ–ไปปไฝ•ไปฅๅคชๅŠๅฎขๆˆท็ซฏ่ฐƒ็”จๅˆ็บฆ๏ผš + +```bash +# ่ดจๆŠผๅนถ่งฆๅ‘ๅฎก่ฎก +cast send \ + --rpc-url http://203.91.76.159:18545 \ + --private-key $YOUR_PRIVATE_KEY \ + --value 1.01ether \ + 0xa513E6E4b8f2a923D98304ec87F64353C4D5C853 \ + "stake(string,string)" \ + "hermes-agent" \ + "https://raw.githubusercontent.com/your-org/your-repo/main/manifest.json" +``` + +| ๅ‚ๆ•ฐ | ่ฏดๆ˜Ž | +|------|------| +| `--value` | ่ดจๆŠผ้‡‘้ข๏ผˆ>= serviceFee 0.01 ETH + minimumBond 1 ETH๏ผ‰ | +| ็ฌฌไธ€ไธชๅญ—็ฌฆไธฒๅ‚ๆ•ฐ | Agent ๅ็งฐ๏ผˆๅฟ…้กปไธŽ manifest ไธญ `agent_name` ไธ€่‡ด๏ผ‰ | +| ็ฌฌไบŒไธชๅญ—็ฌฆไธฒๅ‚ๆ•ฐ | Manifest ๆ–‡ไปถ็š„ๅ…ฌๅผ€ URL | + +่ฐƒ็”จๆˆๅŠŸๅŽ๏ผš +1. ๅˆ็บฆ้“ธ้€  NFT๏ผŒๅ‘ๅ‡บ `AuditRequested` ไบ‹ไปถ +2. ๅฎก่ฎก็›‘ๅฌๅ™จ่‡ชๅŠจๆฃ€ๆต‹ๅˆฐไบ‹ไปถ +3. ๆ‹‰ๅ– manifest โ†’ ๆ‹‰ๅ– Docker ้•œๅƒ โ†’ ๅฏๅŠจๆฒ™็ฎฑ โ†’ ๆ‰ง่กŒๅฎก่ฎก +4. ็ป“ๆžœ่‡ชๅŠจๅ†™ๅ›ž้“พไธŠ + +### ๆ–นๅผไบŒ๏ผšๆœฌๅœฐ E2E ๆต‹่ฏ•๏ผˆๅผ€ๅ‘่ฐƒ่ฏ•็”จ๏ผ‰ + +```bash +cd infra/polygon-edge-local +bash scripts/run-local-e2e.sh +``` + +ๆญค่„šๆœฌไผš่‡ชๅŠจๅฏๅŠจๆœฌๅœฐ้“พใ€้ƒจ็ฝฒๅˆ็บฆใ€ๆ‰ง่กŒๅฎŒๆ•ดๅฎก่ฎกๆต็จ‹ใ€‚ + +--- + +## 5. ๆŸฅ็œ‹ๅฎก่ฎก็ป“ๆžœ + +### ๅ‰็ซฏ้กต้ข + +ๆต่งˆๅ™จ่ฎฟ้—ฎ๏ผš`http://203.91.76.159`๏ผˆ็”Ÿไบง็Žฏๅขƒๅ‰็ซฏ๏ผ‰ + +- ้ฆ–้กต๏ผšๆ‰€ๆœ‰ๅทฒๆณจๅ†Œ Agent ๅˆ—่กจ +- `/agent/:tokenId`๏ผšAgent ่ฏฆๆƒ… + ๅฎก่ฎกๅކๅฒ +- `/agent/:tokenId/audits/:auditId/:index`๏ผšๅ•ๆฌกๅฎก่ฎก็š„ๅฎŒๆ•ดๆŠฅๅ‘Š + - ๅŒ…ๅซ๏ผšLLM ๅฎก่ฎก้ข˜็›ฎใ€ๆฒ™็ฎฑๆ‰ง่กŒๆ—ถ้—ด็บฟใ€Agent ๅ“ๅบ”ใ€็ฝ‘็ปœ่กŒไธบใ€่ต„ๆบๆถˆ่€—ใ€่กŒไธบๅฏน่ดฆ + +### ๅˆ็บฆๆŸฅ่ฏข + +```bash +# ๆŸฅ่ฏข Agent ๆœ€ๆ–ฐๅฎก่ฎก็ป“ๆžœ +cast call \ + --rpc-url http://203.91.76.159:18545 \ + 0xa513E6E4b8f2a923D98304ec87F64353C4D5C853 \ + "getLatestAudit(uint256)" \ + 1 # tokenId +``` + +--- + +## 6. ๅฎก่ฎก็ป“ๆžœ่งฃ่ฏป + +### ๅฎก่ฎก็Šถๆ€ + +| ็Šถๆ€ | ๅซไน‰ | +|------|------| +| **Passed** | ๅฎก่ฎก้€š่ฟ‡๏ผŒAgent ่กŒไธบ็ฌฆๅˆๅฃฐๆ˜Ž | +| **Failed** | ๅฎก่ฎกๅคฑ่ดฅ๏ผˆ่ต„ๆบ่ถ…้™ใ€ๅ่ฎฎ่ฟ่ง„็ญ‰๏ผ‰ | +| **Slashed** | ็บข็บฟ่ฟ่ง„๏ผŒ่ดจๆŠผ้‡‘่ขซๆ‰ฃ็ฝš | + +### ๅธธ่งๅคฑ่ดฅๅŽŸๅ›  + +| ๅŽŸๅ› ็  | ๅซไน‰ | ไฟฎๅคๅปบ่ฎฎ | +|--------|------|---------| +| `IMAGE_PULL_FAILED` | ้•œๅƒๆ‹‰ๅ–ๅคฑ่ดฅ | ๆฃ€ๆŸฅ้•œๅƒๅœฐๅ€ๅ’Œๆƒ้™ | +| `AGENT_UNAVAILABLE` | ๅฅๅบทๆฃ€ๆŸฅๅคฑ่ดฅ | ็กฎไฟ 8080 ็ซฏๅฃ็›‘ๅฌไธ” `/audit/health` ่ฟ”ๅ›žๆญฃ็กฎ | +| `PROTOCOL_VIOLATION` | `/audit/solve` ๅ“ๅบ”ๆ ผๅผ้”™่ฏฏ | ๆฃ€ๆŸฅ่ฟ”ๅ›ž JSON ๆ ผๅผ | +| `UNDECLARED_EGRESS` | ่ฎฟ้—ฎไบ†ๆœชๅฃฐๆ˜Ž็š„ๅŸŸๅ | ๅœจ manifest `allowed_hosts` ไธญๆทปๅŠ  | +| `ACTION_MISMATCH` | ๅฃฐๆ˜Ž็š„ actions ไธŽๅฎž้™…็ฝ‘็ปœ่กŒไธบไธ็ฌฆ | ็กฎไฟ `actions` ๆ•ฐ็ป„ๅฆ‚ๅฎžๅๆ˜ ็ฝ‘็ปœ่ฏทๆฑ‚ | +| `MEMORY_LIMIT_EXCEEDED` | ๅ†…ๅญ˜่ถ…่ฟ‡ 512 MB | ไผ˜ๅŒ–ๅ†…ๅญ˜ไฝฟ็”จ | +| `CPU_LIMIT_EXCEEDED` | CPU ่ถ…้™ | ไผ˜ๅŒ–่ฎก็ฎ—้€ป่พ‘ | +| `MANIFEST_NAME_MISMATCH` | manifest ไธญ agent_name ไธŽ้“พไธŠไธไธ€่‡ด | ็กฎไฟไธคๅค„ๅ็งฐๅฎŒๅ…จ็›ธๅŒ | + +--- + +## 7. ้’ˆๅฏนไธปๆต Agent ็š„้€‚้…ๆ€่ทฏ + +ๅฏนไบŽ Hermesใ€OpenClawใ€Manus ็ญ‰ๅทฒๆœ‰็š„ Agent ไบงๅ“๏ผŒๅฎƒไปฌ้€šๅธธไธไผšๅŽŸ็”Ÿๆ”ฏๆŒ `/audit/health` ๅ’Œ `/audit/solve` ๆŽฅๅฃใ€‚้œ€่ฆๆž„ๅปบไธ€ไธช **ๅฎก่ฎก้€‚้…ๅฑ‚**๏ผˆAdapter๏ผ‰๏ผš + +``` +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ ๅฎก่ฎก้€‚้…ๅฎนๅ™จ โ”‚ +โ”‚ โ”‚ +โ”‚ /audit/health โ†’ ่ฟ”ๅ›ž { status: ok } โ”‚ +โ”‚ โ”‚ +โ”‚ /audit/solve โ†’ ๆŽฅๆ”ถๅฎก่ฎก้ข˜็›ฎ โ”‚ +โ”‚ โ†“ ่ฝฌๆขไธบ Agent ๅŽŸ็”Ÿ่ฐƒ็”จๆ ผๅผ โ”‚ +โ”‚ โ†“ ่ฐƒ็”จ Agent ๆ ธๅฟƒ API โ”‚ +โ”‚ โ†“ ๆ”ถ้›†ๅ“ๅบ”ๅ’Œ actions โ”‚ +โ”‚ โ†“ ่ฟ”ๅ›žๅฎก่ฎกๆ ‡ๅ‡†ๅ“ๅบ”ๆ ผๅผ โ”‚ +โ”‚ โ”‚ +โ”‚ ๅ†…้ƒจไพ่ต–: Agent SDK / API Client โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +``` + +### ็คบไพ‹๏ผš้€‚้… Manus Agent + +ๅ‡่ฎพ Manus ๆไพ›ไบ† HTTP API `POST https://api.manus.ai/v1/chat`๏ผš + +```javascript +// ๅœจ /audit/solve ๅค„็†ๅ‡ฝๆ•ฐไธญ +async function handleSolve(auditRequest) { + // 1. ๆŠŠๅฎก่ฎก้ข˜็›ฎ่ฝฌๆขไธบ Manus ็š„่ฏทๆฑ‚ๆ ผๅผ + const manusResponse = await fetch("https://api.manus.ai/v1/chat", { + method: "POST", + headers: { + "Authorization": `Bearer ${process.env.MANUS_API_KEY}`, + "Content-Type": "application/json" + }, + body: JSON.stringify({ + messages: [{ role: "user", content: auditRequest.question }] + }) + }); + const result = await manusResponse.json(); + + // 2. ่ฟ”ๅ›žๅฎก่ฎกๆ ‡ๅ‡†ๆ ผๅผ + return { + answer: result.choices[0].message.content + "\nDECISION: undetermined", + actions: [ + { type: "web_request", url: "https://api.manus.ai/v1/chat", method: "POST" } + ] + }; +} +``` + +ๅฏนๅบ” manifest ้œ€่ฆๅฃฐๆ˜Ž `allowed_hosts: ["api.manus.ai"]`ใ€‚ + +--- + +## 8. ๅฟซ้€Ÿ้ชŒ่ฏๆฃ€ๆŸฅๆธ…ๅ• + +ๅœจๆญฃๅผๆไบคๅฎก่ฎกๅ‰๏ผŒ็กฎ่ฎคไปฅไธ‹้กน็›ฎ๏ผš + +- [ ] Docker ้•œๅƒๆž„ๅปบๆˆๅŠŸไธ”ๅทฒๆŽจ้€ๅˆฐๅฏ่ฎฟ้—ฎ็š„ไป“ๅบ“ +- [ ] `docker run -p 8080:8080 your-image` ๅŽๅฎนๅ™จๆญฃๅธธๅฏๅŠจ +- [ ] `curl http://localhost:8080/audit/health` ่ฟ”ๅ›ž `{"status":"ok"}` +- [ ] `curl -X POST http://localhost:8080/audit/solve -H 'Content-Type: application/json' -d '{"task_id":"test","question":"hello","context":{"history":[]},"constraints":{"response_format":"json"}}'` ่ฟ”ๅ›žๅˆๆณ• JSON๏ผˆๅŒ…ๅซ `answer` ๅ’Œ `actions` ๅญ—ๆฎต๏ผ‰ +- [ ] Manifest ๆ–‡ไปถๅทฒไธŠไผ ๅˆฐๅ…ฌๅผ€ URL ๅนถๅฏ่ฎฟ้—ฎ +- [ ] Manifest ไธญ `agent_name` ไธŽๅ‡†ๅค‡ๆณจๅ†Œ็š„ๅ็งฐไธ€่‡ด +- [ ] Manifest ไธญ `image` ไธŽๆŽจ้€็š„้•œๅƒๅœฐๅ€ไธ€่‡ด +- [ ] Manifest ไธญ `allowed_hosts` ๅŒ…ๅซไบ† Agent ไผš่ฎฟ้—ฎ็š„ๆ‰€ๆœ‰ๅŸŸๅ + +--- + +## 9. ้“พไฟกๆฏ + +| ้กน็›ฎ | ๅ€ผ | +|------|-----| +| RPC URL | `http://203.91.76.159:18545` | +| Chain ID | `302612` | +| ๅˆ็บฆๅœฐๅ€ | `0xa513E6E4b8f2a923D98304ec87F64353C4D5C853` | +| serviceFee | 0.01 ETH | +| minimumBond | 1 ETH | +| ๅ‰็ซฏ | `http://203.91.76.159` | + +### ่Žทๅ–ๆต‹่ฏ• ETH + +ๆœฌๆต‹่ฏ•้“พไฝฟ็”จ้ข„็ฝฎ่ดฆๆˆทใ€‚ๅฆ‚้œ€ๆต‹่ฏ•่ดฆๆˆทๅ’Œ ETH๏ผŒ่ฏท่”็ณปๆˆ‘ไปฌๆไพ›ใ€‚ diff --git a/docs/popo-icon.png b/docs/popo-icon.png new file mode 100644 index 0000000..2b4ea53 Binary files /dev/null and b/docs/popo-icon.png differ diff --git a/docs/screenshots/01-homepage-hero.png b/docs/screenshots/01-homepage-hero.png new file mode 100644 index 0000000..15c4efc Binary files /dev/null and b/docs/screenshots/01-homepage-hero.png differ diff --git a/docs/screenshots/02-leaderboard.png b/docs/screenshots/02-leaderboard.png new file mode 100644 index 0000000..477f68d Binary files /dev/null and b/docs/screenshots/02-leaderboard.png differ diff --git a/docs/screenshots/03-agent-cards.png b/docs/screenshots/03-agent-cards.png new file mode 100644 index 0000000..e2f1067 Binary files /dev/null and b/docs/screenshots/03-agent-cards.png differ diff --git a/docs/screenshots/04-claude-agent-profile.png b/docs/screenshots/04-claude-agent-profile.png new file mode 100644 index 0000000..fc75760 Binary files /dev/null and b/docs/screenshots/04-claude-agent-profile.png differ diff --git a/docs/screenshots/05-radar-and-scenes.png b/docs/screenshots/05-radar-and-scenes.png new file mode 100644 index 0000000..3e79824 Binary files /dev/null and b/docs/screenshots/05-radar-and-scenes.png differ diff --git a/docs/screenshots/06-trust-guarantee.png b/docs/screenshots/06-trust-guarantee.png new file mode 100644 index 0000000..3e79824 Binary files /dev/null and b/docs/screenshots/06-trust-guarantee.png differ diff --git a/docs/screenshots/07-latest-audit-summary.png b/docs/screenshots/07-latest-audit-summary.png new file mode 100644 index 0000000..02190fa Binary files /dev/null and b/docs/screenshots/07-latest-audit-summary.png differ diff --git a/docs/screenshots/08-audit-history-reviews.png b/docs/screenshots/08-audit-history-reviews.png new file mode 100644 index 0000000..46ead67 Binary files /dev/null and b/docs/screenshots/08-audit-history-reviews.png differ diff --git a/docs/status/2026-04-16-tee-loop-tasks.md b/docs/status/2026-04-16-tee-loop-tasks.md new file mode 100644 index 0000000..e21134d --- /dev/null +++ b/docs/status/2026-04-16-tee-loop-tasks.md @@ -0,0 +1,273 @@ +# TEE ็”Ÿไบง้—ญ็Žฏ 12 ้กนไปปๅŠกๅฎŒๆˆๆธ…ๅ• โ€” 2026-04-16 + +## ๆ€ป่งˆ + +ๆœฌๆฌกไบคไป˜ๅฎŒๆˆ **SGX DCAP v3 attestation ็”Ÿไบง้“พ่ทฏ็ซฏๅˆฐ็ซฏ้—ญ็Žฏ**๏ผŒไปŽ listener ่ฐƒ็”จ SGX +Attestation API ๅˆฐ `attestationHash` ไธŠ้“พใ€ๅ‰็ซฏ UI ๅฑ•็คบ๏ผŒๅฝขๆˆๅฎŒๆ•ดไฟกไปป้“พใ€‚ + +| ็ปดๅบฆ | ๅ€ผ | +|------|-----| +| ่ฎกๅˆ’้กนๆ€ปๆ•ฐ | 13 | +| ๅทฒๅฎŒๆˆ | **12** | +| ๅฏ้€‰ๆœชๅš | 1๏ผˆ#12 SGX ๅฎ•ๆœบ้™็บง็ญ–็•ฅ๏ผŒๅทฒๆœ‰ๅค‡ๅฟ˜๏ผ‰ | +| ๅ›žๅฝ’ๆˆๅŠŸ็އ | **10/10** | +| ็ซฏๅˆฐ็ซฏไธญไฝๆ•ฐ่€—ๆ—ถ | 18.25 s | +| p95 ่€—ๆ—ถ | 18.66 s | + +--- + +## ๅฎŒๆˆๆธ…ๅ• + +### #1 ไฟฎๅค listener V2 writeback calldata ็ผ–็  + +**้—ฎ้ข˜**๏ผš็”Ÿไบง listener ๅ‘ V2 ๅˆ็บฆๅ†™ๅ›žๆ—ถไฝฟ็”จ V1 ็š„ `recordAuditResult` selector๏ผŒ่งฆๅ‘ +"unknown selector" revertใ€‚ + +**่งฃๅ†ณ**๏ผš +- ๆ–ฐๅขž V2 ABI ๅŠ ่ฝฝ๏ผš`sandbox/src/listener/auditRegistryArtifact.ts` +- ๅˆ‡ๆขๅ†™ๅ›žๅ…ฅๅฃไธบ `recordAuditResultV2(tokenId, score, manifestHash, reportHash, reportCID, attestationHash, DimensionalScores)` +- ่กฅๅ……ๅ•ๅ…ƒๆต‹่ฏ• `sandbox/tests/listener/writeAuditResult.test.ts` + +**ไบคไป˜ commit**๏ผš`9240efb feat(sandbox): enforce MRENCLAVE pin and fix V2 writeback calldata` + +--- + +### #2 ็กฎ่ฎคๅนถๅˆ‡ๆข็”Ÿไบง็Žฏๅขƒๅˆ็บฆๅœฐๅ€ๅˆฐ V2 + +**ๅŠจไฝœ**๏ผš +- `AUDIT_REGISTRY_ADDRESS`๏ผš`0xa513...C853` (V1) โ†’ `0x4A67...5319` (V2) +- ๆ–ฐๅขž `AUDIT_REGISTRY_V2_ADDRESS` ๆ”ฏๆŒ็”ณ่ฏ‰้“พไธŠๅ†™ๅ…ฅ (`APPEAL_CHAIN_WRITER_ENABLED=true`) +- ๆ›ดๆ–ฐ `infra/production/.env.example` ็คบๆ„ไธค่€…ๅฏๆŒ‡ๅ‘ๅŒไธ€ V2 ๅˆ็บฆ +- ๆ ธๅฏน `memory/deployment.md` ไธญๅˆ‡ๆขๆณจๆ„ไบ‹้กน + +**ไบคไป˜ commit**๏ผš`279ec99 feat(infra): add standalone attestation service and production TEE E2E scripts` + +--- + +### #3 ๆ‰“ๅŒ… Attestation API ๆœๅŠก Docker ้•œๅƒไธŽ็‹ฌ็ซ‹ compose + +**ไบงๅ‡บ**๏ผš`infra/attestation/` +- `Dockerfile`๏ผˆๅŸบไบŽ Gramine 1.9 + Node.js 20๏ผ‰ +- `docker-compose.yml`๏ผˆ็‹ฌ็ซ‹้ƒจ็ฝฒๅˆฐ SGX ๅฎฟไธป๏ผ‰ +- `entrypoint.sh`๏ผˆgramine-sgx ๅŒ…่ฃ… + signing ๆต็จ‹๏ผ‰ +- `README.md`๏ผˆๅฎŒๆ•ดๆ“ไฝœๆ–‡ๆกฃ๏ผ‰ +- `.env.example`๏ผˆๆœๅŠก้…็ฝฎ็คบไพ‹๏ผ‰ + +**ไบคไป˜ commit**๏ผš`279ec99` + `874168e chore(infra): add attestation service env example` + +--- + +### #4 M6ce ๆœๅŠกๅ™จๆž„ๅปบ Gramine SGX enclave ๅนถ่ฎฐๅฝ• MRENCLAVE + +**ๅŠจไฝœ**๏ผš +- ๅœจ M6ce (`43.134.90.165`) ๆ‰ง่กŒ `make SGX=1`๏ผŒ็”Ÿๆˆ `generate-quote.manifest.sgx` +- ่ฎฐๅฝ• MRENCLAVE๏ผš`1656d0e5f1dbac0e687662f79b8b5bf8629e40224567ecb823d1eb409f0b16b8` +- ่ฏฅๅ€ผไฝœไธบ็”Ÿไบง listener + ๅ‰็ซฏๅ…ฑๅŒ pin ็š„้”š็‚น + +**้ƒจ็ฝฒๆ–‡ๆกฃ**๏ผš`infra/attestation/README.md` + `memory/servers.md#1-tencent-cloud-m6ce` + +--- + +### #5 M6ce ๅฏๅŠจ Attestation API ๆœๅŠก๏ผˆcommand mode๏ผ‰ + +**ๅฏๅŠจๅ‚ๆ•ฐ**๏ผš +```bash +AUDIT_ATTESTATION_SERVICE_PROVIDER_MODE=command +AUDIT_ATTESTATION_COMMAND=/home/ubuntu/agent-shenji-sgx/run-quote.sh +AUDIT_ATTESTATION_COMMAND_PROVIDER_TYPE=sgx-dcap +AUDIT_ATTESTATION_SERVICE_HOST=0.0.0.0 +AUDIT_ATTESTATION_SERVICE_PORT=3311 +``` + +**้ชŒ่ฏ**๏ผš`curl http://43.134.90.165:3311/attest` ่ฟ”ๅ›ž้ž้›ถ quoteใ€‚ + +--- + +### #6 ๆ‰“้€š็”Ÿไบงๆœบ โ†” M6ce ็š„็ฝ‘็ปœไธŽ้‰ดๆƒ + +**ๅŠจไฝœ**๏ผš +- ๅผ€ๆ”พ M6ce ๅฎ‰ๅ…จ็ป„ `3311` ็ซฏๅฃ๏ผˆ2026-04-11๏ผ‰ +- ็”Ÿไบงๆœบ (`203.91.76.159`) ็›ด่ฟž M6ce ๆ— ไปฃ็† +- listener `AUDIT_ATTESTATION_API_URL=http://43.134.90.165:3311/attest` ็”Ÿๆ•ˆ + +--- + +### #7 ็ป™็”Ÿไบง listener ้…็ฝฎ attestation ๅฎขๆˆท็ซฏ็Žฏๅขƒๅ˜้‡ + +**ๆ–ฐๅขž listener ็Žฏๅขƒๅ˜้‡**๏ผˆๅ…จ้ƒจๅœจ็”Ÿไบง `.env` ไธญ่ฝๅœฐ๏ผ‰๏ผš + +| ๅ˜้‡ | ๅ€ผ | +|------|-----| +| `AUDIT_ATTESTATION_API_URL` | `http://43.134.90.165:3311/attest` | +| `AUDIT_ATTESTATION_PROVIDER_TYPE` | `sgx-dcap-v3-gramine` | +| `AUDIT_ATTESTATION_EXPECTED_PROVIDER_TYPE` | `sgx-dcap` | +| `AUDIT_ATTESTATION_EXPECTED_MEASUREMENT` | `1656d0e5โ€ฆ0b16b8` | +| `AUDIT_ATTESTATION_EXPECTED_QUOTE_FORMAT` | `sgx-dcap-v3` | +| `AUDIT_ATTESTATION_VERIFY_REPORT_DATA_BINDING` | `true` | + +**Online ๆ ก้ชŒ**๏ผˆๅœจ `sandbox/src/attestation/httpAttestationClient.ts` ไธญๅฎž็Žฐ๏ผ‰๏ผš +- ๆฏๆฌก `/attest` ๅ“ๅบ”้ƒฝ็”จ `buildPerRequestQuoteValidator()` ็ป„ๅˆ + `ExpectedFieldValidator + SgxDcapQuoteValidator` +- ๅผบๅˆถ `report_data == sha256(eventKey โ€– manifestHash โ€– evidenceRoot)` +- ไปปไฝ•ไธๅŒน้…ไผš่ฎฉ audit ๅคฑ่ดฅ + `attestationHash=bytes32(0)` + +**ไบคไป˜ commit**๏ผš`9240efb` + +--- + +### #8 ๅ‰็ซฏๆ–ฐๅขž Attestation ๆ ก้ชŒๅฑ•็คบ็ป„ไปถ + +**ไบงๅ‡บ**๏ผš +- `frontend/src/components/AttestationBadge.tsx` โ€” ๅฐ badge๏ผˆverified / not attested๏ผ‰ +- `frontend/src/components/AttestationBadge.test.tsx` โ€” 6 vitest ็”จไพ‹ๅ…จ้€š่ฟ‡ +- `frontend/src/components/AttestationVerificationCard.tsx` โ€” ๅฎŒๆ•ด card๏ผˆ้™„ pinned MRENCLAVE๏ผ‰ +- ้›†ๆˆๅˆฐ `LatestAuditSummary.tsx` + `AuditReportPage.tsx` +- `frontend/src/config/appConfig.ts` ๆถˆ่ดน `VITE_AUDIT_ATTESTATION_EXPECTED_*` +- `frontend/src/lib/agentAuditRegistryClient.ts` ่ฏปๅ– V2 `attestationHash` + +**Docker ๆž„ๅปบๆœŸๆณจๅ…ฅ**๏ผš`infra/production/Dockerfile` + `docker-compose.yml` ๅขžๅŠ  4 ไธช +`VITE_AUDIT_ATTESTATION_EXPECTED_*` build-arg๏ผŒ็กฎไฟ MRENCLAVE ็ƒ˜็„™่ฟ› JS bundleใ€‚ + +**ไบคไป˜ commit**๏ผš`987ba79 feat(frontend): add SGX attestation verification UI` + +--- + +### #9 ็ผ–ๅ†™ TEE ็”Ÿไบง้“พ่ทฏ E2E ๅ†’็ƒŸ่„šๆœฌ + +**ไบงๅ‡บ**๏ผš`infra/production/scripts/` +- `run-tee-e2e.sh`๏ผˆๅ•ๆฌกๅ†’็ƒŸ๏ผšstake โ†’ poll โ†’ assert attestationHash != 0๏ผ‰ +- `tee-e2e.env.example`๏ผˆ็Žฏๅขƒๅ˜้‡ๆจกๆฟ๏ผ‰ +- `tee-e2e-summary.example.json`๏ผˆ้ฆ–ๆฌกๆˆๅŠŸๆ ทไพ‹๏ผštokenId=1, attestationHash=`0x2f2a5d4eโ€ฆ`, block=901391๏ผ‰ + +**ๅ…ณ้”ฎๅ‘ไฝ๏ผˆๅทฒไฟฎๅค๏ผ‰**๏ผš +- node heredoc ๅ†… env ๅ˜้‡้œ€ๆ˜พๅผ `export` +- macOS `date +%s%3N` ่ฟ”ๅ›ž้žๆ•ฐๅ€ผ๏ผŒๆ”น็”จ `node -e 'Date.now()'` +- ethers ไป… `frontend/node_modules` ๆœ‰ v6๏ผŒ้€š่ฟ‡ `NODE_PATH` ๆŒ‡ๅ‘ + +**ไบคไป˜ commit**๏ผš`279ec99` + +--- + +### #10 ๆ›ดๆ–ฐ TEE ้ƒจ็ฝฒไธŽไฝฟ็”จๆ–‡ๆกฃ + +**ๆ‰น้‡ๅˆทๆ–ฐ**๏ผš +- `infra/production/README.md` โ€” ๆ–ฐๅขžๅฎŒๆ•ด "SGX TEE Attestation (Production Loop)" ็ซ ่Š‚ +- `docs/verification-methods.md` โ€” ๆ–ฐๅขž "7. ็”Ÿไบง้ƒจ็ฝฒ็Šถๆ€ (2026-04-16)" +- `memory/servers.md` โ€” ๆ›ดๆ–ฐ M6ce + ็”Ÿไบงๆœบ้ƒจ็ฝฒๆƒ…ๅ†ต + TEE ้—ญ็Žฏ pin +- `memory/deployment.md` โ€” ๆ–ฐๅขž attestation ็Žฏๅขƒๅ˜้‡ + ๅ†’็ƒŸๅ‘ฝไปค +- `memory/architecture.md` โ€” ๆ–ฐๅขž "Online ๆ ก้ชŒ๏ผˆlistener ๅ†…่”๏ผ‰" + "ๅ‰็ซฏๅฑ•็คบ" +- `memory/MEMORY.md` โ€” Current Status ๆ–ฐๅขž SGX TEE ้—ญ็Žฏ + +**ไบคไป˜ commit**๏ผš`880ffb0 docs: document production TEE loop and add upline report` + +--- + +### #11 ๅ›žๅฝ’ๆต‹่ฏ•ๅนถ้ชŒ่ฏ TEE ้—ญ็Žฏ็จณๅฎšๆ€ง + +**ไบงๅ‡บ**๏ผš +- `infra/production/scripts/run-tee-regression.sh`๏ผˆๅพช็Žฏ N ๆฌก + ่šๅˆ็ปŸ่ฎก๏ผ‰ +- `infra/production/scripts/regression-20260416-175024/`๏ผˆ10 ร— summary + log + aggregate๏ผ‰ +- `docs/status/2026-04-16-tee-production.md`๏ผˆๅฎŒๆ•ดไธŠ็บฟๆŠฅๅ‘Š๏ผ‰ + +**็ป“ๆžœ**๏ผš + +| ๆŒ‡ๆ ‡ | ๅ€ผ | +|------|-----| +| ่ฟญไปฃ | 10 | +| ๆˆๅŠŸ | **10** | +| ๅคฑ่ดฅ | 0 | +| attestationHash ้ž้›ถๆฌกๆ•ฐ | **10** | +| elapsed ไธญไฝๆ•ฐ | 18251 ms | +| elapsed p95 | 18657 ms | +| tokenId ่Œƒๅ›ด | 3โ€“12๏ผˆ่ฟž็ปญ๏ผ‰ | + +ๆ‰€ๆœ‰ attestationHash ๅ”ฏไธ€ไธ”้ž `bytes32(0)`๏ผŒMRENCLAVE pin ๆ ก้ชŒ้€š่ฟ‡ใ€‚ + +**ไบคไป˜ commit**๏ผš`279ec99` + `880ffb0` + +--- + +### #13 ้ƒจ็ฝฒ listener V2 calldata ไฟฎๅคๅˆฐ็”Ÿไบง็Žฏๅขƒ + +**ๅŠจไฝœ**๏ผš +- rsync ๅŒๆญฅไปฃ็ ๅˆฐ `/root/agent-shenji/`๏ผˆๆŽ’้™ค `.git/node_modules/dist`๏ผ‰ +- ไปŽ่ฟ่กŒๅฎนๅ™จๆขๅค `.env`๏ผˆrsync `--delete` ไผšๅˆ ๏ผ‰ +- `docker compose build --no-cache`๏ผˆ~2min๏ผŒnohup ๅŽๅฐ๏ผ‰ +- `docker compose up -d` ้‡ๅฏ +- ้ชŒ่ฏ 4 ไธช shenji ๅฎนๅ™จๅ…จ้ƒจ healthy +- ้ชŒ่ฏ attestationHash ๆˆๅŠŸไธŠ้“พ๏ผˆTask #11 ็š„ 10 ๆฌกๆˆๅŠŸๅ›žๅฝ’ๅทฒ่ฏๆ˜Ž๏ผ‰ + +--- + +## ่ทณ่ฟ‡๏ผˆๅฏ้€‰๏ผ‰ + +### #12 SGX ๆœบๅฎ•ๆœบๆ—ถ็š„้™็บง็ญ–็•ฅ่ฎพ่ฎก + +**ๅฝ“ๅ‰่กŒไธบ**๏ผš`createAuditAttestation` ๆŠ›ๅผ‚ๅธธ โ†’ audit ่ฟ› retry-queue ๆ— ้™้‡่ฏ•ใ€‚ + +**ๅ€™้€‰ๆ–นๆกˆ**๏ผˆๅทฒ่ฎฐๅ…ฅ `docs/status/2026-04-16-tee-production.md`๏ผ‰๏ผš +1. `AUDIT_ATTESTATION_REQUIRED=strict|optional` ๅผ€ๅ…ณ +2. retry-queue ๆœ€ๅคง้‡่ฏ•ๆฌกๆ•ฐ + `AUDIT_ATTESTATION_UNAVAILABLE` ๅ‘Š่ญฆ +3. M6ce ๅคšๅฎžไพ‹ + health-check ๅˆ‡ๆข + +--- + +## ็”Ÿไบงๆ‹“ๆ‰‘๏ผˆๆœ€็ปˆ๏ผ‰ + +``` +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ 203.91.76.159 (ecs6824 / Tencent Cloud) โ”‚ +โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ +โ”‚ โ”‚ shenji-listener (docker, healthy) โ”‚ โ”‚ +โ”‚ โ”‚ โ†’ httpAttestationClient โ”‚ โ”‚ +โ”‚ โ”‚ โ†’ MRENCLAVE + report_data ๆ ก้ชŒ โ”‚โ”€โ”€โ”ผโ”€โ”€โ” +โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ +โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ +โ”‚ โ”‚ shenji-report-gateway (3310) โ”‚ โ”‚ โ”‚ +โ”‚ โ”‚ shenji-appeal-api (3312) โ”‚ โ”‚ โ”‚ +โ”‚ โ”‚ shenji-frontend (80) โ”‚ โ”‚ โ”‚ +โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ +โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ +โ”‚ โ”‚ polygon-edge-external (18545) โ”‚ โ”‚ โ”‚ +โ”‚ โ”‚ chainId=302612 โ”‚ โ”‚ โ”‚ +โ”‚ โ”‚ V2 Registry 0x4A67โ€ฆ5319 โ”‚ โ”‚ โ”‚ +โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ + โ”‚ HTTP + โ–ผ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ 43.134.90.165 (M6ce / SGX ๅฎฟไธป) โ”‚ +โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ +โ”‚ โ”‚ attestationApi.ts (3311) โ”‚ โ”‚ +โ”‚ โ”‚ โ†’ gramine-sgx ./generate-quote โ”‚ โ”‚ +โ”‚ โ”‚ MRENCLAVE 1656d0e5โ€ฆ0b16b8 โ”‚ โ”‚ +โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +``` + +--- + +## ็›ธๅ…ณ็ดขๅผ• + +| ไธป้ข˜ | ่ทฏๅพ„ | +|------|------| +| ็”Ÿไบง้ƒจ็ฝฒ | `infra/production/README.md` | +| SGX ๆœๅŠก | `infra/attestation/README.md` | +| ้ชŒ่ฏๆ–นๆณ• | `docs/verification-methods.md` | +| ไธŠ็บฟๆŠฅๅ‘Š | `docs/status/2026-04-16-tee-production.md` | +| ๅ›žๅฝ’่„šๆœฌ | `infra/production/scripts/run-tee-regression.sh` | +| ๅ†’็ƒŸ่„šๆœฌ | `infra/production/scripts/run-tee-e2e.sh` | + +--- + +## ๆŽจ้€่ฎฐๅฝ• + +| Commit | ไธป้ข˜ | +|--------|------| +| `9240efb` | feat(sandbox): enforce MRENCLAVE pin and fix V2 writeback calldata | +| `987ba79` | feat(frontend): add SGX attestation verification UI | +| `279ec99` | feat(infra): add standalone attestation service and production TEE E2E scripts | +| `880ffb0` | docs: document production TEE loop and add upline report | +| `874168e` | chore(infra): add attestation service env example | + +ๅทฒๆŽจ้€ๅˆฐ `origin/main`ใ€‚ diff --git a/docs/status/2026-04-16-tee-production.md b/docs/status/2026-04-16-tee-production.md new file mode 100644 index 0000000..da8af27 --- /dev/null +++ b/docs/status/2026-04-16-tee-production.md @@ -0,0 +1,140 @@ +# TEE ็”Ÿไบง้—ญ็ŽฏไธŠ็บฟๆŠฅๅ‘Š โ€” 2026-04-16 + +## ๆ‘˜่ฆ + +ๆœฌๆฌกไธŠ็บฟๅฎŒๆˆไบ† **SGX DCAP v3 attestation ็”Ÿไบง้“พ่ทฏ** ็ซฏๅˆฐ็ซฏ้—ญ็Žฏ๏ผš + +``` +stake() โ†’ AuditRequested โ†’ listener โ†’ SGX Attestation API (Gramine enclave) + โ†’ MRENCLAVE + report_data ๅœจ็บฟๆ ก้ชŒ + โ†’ recordAuditResultV2(..., attestationHash) + โ†’ ๅ‰็ซฏๆ˜พ็คบ verified badge + MRENCLAVE pin +``` + +10 ๆฌกๅ›žๅฝ’ๆต‹่ฏ• **10/10 ๆˆๅŠŸ**๏ผŒattestation ๅ‡ไธŠ้“พ้ž้›ถ๏ผŒ็”Ÿไบง้—ญ็Žฏ็จณๅฎšใ€‚ + +--- + +## ๆ‹“ๆ‰‘ + +| ็ป„ไปถ | ้ƒจ็ฝฒไฝ็ฝฎ | ็ซฏๅฃ | ็Šถๆ€ | +| ----------------------- | ---------------------------- | ------- | ------- | +| AgentAuditRegistryV2 | Polygon Edge (chainId 302612) | 18545 | healthy | +| shenji-listener | 203.91.76.159 (docker) | ๅ†…้ƒจ | healthy | +| shenji-report-gateway | 203.91.76.159 (docker) | 3310 | healthy | +| shenji-appeal-api | 203.91.76.159 (docker) | 3312 | healthy | +| shenji-frontend | 203.91.76.159 (docker) | 80 | healthy | +| Attestation API (SGX) | 43.134.90.165 (M6ce) | 3311 | healthy | + +- V2 ๅˆ็บฆ๏ผš`0x4A679253410272dd5232B3Ff7cF5dbB88f295319` +- Gramine enclave MRENCLAVE๏ผš`1656d0e5f1dbac0e687662f79b8b5bf8629e40224567ecb823d1eb409f0b16b8` +- Quote ๆ ผๅผ๏ผš`sgx-dcap-v3` +- `report_data` ็ป‘ๅฎš๏ผš`sha256(eventKey โ€– manifestHash โ€– evidenceRoot)` + +--- + +## ๅ›žๅฝ’ๆต‹่ฏ•็ป“ๆžœ + +่„šๆœฌ๏ผš`infra/production/scripts/run-tee-regression.sh` (ๅฐ่ฃ… `run-tee-e2e.sh`) + +่ฐƒ็”จ๏ผš + +```bash +bash infra/production/scripts/run-tee-regression.sh \ + --env /tmp/tee-e2e-local.env \ + --iterations 10 +``` + +### ่šๅˆๆŒ‡ๆ ‡ + +| ๆŒ‡ๆ ‡ | ๅ€ผ | +| --------------------------- | -------- | +| ่ฟญไปฃๆฌกๆ•ฐ | 10 | +| ๆˆๅŠŸ | **10** | +| ๅคฑ่ดฅ | 0 | +| ๆˆๅŠŸ็އ | 1.00 | +| attestationHash ้ž้›ถๆฌกๆ•ฐ | **10** | +| ็ซฏๅˆฐ็ซฏ่€—ๆ—ถ๏ผˆไธญไฝๆ•ฐ๏ผ‰ | 18251 ms | +| ็ซฏๅˆฐ็ซฏ่€—ๆ—ถ๏ผˆp95๏ผ‰ | 18657 ms | + +> ็ซฏๅˆฐ็ซฏ่€—ๆ—ถ = ไปŽๆœฌๅœฐ่ฐƒ็”จ `stake` ๅˆฐ `getLatestAuditReport` ่ฟ”ๅ›ž non-Pendingใ€‚ +> ๅŒบ้—ดๅŒ…ๅซ๏ผšchain tx confirmation + listener ่ฝฎ่ฏข้—ด้š” + manifest ๆ‹‰ๅ– + docker ๆ‹‰่ตท + audit solve + +> SGX quote ็”Ÿๆˆ๏ผˆ็”Ÿไบงๆœบ โ†’ M6ce โ†’ ๅ›žไผ ๏ผ‰+ writeback tx confirmationใ€‚ + +### ้€ๆฌกๆ˜Ž็ป† + +| # | agentName | tokenId | block | attestationHash | +| - | --------------------------- | ------- | ------- | -------------------------------------------------------------------- | +| 1 | regression-1776333024-1 | 3 | 901723 | `0xea3814a1โ€ฆfd4b6d332` | +| 2 | regression-1776333042-2 | 4 | 901732 | `0x07d36984โ€ฆ739506b3` | +| 3 | regression-1776333061-3 | 5 | 901741 | `0xe35023f3โ€ฆ1054d2f0` | +| 4 | regression-1776333079-4 | 6 | 901750 | `0xc8b9b13eโ€ฆb28309ad` | +| 5 | regression-1776333098-5 | 7 | 901759 | `0xbd067341โ€ฆ219141e` | +| 6 | regression-1776333116-6 | 8 | 901769 | `0xa4eb201bโ€ฆfd192a01` | +| 7 | regression-1776333134-7 | 9 | 901778 | `0x053d1988โ€ฆ3449cfae` | +| 8 | regression-1776333153-8 | 10 | 901787 | `0x65ce25d9โ€ฆ0610fb637` | +| 9 | regression-1776333171-9 | 11 | 901796 | `0xf98fce92โ€ฆ5bb4157b` | +| 10 | regression-1776333189-10 | 12 | 901805 | `0x0a06976dโ€ฆ57bbddc7` | + +ๆ‰€ๆœ‰ tokenId ๅ‡ๆˆๅŠŸ้€’ๅขž๏ผŒattestationHash ๅ‡ๅ”ฏไธ€ไธ”้ž `bytes32(0)`๏ผŒMRENCLAVE pin ๆ ก้ชŒ้€š่ฟ‡ใ€‚ + +ๅŽŸๅง‹ๆ•ฐๆฎ๏ผš`infra/production/scripts/regression-20260416-175024/`๏ผˆsummary-*.json + +aggregate.json + log-*.txt๏ผ‰ใ€‚ + +--- + +## ่ง‚ๅฏŸๅˆฐ็š„้—ฎ้ข˜ + +1. **็ซฏๅˆฐ็ซฏ่€—ๆ—ถไธป่ฆๆ˜ฏๅ›บๅฎšๅผ€้”€**ใ€‚ไธญไฝๆ•ฐ 18251 ms ไธญ๏ผš + - `TEE_E2E_POLL_INTERVAL_MS=10000` ่ดก็Œฎ ~10s ่ฝฎ่ฏข็ฒ’ๅบฆ + - ๅ‰ฉไฝ™ ~8s ๆ˜ฏ stake ็กฎ่ฎค + listener ๅฎก่ฎกๆ‰ง่กŒ + writeback ็กฎ่ฎค + - SGX ็”Ÿๆˆ quote ๆœฌ่บซ < 500 ms๏ผˆM6ce ็ซฏๆ—ฅๅฟ—๏ผŒ้žๅ…ณ้”ฎ่ทฏๅพ„๏ผ‰ +2. **`auditScore` ๅ‡ไธบ 0 / `auditStatus=2`๏ผˆFailed๏ผ‰**ใ€‚ๅ›žๅฝ’ manifest ๅฃฐ็งฐ `pass` ไฝ†ๆฒ™็ฎฑๅˆคๅฎš `fail`๏ผŒ + ๅฑžไบŽ audit decision mismatchใ€‚ไธๅฝฑๅ“ attestation ้“พ่ทฏ้ชŒ่ฏ็›ฎๆ ‡ใ€‚ +3. **macOS ่„šๆœฌ portability ไฟฎๅค**๏ผšๅฐ† `date +%s%3N` ๆ›ฟๆขไธบ `node -e 'Date.now()'`๏ผŒ + ๅทฒๅœจ Task #9 ไธญๅฎŒๆˆใ€‚ +4. **ethers v5/v6 ๅ…ฑๅญ˜**๏ผš่„šๆœฌ็”จ v6 API๏ผŒๅชๆœ‰ `frontend/node_modules/ethers@6.16.0` ๅฏ็”จใ€‚ + `NODE_PATH` ๆ˜Ž็กฎๆŒ‡ๅ‘ frontend ็š„ `node_modules` ไปฅ้ฟๅ…ๆญงไน‰ใ€‚ + +--- + +## ๅทฒ็Ÿฅไธ่ถณ๏ผˆๅ€™้€‰ Task #12๏ผ‰ + +listener `processAuditRequested.ts:166` ๅฏน `createAuditAttestation` ้‡‡ๅ– **"SGX ไธๅฏ็”จๅˆ™ๆŠ›ๅ‡บ"** ็š„ +ไธฅๆ ผ็ญ–็•ฅ๏ผš + +```ts +const attestationResult = dependencies.createAuditAttestation + ? await dependencies.createAuditAttestation({...}) + : undefined; +const attestationHash = attestationResult?.attestationHash ?? ZERO_EVIDENCE_HASH; +``` + +ๅช่ฆ SGX API ไธๅฏ่พพๆˆ– MRENCLAVE ไธๅŒน้…๏ผŒ`createAuditAttestation` ไผšๆŠ›ๅผ‚ๅธธ โ†’ +audit ่ขซไธข่ฟ› `audit-execution-retry.json` ไธๆ–ญ้‡่ฏ•ใ€‚่ฟ™ๆ„ๅ‘ณ็€๏ผš + +- **ไผ˜็‚น**๏ผš้“พไธŠไธไผšๅ‡บ็Žฐ `attestationHash=0x0` ็š„"ๆœช็ป TEE ๆ ก้ชŒ"่ฎฐๅฝ•๏ผŒไฟ่ฏๅฎก่ฎกๅ‡ญๆฎ็œŸๅฎžๆ€งใ€‚ +- **็ผบ็‚น**๏ผšSGX ๆœบ้•ฟๆ—ถ้—ดๅฎ•ๆœบๆ—ถ๏ผŒๆ•ดไธช listener ไผšๅกๅœจๆ— ้™้‡่ฏ•๏ผŒๆ— ๆณ•้™็บงไธบ"่ฃธ audit without TEE"ใ€‚ + +**ๅŽ็ปญๆ–นๆกˆๅ€™้€‰**๏ผš + +1. ๅŠ ๅ…ฅ "degraded-mode" ้…็ฝฎ๏ผš`AUDIT_ATTESTATION_REQUIRED=strict|optional`ใ€‚ + - `strict`๏ผšไฟๆŒ็Žฐ็Šถ๏ผˆ้ป˜่ฎค๏ผ‰ใ€‚ + - `optional`๏ผšSGX ไธๅฏ่พพๆ—ถๅ…่ฎธๅ†™ๅ…ฅ `attestationHash=0x0`๏ผŒๅ‰็ซฏ็”จ็บข่‰ฒ badge ๆ˜พ็คบ + "NOT attested"ใ€‚ +2. ็ป™ retry-queue ่ฎพๆœ€ๅคงๅคฑ่ดฅๆฌกๆ•ฐ๏ผŒ่ถ…่ฟ‡ๅŽ fire `AUDIT_ATTESTATION_UNAVAILABLE` ๅ‘Š่ญฆใ€‚ +3. M6ce ๅคšๅฎžไพ‹ + health-check ๅˆ‡ๆขใ€‚ + +ๅฐ†ไฝœไธบ Task #12 ่ทŸ่ฟ›ใ€‚ + +--- + +## ็›ธๅ…ณๆ–‡ไปถ + +- ๅ›žๅฝ’่„šๆœฌ๏ผš`infra/production/scripts/run-tee-regression.sh` +- ๅ•ๆฌก่„šๆœฌ๏ผš`infra/production/scripts/run-tee-e2e.sh` +- ็Žฏๅขƒๆจกๆฟ๏ผš`infra/production/scripts/tee-e2e.env.example` +- ๆ ทไพ‹ไบง็‰ฉ๏ผš`infra/production/scripts/tee-e2e-summary.example.json` +- ๆœฌๆฌกๅ›žๅฝ’ๅŽŸๅง‹ๆ•ฐๆฎ๏ผš`infra/production/scripts/regression-20260416-175024/` +- ้ƒจ็ฝฒๆ–‡ๆกฃ๏ผš`infra/production/README.md#sgx-tee-attestation-production-loop` +- ้ชŒ่ฏๆ–นๆณ•่ฏฆ่งฃ๏ผš`docs/verification-methods.md#7-็”Ÿไบง้ƒจ็ฝฒ็Šถๆ€-2026-04-16` diff --git a/docs/verification-methods.md b/docs/verification-methods.md new file mode 100644 index 0000000..981a927 --- /dev/null +++ b/docs/verification-methods.md @@ -0,0 +1,380 @@ +# Agent Shenji โ€” ๅทฒๅฎž็Žฐ็š„้ชŒ่ฏๆ–นๆณ• + +ๆœฌๆ–‡ๆกฃๆ่ฟฐ้กน็›ฎไธญๅทฒๅฎž็Žฐ็š„ไธ‰ๅฑ‚้ชŒ่ฏไฝ“็ณป๏ผš**TEE ่ฏๆ˜Ž้ชŒ่ฏ**ใ€**ๅญ˜่ฏ้“พ้ชŒ่ฏ**ใ€**ๆŠฅๅ‘ŠๅฎŒๆ•ดๆ€ง้ชŒ่ฏ**๏ผŒไปฅๅŠๅฎƒไปฌไน‹้—ด็š„่ทจๅฑ‚็ป‘ๅฎšๅ…ณ็ณปใ€‚ + +> **ZK ็Šถๆ€**๏ผš้กน็›ฎๅฝ“ๅ‰ **ๆฒกๆœ‰** ไปปไฝ•้›ถ็Ÿฅ่ฏ†่ฏๆ˜Ž (ZK) ็›ธๅ…ณไปฃ็ ใ€‚ + +--- + +## ็›ฎๅฝ• + +1. [ๆŠฅๅ‘ŠๅฎŒๆ•ดๆ€ง้ชŒ่ฏ (Report Verification)](#1-ๆŠฅๅ‘ŠๅฎŒๆ•ดๆ€ง้ชŒ่ฏ) +2. [ๅญ˜่ฏ้“พ้ชŒ่ฏ (Evidence Chain Verification)](#2-ๅญ˜่ฏ้“พ้ชŒ่ฏ) +3. [TEE ่ฏๆ˜Ž้ชŒ่ฏ (Attestation Verification)](#3-tee-่ฏๆ˜Ž้ชŒ่ฏ) +4. [่ทจๅฑ‚็ป‘ๅฎš (Cross-Layer Binding)](#4-่ทจๅฑ‚็ป‘ๅฎš) +5. [CLI ไฝฟ็”จๆ–นๅผ](#5-cli-ไฝฟ็”จๆ–นๅผ) +6. [ๆ–‡ไปถๅ‘ฝๅ็บฆๅฎš](#6-ๆ–‡ไปถๅ‘ฝๅ็บฆๅฎš) + +--- + +## 1. ๆŠฅๅ‘ŠๅฎŒๆ•ดๆ€ง้ชŒ่ฏ + +### ๆ ธๅฟƒๆ–‡ไปถ + +| ๆ–‡ไปถ | ่Œ่ดฃ | +|------|------| +| `sandbox/src/report/buildAuditReport.ts` | ๆž„ๅปบๆŠฅๅ‘Š + ่ฎก็ฎ—ๅ“ˆๅธŒ | +| `sandbox/src/report/persistAuditReport.ts` | ๅŽŸๅญ่ฝ็›˜ (link-based) | +| `sandbox/src/report/readPersistedAuditReport.ts` | ่ฏปๅ– + ้ชŒ่ฏ | +| `sandbox/src/cli/reportVerify.ts` | CLI ๅ…ฅๅฃ | + +### ้ชŒ่ฏ็ฎ—ๆณ• + +``` +1. ๆ ก้ชŒ eventKey ๆ ผๅผ๏ผšๅฟ…้กปๅŒน้… ^0x[0-9a-fA-F]+:\d+$ +2. ๆ‰ซๆ reports/ ็›ฎๅฝ•๏ผŒๅŒน้…ๆ–‡ไปถๅๆจกๅผ ---.json + - 0 ไธชๅŒน้… โ†’ not_found + - 2+ ไธชๅŒน้… โ†’ conflict +3. ่ฏปๅ–ๆ–‡ไปถๅŽŸๅง‹ๅญ—่Š‚ +4. ้‡็ฎ— SHA-256(fileContents) +5. ไธŽๆ–‡ไปถๅไธญๅตŒๅ…ฅ็š„ 64 ไฝ hex hash ๆฏ”ๅฏน๏ผˆๅคงๅฐๅ†™ไธๆ•ๆ„Ÿ๏ผ‰ + - ไธ€่‡ด โ†’ verified + - ไธไธ€่‡ด โ†’ hash_mismatch๏ผˆ่ฟ”ๅ›ž expected + actual๏ผ‰ +``` + +### ๅ“ˆๅธŒ่ฎก็ฎ— + +```typescript +reportHash = sha256(JSON.stringify(report, null, 2)) +``` + +ๆŠฅๅ‘Šๅ†…ๅฎนๅŒ…ๅซ๏ผšๅฎก่ฎกๅ†ณ็ญ–ใ€่ต„ๆบๆŒ‡ๆ ‡ใ€็ฝ‘็ปœๆดปๅŠจใ€healthcheck ็ป“ๆžœใ€response traceใ€ไปฅๅŠๅตŒๅ…ฅ็š„ `evidenceRoot` ๅ’Œ `attestationHash` ๅผ•็”จใ€‚ + +--- + +## 2. ๅญ˜่ฏ้“พ้ชŒ่ฏ + +### ๆ ธๅฟƒๆ–‡ไปถ + +| ๆ–‡ไปถ | ่Œ่ดฃ | +|------|------| +| `sandbox/src/evidence/buildAuditEvidenceEvent.ts` | ๆž„ๅปบๅ•ไธชๅญ˜่ฏไบ‹ไปถ + ๅ“ˆๅธŒ | +| `sandbox/src/evidence/evidenceChain.ts` | ็ปดๆŠคๅ“ˆๅธŒ้“พไธŠไธ‹ๆ–‡ | +| `sandbox/src/evidence/persistAuditEvidence.ts` | ๅŽŸๅญ่ฝ็›˜ | +| `sandbox/src/evidence/readPersistedAuditEvidence.ts` | ่ฏปๅ– + ้ชŒ่ฏ | +| `sandbox/src/cli/evidenceVerify.ts` | CLI ๅ…ฅๅฃ | + +### ๅ“ˆๅธŒ้“พ็ป“ๆž„ + +ๆฏไธชๅญ˜่ฏไบ‹ไปถๅŒ…ๅซ 7 ไธชๅญ—ๆฎต๏ผš + +```typescript +{ + schemaVersion: "audit-evidence-event.v1", + eventKey, // "0x:" + tokenId, + sequence, // ไปŽ 0 ๅผ€ๅง‹้€’ๅขž + stage, // 10 ไธชๆœ‰ๅบ้˜ถๆฎตไน‹ไธ€ + timestamp, + prevHash, // ๅ‰ไธ€ไธชไบ‹ไปถ็š„ eventHash๏ผˆ็ฌฌไธ€ไธชไบ‹ไปถไธบ ZERO_EVIDENCE_HASH๏ผ‰ + payloadHash // sha256(JSON.stringify(canonicalize(payload))) +} +``` + +ๅ…ถไธญ `canonicalize` ้€’ๅฝ’ๅœฐๆŒ‰ๅญ—ๅ…ธๅบๆŽ’ๅˆ—ๅฏน่ฑก key๏ผŒ็กฎไฟ็›ธๅŒๅ†…ๅฎน็š„ JSON ไบง็”Ÿ็›ธๅŒๅ“ˆๅธŒใ€‚ + +``` +eventHash = sha256(canonicalize({ schemaVersion, eventKey, tokenId, sequence, stage, timestamp, prevHash, payloadHash })) +``` + +**evidenceRoot** = ๆœ€ๅŽไธ€ไธชไบ‹ไปถ็š„ `eventHash`ใ€‚ไปปไฝ•ๅކๅฒไบ‹ไปถ็š„็ฏกๆ”น้ƒฝไผšๅฏผ่‡ดๅŽ็ปญๆ‰€ๆœ‰ๅ“ˆๅธŒๅคฑๆ•ˆ๏ผŒๆœ€็ปˆๆ”นๅ˜ evidenceRootใ€‚ + +### 10 ไธชๆœ‰ๅบ้˜ถๆฎต + +``` +audit_requested_observed โ†’ manifest_fetched โ†’ manifest_validated โ†’ +container_started โ†’ healthcheck_passed โ†’ audit_request_sent โ†’ +audit_response_received โ†’ resource_usage_collected โ†’ +network_activity_collected โ†’ report_built +``` + +### ้ชŒ่ฏ็ฎ—ๆณ• + +``` +1. ๆ ก้ชŒ eventKey ๆ ผๅผ +2. ๆ‰ซๆ evidence/ ็›ฎๅฝ•๏ผŒๅŒน้…ๆ–‡ไปถๅๆๅ–ๅตŒๅ…ฅ็š„ evidenceRoot + - 0 ๅŒน้… โ†’ not_found / 2+ โ†’ conflict +3. ่งฃๆž JSON๏ผŒ้ๅކ events ๆ•ฐ็ป„ +4. ไปŽๅคด้‡็ฎ—ๆฏไธชไบ‹ไปถ็š„ eventHash๏ผˆไฝฟ็”จๅ…ถ prevHash + ่‡ช่บซๅญ—ๆฎต๏ผ‰ +5. ๆœ€ๅŽไธ€ไธช eventHash ๅณไธบ้‡็ฎ—็š„ evidenceRoot +6. ไธ‰้‡ไธ€่‡ดๆ€งๆ ก้ชŒ๏ผš + - ้‡็ฎ—็š„ root == ๆ–‡ไปถๅๅตŒๅ…ฅ็š„ hash + - payload.evidenceRoot == ๆ–‡ไปถๅๅตŒๅ…ฅ็š„ hash + - payload.eventCount == payload.events.length +7. ๅ…จ้ƒจไธ€่‡ด โ†’ verified๏ผŒไปปไธ€ไธๅŒน้… โ†’ hash_mismatch +``` + +--- + +## 3. TEE ่ฏๆ˜Ž้ชŒ่ฏ + +### ๆ ธๅฟƒๆ–‡ไปถ + +| ๆ–‡ไปถ | ่Œ่ดฃ | +|------|------| +| `sandbox/src/attestation/buildAuditAttestation.ts` | ๆž„ๅปบ attestation bundle | +| `sandbox/src/attestation/persistAuditAttestation.ts` | ๅŽŸๅญ่ฝ็›˜ | +| `sandbox/src/attestation/readPersistedAuditAttestation.ts` | ่ฏปๅ– + ๅคšๅฑ‚้ชŒ่ฏ | +| `sandbox/src/attestation/attestationQuoteValidator.ts` | Quote ๅญ—ๆฎตๆ ก้ชŒๅ™จ | +| `sandbox/src/attestation/sgxDcapQuoteValidator.ts` | SGX DCAP v3 ไบŒ่ฟ›ๅˆถ่งฃๆž | +| `sandbox/src/attestation/readAttestationVerifyConfig.ts` | ็Žฏๅขƒๅ˜้‡้…็ฝฎ | +| `sandbox/src/attestation/createTeeProvider.ts` | Provider ๅทฅๅŽ‚ | +| `sandbox/src/cli/attestationVerify.ts` | CLI ๅ…ฅๅฃ | + +### Attestation Bundle ็ป“ๆž„ + +```typescript +{ + schemaVersion: "audit-attestation.v1", + eventKey: "0x:", + tokenId: "1", + manifestHash: "<64 hex>", + evidenceRoot: "<64 hex>", + verifier: { + type: "sgx-dcap" | "mock-tee", + measurement: "", + quoteFormat: "sgx-dcap-v3" | "mock-quote", + sessionPublicKey: "", + quote: "" + } +} +``` + +### ้ชŒ่ฏ็ฎ—ๆณ•๏ผˆๅฎŒๆ•ด 7 ๆญฅ๏ผ‰ + +``` +1. ๆ ก้ชŒ eventKey ๆ ผๅผ +2. ๆ‰ซๆ attestations/ ็›ฎๅฝ•๏ผŒๅŒน้…ๆ–‡ไปถๅๆๅ–ๅตŒๅ…ฅ็š„ attestationHash + - 0 ๅŒน้… โ†’ not_found / 2+ โ†’ conflict +3. ่ฏปๅ–ๆ–‡ไปถ๏ผŒ้‡็ฎ— sha256(fileContents)๏ผŒไธŽๆ–‡ไปถๅ hash ๆฏ”ๅฏน + - ไธไธ€่‡ด โ†’ hash_mismatch +4. ่งฃๆž JSON๏ผŒๆ ก้ชŒ schema ็ป“ๆž„๏ผš + - schemaVersion === "audit-attestation.v1" + - ๆ‰€ๆœ‰ๅญ—ๆฎต้ž็ฉบๅญ—็ฌฆไธฒ +5. ๅฆ‚ๆžœๆไพ›ไบ† expectedVerifier๏ผŒ้€ๅญ—ๆฎตๆฏ”ๅฏน๏ผš + - verifier.type vs expectedVerifier.providerType + - verifier.measurement vs expectedVerifier.measurement + - verifier.quoteFormat vs expectedVerifier.quoteFormat + - ไธไธ€่‡ด โ†’ verifier_mismatch๏ผˆ่ฟ”ๅ›ž field/expected/actual๏ผ‰ +6. ๅฆ‚ๆžœ verifyReportDataBinding === true ไธ” quoteFormat === "sgx-dcap-v3"๏ผš + a. ่งฃๆž SGX DCAP v3 ไบŒ่ฟ›ๅˆถ quote๏ผˆ่งไธ‹ๆ–น๏ผ‰ + b. ่ฎก็ฎ—ๆœŸๆœ›็š„ report_data = sha256(eventKey + manifestHash + evidenceRoot) + c. ไธŽ quote ไธญ็š„ report_data ๅญ—ๆฎต้€ๅญ—่Š‚ๆฏ”ๅฏน + - ่งฃๆžๅคฑ่ดฅ โ†’ sgx_quote_invalid + - ไธไธ€่‡ด โ†’ report_data_mismatch +7. ๅ…จ้ƒจ้€š่ฟ‡ โ†’ verified +``` + +### SGX DCAP v3 Quote ไบŒ่ฟ›ๅˆถ็ป“ๆž„ + +``` +ๅ็งป้‡ ๅญ—ๆฎต ๅคงๅฐ +โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ +0-1 version (ๅฟ…้กป = 3) 2 bytes +2-3 att_key_type 2 bytes +4-7 tee_type (ๅฟ…้กป = 0) 4 bytes (0 = SGX) +8-9 qe_svn 2 bytes +10-11 pce_svn 2 bytes +12-27 qe_vendor_id 16 bytes +28-47 user_data 20 bytes +โ”€โ”€โ”€โ”€โ”€ Report Body (offset 48) โ”€โ”€โ”€โ”€โ”€โ”€ +48-63 cpu_svn 16 bytes +64-79 misc_select ... +... +112-143 MRENCLAVE 32 bytes โ† enclave ๅบฆ้‡ๅ€ผ +... +176-207 MRSIGNER 32 bytes +... +368-431 report_data 64 bytes โ† ็ป‘ๅฎšๅญ—ๆฎต +โ”€โ”€โ”€โ”€โ”€ Auth Data (offset 432+) โ”€โ”€โ”€โ”€โ”€โ”€ +432-435 auth_data_size 4 bytes +436+ ECDSA signature + cert chain +``` + +### report_data ็ป‘ๅฎš่ฎก็ฎ— + +```typescript +const digest = sha256(eventKey + manifestHash + evidenceRoot); // 32 bytes +const reportData = Buffer.alloc(64); // 64 bytes +digest.copy(reportData, 0, 0, 32); // ๅ‰ 32 ๅญ—่Š‚ๆ˜ฏ digest๏ผŒๅŽ 32 ๅญ—่Š‚้›ถๅกซๅ…… +``` + +### Quote ้ชŒ่ฏๅ™จ็ป„ๅˆ + +ๅฝ“ `expectedQuoteFormat === "sgx-dcap-v3"` ๆ—ถ๏ผŒ็ณป็ปŸ่‡ชๅŠจ็ป„ๅˆไธคไธช้ชŒ่ฏๅ™จ๏ผš + +``` +CompositeValidator = [ + ExpectedFieldValidator๏ผˆๆฃ€ๆŸฅ providerType / measurement / quoteFormat๏ผ‰, + SgxDcapQuoteValidator๏ผˆ่งฃๆžไบŒ่ฟ›ๅˆถใ€ๆ ก้ชŒ version/teeType/mrEnclave/reportData๏ผ‰ +] +``` + +้กบๅบๆ‰ง่กŒ๏ผŒไปปไธ€ๅคฑ่ดฅๅณๅœๆญขใ€‚ + +--- + +## 4. ่ทจๅฑ‚็ป‘ๅฎš + +ไธ‰ๅฑ‚้€š่ฟ‡ SGX quote ็š„ `report_data` ๅญ—ๆฎต็ป‘ๅฎšๅœจไธ€่ตท๏ผš + +``` +report_data[0..31] = sha256(eventKey + manifestHash + evidenceRoot) +``` + +| ๅญ—ๆฎต | ๅซไน‰ | ๆฅๆบ | +|------|------|------| +| `eventKey` | ้“พไธŠๅฎก่ฎก่ฏทๆฑ‚็š„ๅ”ฏไธ€ๆ ‡่ฏ† | `:` | +| `manifestHash` | Agent manifest ็š„ SHA-256 | ๆŠฅๅ‘Šๅฑ‚ | +| `evidenceRoot` | ๅญ˜่ฏ้“พๆœ€็ปˆๅ“ˆๅธŒ | ๅญ˜่ฏๅฑ‚ | + +**ๅฎ‰ๅ…จไฟ่ฏ**๏ผšๅผ€ๅฏ `verifyReportDataBinding` ๅŽ๏ผŒ้ชŒ่ฏ็ณป็ปŸๅฏไปฅๅฏ†็ ๅญฆ่ฏๆ˜Ž๏ผš็”ฑ `MRENCLAVE` ๆ ‡่ฏ†็š„ SGX enclave ๅœจ็‰นๅฎš้“พไธŠ token๏ผˆ`eventKey`๏ผ‰็š„ๅฎก่ฎกไธญ๏ผŒ้’ˆๅฏน็‰นๅฎš manifest๏ผˆ`manifestHash`๏ผ‰๏ผŒไบง็”Ÿไบ†็‰นๅฎš็š„ๅญ˜่ฏ้“พ๏ผˆ`evidenceRoot`๏ผ‰โ€”โ€”ๆ— ๆณ•ๅœจไธ็ ด่งฃ SHA-256 ็š„ๅ‰ๆไธ‹ไผช้€ ใ€‚ + +### ไฟกไปป้“พ + +``` +้“พไธŠๅˆ็บฆ (attestationHash) + โ†“ ๅ“ˆๅธŒๅผ•็”จ +Attestation Bundle (ๅŒ…ๅซ SGX quote) + โ†“ report_data ็ป‘ๅฎš + โ”œโ”€โ”€ eventKey โ†’ ้“พไธŠ token + โ”œโ”€โ”€ manifestHash โ†’ ่ขซๅฎก่ฎก็š„ Agent ไปฃ็  + โ””โ”€โ”€ evidenceRoot โ†’ ๅญ˜่ฏ้“พ + โ†“ ๅ“ˆๅธŒ้“พ + ๅ„้˜ถๆฎตๅญ˜่ฏไบ‹ไปถ๏ผˆmanifest่Žทๅ–ใ€ๅฎนๅ™จๅฏๅŠจใ€ๅฎก่ฎกๆ‰ง่กŒโ€ฆ๏ผ‰ + โ†“ payloadHash + ๆฏไธชไบ‹ไปถ็š„่ฏฆ็ป†ๆ•ฐๆฎ +``` + +--- + +## 5. CLI ไฝฟ็”จๆ–นๅผ + +### ๆŠฅๅ‘Š้ชŒ่ฏ + +```bash +npm run run:report:verify -- --event-key 0x: [--state-dir /path] +``` + +### ๅญ˜่ฏ้“พ้ชŒ่ฏ + +```bash +npm run run:evidence:verify -- --event-key 0x: [--state-dir /path] +``` + +### TEE ่ฏๆ˜Ž้ชŒ่ฏ + +```bash +# ๅŸบ็ก€้ชŒ่ฏ๏ผˆๅ“ˆๅธŒๅฎŒๆ•ดๆ€ง๏ผ‰ +npm run run:attestation:verify -- --event-key 0x: [--state-dir /path] + +# ๅธฆๆœŸๆœ›ๅ€ผ็š„้ชŒ่ฏ +AUDIT_ATTESTATION_EXPECTED_PROVIDER_TYPE=sgx-dcap \ +AUDIT_ATTESTATION_EXPECTED_MEASUREMENT= \ +AUDIT_ATTESTATION_EXPECTED_QUOTE_FORMAT=sgx-dcap-v3 \ +AUDIT_ATTESTATION_VERIFY_REPORT_DATA_BINDING=true \ +npm run run:attestation:verify -- --event-key 0x: +``` + +### ็Žฏๅขƒๅ˜้‡ + +| ๅ˜้‡ | ่ฏดๆ˜Ž | +|------|------| +| `AUDIT_ATTESTATION_EXPECTED_PROVIDER_TYPE` | ๆœŸๆœ›็š„ TEE ็ฑปๅž‹๏ผˆๅฆ‚ `sgx-dcap`๏ผ‰ | +| `AUDIT_ATTESTATION_EXPECTED_MEASUREMENT` | ๆœŸๆœ›็š„ MRENCLAVE๏ผˆ64 hex๏ผ‰ | +| `AUDIT_ATTESTATION_EXPECTED_QUOTE_FORMAT` | ๆœŸๆœ›็š„ quote ๆ ผๅผ๏ผˆๅฆ‚ `sgx-dcap-v3`๏ผ‰ | +| `AUDIT_ATTESTATION_VERIFY_REPORT_DATA_BINDING` | ่ฎพไธบ `true` ๅฏ็”จ report_data ็ป‘ๅฎš้ชŒ่ฏ | + +### ่ฟ”ๅ›ž็  + +ๆ‰€ๆœ‰ CLI ๅทฅๅ…ท๏ผš`0` = verified๏ผŒ`1` = ๅ…ถไป–็Šถๆ€ใ€‚ + +### ่พ“ๅ‡บๆ ผๅผ + +JSON ๅˆฐ stdout๏ผŒ็คบไพ‹๏ผš + +```json +{ + "status": "verified", + "eventKey": "0xabc:0", + "attestationFilePath": "/path/to/attestations/1-0xabc-0-.json", + "attestationHash": "<64 hex>" +} +``` + +--- + +## 6. ๆ–‡ไปถๅ‘ฝๅ็บฆๅฎš + +ไธ‰ๅฑ‚้ชŒ่ฏๅ…ฑ็”จ็›ธๅŒ็š„ๆ–‡ไปถๅ‘ฝๅๆจกๅผ๏ผš + +``` +---.json +``` + +| ๅฑ‚ | ็›ฎๅฝ• | contentHash ๅซไน‰ | +|---|------|------------------| +| ๆŠฅๅ‘Š | `reports/` | `reportHash` = sha256(ๆŠฅๅ‘Š JSON) | +| ๅญ˜่ฏ | `evidence/` | `evidenceRoot` = ๆœ€ๅŽไธ€ไธช eventHash | +| ่ฏๆ˜Ž | `attestations/` | `attestationHash` = sha256(bundle JSON) | + +่ฝ็›˜ไฝฟ็”จ `link()` ๅŽŸๅญๅ†™ๅ…ฅ๏ผšๅ…ˆๅ†™ UUID ไธดๆ—ถๆ–‡ไปถ๏ผŒๅ† `link` ๅˆฐ็›ฎๆ ‡่ทฏๅพ„๏ผŒ็กฎไฟไธไผšๅ‡บ็ŽฐๅŠๅ†™ๆ–‡ไปถใ€‚ๅฆ‚ๆžœ็›ฎๆ ‡ๅทฒๅญ˜ๅœจไธ”ๅ†…ๅฎนไธๅŒ๏ผŒๆŠ›ๅ‡บ conflict ้”™่ฏฏใ€‚ + +--- + +## 7. ็”Ÿไบง้ƒจ็ฝฒ็Šถๆ€ (2026-04-16) + +### ่ฟ่กŒไธญ็š„ TEE ้—ญ็Žฏ + +| ็ป„ไปถ | ้ƒจ็ฝฒไฝ็ฝฎ | ็ซฏๅฃ | +|------|----------|------| +| Listener / Registry Writeback | `203.91.76.159` (Tencent Cloud) | docker-compose, ๆ— ๅค–้ƒจ็ซฏๅฃ | +| Attestation API (Gramine SGX) | `43.134.90.165` (Tencent Cloud M6ce) | `3311` | +| AgentAuditRegistryV2 | Polygon Edge `chainId=302612` | `0x4A679253410272dd5232B3Ff7cF5dbB88f295319` | + +### ๅฝ“ๅ‰็”Ÿไบง็š„ enclave pin + +| ้กน | ๅ€ผ | +|----|----| +| `AUDIT_ATTESTATION_EXPECTED_PROVIDER_TYPE` | `sgx-dcap` | +| `AUDIT_ATTESTATION_EXPECTED_MEASUREMENT` (MRENCLAVE) | `1656d0e5f1dbac0e687662f79b8b5bf8629e40224567ecb823d1eb409f0b16b8` | +| `AUDIT_ATTESTATION_EXPECTED_QUOTE_FORMAT` | `sgx-dcap-v3` | +| `AUDIT_ATTESTATION_VERIFY_REPORT_DATA_BINDING` | `true` | + +ไธŠ่ฟฐๅ€ผๅœจ listener ็š„ `createHttpAttestationClient` ไธญๅผบๅˆถๆ‰ง่กŒ โ€”โ€” ไปปไฝ•่ฟ”ๅ›ž +ไธๅŒ MRENCLAVE / quoteFormat / providerType ๆˆ–้”™่ฏฏ `report_data` ็š„ quote ้ƒฝไผš +ๅฏผ่‡ด audit ่ขซๆ ‡่ฎฐไธบๅคฑ่ดฅ๏ผŒไธ” `record.attestationHash = bytes32(0)`ใ€‚ + +### ่‡ชๅŠจๅŒ–ๅ†’็ƒŸ + +`infra/production/scripts/run-tee-e2e.sh` ๆไพ›ไธ€้”ฎๅผ็ซฏๅˆฐ็ซฏ้ชŒ่ฏ๏ผš + +```bash +bash infra/production/scripts/run-tee-e2e.sh --env infra/production/.env.e2e +``` + +ๆˆๅŠŸๆ ทไพ‹่ง `infra/production/scripts/tee-e2e-summary.example.json`ใ€‚ + +### ๅ‰็ซฏ UI + +`AuditReportPage` ้€š่ฟ‡ `` ๅฑ•็คบ๏ผš + +- `attestationHash`๏ผˆ้ž้›ถ โ†’ ็ปฟ่‰ฒ "SGX-DCAP verified" badge + ๆˆช็Ÿญ hash๏ผ‰ +- ็”Ÿไบง้ƒจ็ฝฒๆ‰€ pin ็š„ MRENCLAVE / provider / quote format / report_data binding ๆ ‡ๅฟ— + +ๅฏนๅบ”็ป„ไปถ๏ผš +- `frontend/src/components/AttestationBadge.tsx` +- `frontend/src/components/AttestationVerificationCard.tsx` + +้…็ฝฎๅ…ฅๅฃ๏ผš`frontend/src/config/appConfig.ts`๏ผŒ้€š่ฟ‡ +`VITE_AUDIT_ATTESTATION_EXPECTED_*` ๆณจๅ…ฅใ€‚ diff --git a/frontend/index.html b/frontend/index.html index 61a4079..c59f2ac 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -3,10 +3,92 @@ - Agent Shenji + AgentLens โ€” Trusted Agent Marketplace + +
+ - + diff --git a/frontend/public/popo-mascot.png b/frontend/public/popo-mascot.png new file mode 100644 index 0000000..815e902 Binary files /dev/null and b/frontend/public/popo-mascot.png differ diff --git a/frontend/src/app/App.test.tsx b/frontend/src/app/App.test.tsx index 0028f1f..5adaece 100644 --- a/frontend/src/app/App.test.tsx +++ b/frontend/src/app/App.test.tsx @@ -1,5 +1,5 @@ import { describe, expect, it, vi } from "vitest"; -import { render, screen } from "@testing-library/react"; +import { render, screen, fireEvent } from "@testing-library/react"; import { MemoryRouter } from "react-router-dom"; import { App } from "./App"; @@ -22,17 +22,28 @@ vi.mock("../lib/agentAuditRegistryClient", () => ({ getLatestAuditReport: vi.fn().mockRejectedValue(new Error("execution reverted: TOKEN_NOT_FOUND")), getAuditCount: vi.fn().mockRejectedValue(new Error("execution reverted: TOKEN_NOT_FOUND")), getAuditReportByIndex: vi.fn().mockRejectedValue(new Error("execution reverted: TOKEN_NOT_FOUND")) + }), + createAgentAuditRegistryV2Client: () => ({ + getAgentProfile: vi.fn().mockRejectedValue(new Error("execution reverted: TOKEN_NOT_FOUND")), + getLatestAuditReport: vi.fn().mockRejectedValue(new Error("execution reverted: TOKEN_NOT_FOUND")), + getAuditCount: vi.fn().mockRejectedValue(new Error("execution reverted: TOKEN_NOT_FOUND")), + getAuditReportByIndex: vi.fn().mockRejectedValue(new Error("execution reverted: TOKEN_NOT_FOUND")), + getReputation: vi.fn().mockRejectedValue(new Error("execution reverted: TOKEN_NOT_FOUND")), + getAppealCount: vi.fn().mockRejectedValue(new Error("execution reverted: TOKEN_NOT_FOUND")), + getAppealRecord: vi.fn().mockRejectedValue(new Error("execution reverted: TOKEN_NOT_FOUND")) }) })); describe("App", () => { - it("renders a tokenId query surface", () => { + it("renders a tokenId query surface behind the direct lookup toggle", () => { render( ); + // Token input is hidden by default; click toggle to show it + fireEvent.click(screen.getByText(/direct lookup by token id/i)); expect(screen.getByLabelText(/tokenid/i)).toBeInTheDocument(); }); diff --git a/frontend/src/app/App.tsx b/frontend/src/app/App.tsx index 978307d..2a5a8e5 100644 --- a/frontend/src/app/App.tsx +++ b/frontend/src/app/App.tsx @@ -7,6 +7,7 @@ import { readAppConfig } from "../config/appConfig"; import { AgentDetailPage } from "../pages/AgentDetailPage"; import { AuditReportPage } from "../pages/AuditReportPage"; import { HomePage } from "../pages/HomePage"; +import { PopoWelcome } from "../components/PopoWelcome"; interface AppProps { env?: AppEnv; @@ -21,6 +22,7 @@ export function App({ env = import.meta.env }: AppProps): JSX.Element { return ( + } /> } /> diff --git a/frontend/src/components/AccessHistoryCard.tsx b/frontend/src/components/AccessHistoryCard.tsx new file mode 100644 index 0000000..085ba72 --- /dev/null +++ b/frontend/src/components/AccessHistoryCard.tsx @@ -0,0 +1,85 @@ +import { formatPriceEth } from "../lib/format"; + +export interface AccessRecord { + buyer: string; + isRental: boolean; + amountPaid: bigint; + expiresAt: number; // unix timestamp, 0 = permanent +} + +interface AccessHistoryCardProps { + records: AccessRecord[]; + totalCount: number; +} + +function truncateAddress(addr: string): string { + if (addr.length < 10) return addr; + return `${addr.slice(0, 6)}...${addr.slice(-4)}`; +} + +function formatExpiry(expiresAt: number): string { + if (expiresAt === 0) return "Permanent"; + const now = Math.floor(Date.now() / 1000); + if (expiresAt < now) return "Expired"; + const days = Math.ceil((expiresAt - now) / 86400); + return `Expires in ${days}d`; +} + +export function AccessHistoryCard({ records, totalCount }: AccessHistoryCardProps): JSX.Element { + if (totalCount === 0) { + return ( +
+

Access History

+

No Transactions Yet

+

This agent has not been accessed by any buyer yet. Be the first.

+
+ ); + } + + return ( +
+

Access History

+

+ {totalCount} Transaction{totalCount !== 1 ? "s" : ""} +

+

+ On-chain record of all rental and purchase transactions for this agent. +

+
+ + + + + + + + + + + {records.map((record, i) => ( + + + + + + + ))} + +
BuyerTypeAmountStatus
{truncateAddress(record.buyer)} + + {record.isRental ? "Rental" : "Purchase"} + + {formatPriceEth(record.amountPaid)} + + {formatExpiry(record.expiresAt)} + +
+
+ {totalCount > records.length ? ( +

+ Showing {records.length} of {totalCount} transactions +

+ ) : null} +
+ ); +} diff --git a/frontend/src/components/AgentList.test.tsx b/frontend/src/components/AgentList.test.tsx index bdaa809..33628d0 100644 --- a/frontend/src/components/AgentList.test.tsx +++ b/frontend/src/components/AgentList.test.tsx @@ -17,7 +17,12 @@ const agentsFixture: AgentListEntry[] = [ developer: "0x1111111111111111111111111111111111111111", latestStatus: 1, latestScore: 92, - auditCount: 5n + auditCount: 5n, + reputationScore: null, + riskLevel: null, + attestationVerified: false, + lastAuditAt: 0, + pricing: null }, { tokenId: "2", @@ -25,7 +30,12 @@ const agentsFixture: AgentListEntry[] = [ developer: "0x2222222222222222222222222222222222222222", latestStatus: 2, latestScore: 40, - auditCount: 3n + auditCount: 3n, + reputationScore: null, + riskLevel: null, + attestationVerified: false, + lastAuditAt: 0, + pricing: null } ]; diff --git a/frontend/src/components/AgentList.tsx b/frontend/src/components/AgentList.tsx index e1445f9..e665b10 100644 --- a/frontend/src/components/AgentList.tsx +++ b/frontend/src/components/AgentList.tsx @@ -1,4 +1,5 @@ -import { AgentListItem, type AgentListEntry } from "./AgentListItem"; +import { EnhancedAgentCard } from "./EnhancedAgentCard"; +import type { AgentListEntry } from "./AgentListItem"; import { EmptyState } from "./EmptyState"; interface AgentListProps { @@ -19,15 +20,16 @@ export function AgentList({ emptyDescription = "There are no registered agents matching your search criteria." }: AgentListProps): JSX.Element { if (agents.length === 0) { - return ; + // showPopo=true when there are genuinely no agents (not a filtered-out result) + const isNoAgentsAtAll = emptyTitle === "No agents registered"; + return ; } return ( -
-

Registered agents

+
    {agents.map((agent) => ( - + ))}
{hasMore ? ( diff --git a/frontend/src/components/AgentListItem.test.tsx b/frontend/src/components/AgentListItem.test.tsx index ee0edbf..0368b9e 100644 --- a/frontend/src/components/AgentListItem.test.tsx +++ b/frontend/src/components/AgentListItem.test.tsx @@ -15,7 +15,12 @@ const agentFixture: AgentListEntry = { developer: "0x1111111111111111111111111111111111111111", latestStatus: 1, latestScore: 92, - auditCount: 5n + auditCount: 5n, + reputationScore: null, + riskLevel: null, + attestationVerified: false, + lastAuditAt: 0, + pricing: null }; describe("AgentListItem", () => { diff --git a/frontend/src/components/AgentListItem.tsx b/frontend/src/components/AgentListItem.tsx index 1dacbe0..3d0196c 100644 --- a/frontend/src/components/AgentListItem.tsx +++ b/frontend/src/components/AgentListItem.tsx @@ -2,6 +2,7 @@ import { Link } from "react-router-dom"; import { getAuditStatusLabel } from "../lib/auditStatus"; import { truncateAddress } from "../lib/format"; +import type { RiskClassification } from "../lib/riskLevel"; export interface AgentListEntry { tokenId: string; @@ -10,6 +11,11 @@ export interface AgentListEntry { latestStatus: bigint | number | null; latestScore: bigint | number | null; auditCount: bigint | number; + reputationScore: number | null; + riskLevel: RiskClassification | null; + attestationVerified: boolean; + lastAuditAt: number; + pricing: { pricePerDay: bigint; buyPrice: bigint; configured: boolean } | null; } interface AgentListItemProps { diff --git a/frontend/src/components/AppealHistoryTimeline.tsx b/frontend/src/components/AppealHistoryTimeline.tsx index 0ffcfa9..d750858 100644 --- a/frontend/src/components/AppealHistoryTimeline.tsx +++ b/frontend/src/components/AppealHistoryTimeline.tsx @@ -22,6 +22,17 @@ function outcomeClassName(outcome: string): string { } } +function outcomeLabel(outcome: string): string { + switch (outcome) { + case "Approved": + return "Resolved in developer's favor"; + case "Rejected": + return "Original audit result upheld"; + default: + return "Under review"; + } +} + function formatTimestamp(isoString: string): string { try { return new Date(isoString).toLocaleDateString("en-US", { @@ -38,19 +49,23 @@ function formatTimestamp(isoString: string): string { export function AppealHistoryTimeline({ appeals }: AppealHistoryTimelineProps): JSX.Element { if (appeals.length === 0) { - return

No appeal history for this agent.

; + return

No dispute history for this agent.

; } return (
-

Appeal history

+

Dispute History

+

+ Each dispute follows a structured review process. The developer provides evidence, + an independent arbitrator reviews the case, and the outcome is recorded on-chain. +

    {appeals.map((entry) => (
  • - Appeal #{entry.appealId} + Dispute #{entry.appealId} - {entry.outcome} + {outcomeLabel(entry.outcome)}
    @@ -61,7 +76,7 @@ export function AppealHistoryTimeline({ appeals }: AppealHistoryTimelineProps): ) : null}
    {entry.appealCID ? ( -
    CID: {entry.appealCID}
    +
    Evidence: {entry.appealCID}
    ) : null}
  • ))} diff --git a/frontend/src/components/AppealSection.tsx b/frontend/src/components/AppealSection.tsx index 2d0bf71..21ce647 100644 --- a/frontend/src/components/AppealSection.tsx +++ b/frontend/src/components/AppealSection.tsx @@ -88,6 +88,7 @@ export function AppealSection({ {reputation ? ( +

    Audit Failed

    +

    + This agent did not meet the required audit criteria. No bond was penalized. + The developer can address the issues and request a new audit. +

    +
+ ); + } + + if (status === STATUS_SLASHED) { + const bondDisplay = formatBondWei(bondAmount); + + if (appealRequested && !appealApproved) { + return ( +
+

Penalty Under Dispute

+

+ This agent was penalized ({bondDisplay} bond affected) due to security or compliance violations. + The developer has filed a dispute, which is currently under independent review. +

+
+ ); + } + + return ( +
+

Bond Penalized

+

+ This agent was penalized. {bondDisplay} bond was affected due to security or compliance violations. + The developer may file a dispute for independent review. +

+
+ ); + } + + if (status === STATUS_COMPENSATED) { + return ( +
+

Penalty Reversed

+

+ After independent review, the original penalty was reversed. + The bond has been returned to the developer. +

+
+ ); + } + + return null; +} diff --git a/frontend/src/components/EmptyState.tsx b/frontend/src/components/EmptyState.tsx index 4caf52e..c79354e 100644 --- a/frontend/src/components/EmptyState.tsx +++ b/frontend/src/components/EmptyState.tsx @@ -1,14 +1,30 @@ interface EmptyStateProps { title: string; description: string; + /** When true, shows Popo waiting illustration (no agents at all). + * When false (default), shows a lighter "no results" state. */ + showPopo?: boolean; } -export function EmptyState({ title, description }: EmptyStateProps): JSX.Element { +export function EmptyState({ title, description, showPopo = false }: EmptyStateProps): JSX.Element { return ( -
-

Read-only detail

-

{title}

-

{description}

+
+ {showPopo ? ( +
+ Popo the mascot +

+ Popo is waiting for the first agent to be audited... +

+
+ ) : ( +
๐Ÿ”
+ )} +

{title}

+

{description}

); } diff --git a/frontend/src/components/EnhancedAgentCard.tsx b/frontend/src/components/EnhancedAgentCard.tsx new file mode 100644 index 0000000..4f717ec --- /dev/null +++ b/frontend/src/components/EnhancedAgentCard.tsx @@ -0,0 +1,90 @@ +import { Link } from "react-router-dom"; + +import type { AgentListEntry } from "./AgentListItem"; +import { getAuditStatusLabel } from "../lib/auditStatus"; +import { truncateAddress, formatPriceEth } from "../lib/format"; +import { getAuditFreshness } from "../lib/riskLevel"; + +interface EnhancedAgentCardProps { + agent: AgentListEntry; +} + +export function EnhancedAgentCard({ agent }: EnhancedAgentCardProps): JSX.Element { + const statusLabel = + agent.latestStatus !== null ? getAuditStatusLabel(agent.latestStatus) : "No audits"; + const statusClass = agent.latestStatus !== null + ? `status-badge status-badge--${statusLabel.toLowerCase()}` + : "status-badge status-badge--none"; + const scoreLabel = + agent.latestScore !== null ? String(Number(agent.latestScore)) : "--"; + const freshness = getAuditFreshness(agent.lastAuditAt); + + return ( +
  • + +
    +
    +

    + {agent.agentName || `Agent #${agent.tokenId}`} +

    + {statusLabel} +
    + {agent.riskLevel ? ( + + {agent.riskLevel.label} + + ) : null} +
    + +
    + + Token #{agent.tokenId} + + + {truncateAddress(agent.developer)} + + {agent.attestationVerified ? ( + + TEE Verified + + ) : null} +
    + +
    +
    + {scoreLabel} + Score +
    +
    + + {String(Number(agent.auditCount))} + + Audits +
    + {agent.reputationScore !== null ? ( +
    + + {((agent.reputationScore / 10000) * 100).toFixed(0)}% + + Reputation +
    + ) : null} + {agent.pricing?.configured ? ( +
    + + {formatPriceEth(agent.pricing.pricePerDay)}/day + + Rental +
    + ) : null} +
    + + {freshness.label} + + Last Audit +
    +
    + +
  • + ); +} diff --git a/frontend/src/components/LeaderboardSection.tsx b/frontend/src/components/LeaderboardSection.tsx new file mode 100644 index 0000000..8bf516a --- /dev/null +++ b/frontend/src/components/LeaderboardSection.tsx @@ -0,0 +1,119 @@ +import { Link } from "react-router-dom"; +import type { AgentListEntry } from "./AgentListItem"; +import { formatPriceEth } from "../lib/format"; + +export type LeaderboardCategory = "score" | "reputation" | "popular" | "fresh"; + +interface LeaderboardSectionProps { + agents: AgentListEntry[]; + category: LeaderboardCategory; + onCategoryChange: (cat: LeaderboardCategory) => void; +} + +const CATEGORY_OPTIONS: ReadonlyArray<{ value: LeaderboardCategory; label: string; icon: string }> = [ + { value: "score", label: "Top Scored", icon: "๐Ÿ†" }, + { value: "reputation", label: "Best Reputation", icon: "โญ" }, + { value: "popular", label: "Most Popular", icon: "๐Ÿ”ฅ" }, + { value: "fresh", label: "Recently Audited", icon: "โœจ" } +]; + +function getRankedAgents(agents: AgentListEntry[], category: LeaderboardCategory): AgentListEntry[] { + const copy = [...agents]; + switch (category) { + case "score": + return copy + .filter((a) => a.latestScore !== null) + .sort((a, b) => Number(b.latestScore) - Number(a.latestScore)) + .slice(0, 10); + case "reputation": + return copy + .filter((a) => a.reputationScore !== null) + .sort((a, b) => (b.reputationScore ?? 0) - (a.reputationScore ?? 0)) + .slice(0, 10); + case "popular": + return copy + .sort((a, b) => (b.reputationScore ?? 0) - (a.reputationScore ?? 0)) + .slice(0, 10); + case "fresh": + return copy + .filter((a) => a.lastAuditAt > 0) + .sort((a, b) => b.lastAuditAt - a.lastAuditAt) + .slice(0, 10); + default: + return copy.slice(0, 10); + } +} + +function getMetricDisplay(agent: AgentListEntry, category: LeaderboardCategory): string { + switch (category) { + case "score": + return agent.latestScore !== null ? `Score ${Number(agent.latestScore)}` : "--"; + case "reputation": + return agent.reputationScore !== null + ? `Rep ${((agent.reputationScore / 10000) * 100).toFixed(0)}%` + : "--"; + case "popular": + return agent.pricing?.configured + ? `${formatPriceEth(agent.pricing.pricePerDay)}/day` + : "Not listed"; + case "fresh": { + if (agent.lastAuditAt <= 0) return "No audits"; + const days = Math.floor((Date.now() / 1000 - agent.lastAuditAt) / 86400); + return days === 0 ? "Today" : `${days}d ago`; + } + default: + return "--"; + } +} + +export function LeaderboardSection({ + agents, + category, + onCategoryChange +}: LeaderboardSectionProps): JSX.Element { + const ranked = getRankedAgents(agents, category); + + return ( +
    +

    Leaderboard

    +

    Top Agents

    +
    + {CATEGORY_OPTIONS.map((opt) => ( + + ))} +
    + + {ranked.length === 0 ? ( +

    No agents available for this ranking yet.

    + ) : ( +
      + {ranked.map((agent, idx) => ( +
    1. + + {idx === 0 ? "๐Ÿฅ‡" : idx === 1 ? "๐Ÿฅˆ" : idx === 2 ? "๐Ÿฅ‰" : idx + 1} + + + + {agent.agentName || `Agent #${agent.tokenId}`} + + {agent.riskLevel ? ( + + {agent.riskLevel.label} + + ) : null} + + {getMetricDisplay(agent, category)} +
    2. + ))} +
    + )} +
    + ); +} diff --git a/frontend/src/components/MarketplaceHero.tsx b/frontend/src/components/MarketplaceHero.tsx new file mode 100644 index 0000000..12a9ac2 --- /dev/null +++ b/frontend/src/components/MarketplaceHero.tsx @@ -0,0 +1,123 @@ +import { type FormEvent, useState } from "react"; +import { useNavigate } from "react-router-dom"; + +import { parseTokenIdInput } from "../lib/tokenId"; + +interface MarketplaceHeroProps { + totalAgents: number; + attestedCount: number; + averageScore: number | null; +} + +export function MarketplaceHero({ + totalAgents, + attestedCount, + averageScore +}: MarketplaceHeroProps): JSX.Element { + const navigate = useNavigate(); + const [showLookup, setShowLookup] = useState(false); + const [tokenId, setTokenId] = useState(""); + const [error, setError] = useState(null); + + function handleSubmit(event: FormEvent): void { + event.preventDefault(); + const parsed = parseTokenIdInput(tokenId); + if (!parsed.ok) { + setError(parsed.error); + return; + } + setError(null); + navigate(`/agent/${parsed.normalized}`); + } + + const hasData = totalAgents > 0; + + return ( +
    +
    AgentLens โ€” Trusted Agent Marketplace
    +

    + Before You Hire an AI Agent,
    Know Exactly What You're Getting +

    +

    + Every agent here has been audited on-chain, stress-tested in a sandboxed environment, + and verified through TEE attestation. You see the risk profile, the evidence, and the + track record โ€” before you commit. +

    + + {hasData ? ( +
    +
    + {totalAgents} + Agents Listed +
    +
    + {attestedCount} + TEE Verified +
    +
    + + {averageScore !== null ? averageScore : "--"} + + Avg Audit Score +
    +
    + ) : ( +
    +

    + The first marketplace where AI agent trust is verifiable, not just claimed. + Agents are being audited and listed โ€” check back soon. +

    +
    + )} + +
    +
    + ๐Ÿ” +
    + Buyers +

    Browse audited agents, compare risk profiles, and access only what you trust.

    +
    +
    +
    + ๐Ÿš€ +
    + Developers +

    List your agent, pass the audit, and build a verifiable reputation on-chain.

    +
    +
    +
    + ๐Ÿ›ก๏ธ +
    + Auditors +

    Run sandboxed evaluations, submit dimensional scores, and anchor evidence on-chain.

    +
    +
    +
    + + + + {showLookup ? ( +
    + + setTokenId(event.target.value)} + /> + {error ?

    {error}

    : null} + +
    + ) : null} +
    + ); +} diff --git a/frontend/src/components/NavHeader.test.tsx b/frontend/src/components/NavHeader.test.tsx index 4b39b7c..9e68d67 100644 --- a/frontend/src/components/NavHeader.test.tsx +++ b/frontend/src/components/NavHeader.test.tsx @@ -17,7 +17,7 @@ describe("NavHeader", () => { ); - const brand = screen.getByText("Agent Shenji"); + const brand = screen.getByRole("link", { name: /agent shenji/i }); expect(brand).toHaveAttribute("href", "/"); }); diff --git a/frontend/src/components/NavHeader.tsx b/frontend/src/components/NavHeader.tsx index c3e920f..61ae6d0 100644 --- a/frontend/src/components/NavHeader.tsx +++ b/frontend/src/components/NavHeader.tsx @@ -7,7 +7,7 @@ interface NavHeaderProps { } export function NavHeader({ - title = "Agent Shenji", + title = "AgentLens", backHref, backLabel = "Back" }: NavHeaderProps): JSX.Element { @@ -15,13 +15,16 @@ export function NavHeader({
    - {title} + Popo + {title} {backHref ? ( - {backLabel} + {backLabel} - ) : null} + ) : ( + Verify Before You Buy + )}
    ); diff --git a/frontend/src/components/PopoWelcome.tsx b/frontend/src/components/PopoWelcome.tsx new file mode 100644 index 0000000..62ca807 --- /dev/null +++ b/frontend/src/components/PopoWelcome.tsx @@ -0,0 +1,8 @@ +/** + * PopoWelcome โ€” the actual popup logic lives in index.html