-
Notifications
You must be signed in to change notification settings - Fork 161
feat: Add Contract Metadata Standard #330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
8802cb5
27a855d
89f044c
9617b09
1bd0767
657dd68
4add736
63c3267
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Contract Metadata | ||
|
|
||
| ## [NEP-330](https://github.com/near/NEPs/discussions/329) | ||
|
|
||
| Version `1.0.0` | ||
|
|
||
| ## Summary | ||
|
|
||
| The contract metadata is a standard interface to allow for auditing and viewing source code for a deployed smart contract. Implementation of this standard is purely optional but is recommended for developers whose contracts are open source. | ||
|
|
||
| ## Motivation | ||
|
|
||
| There is no trivial way of finding the source code or author of a deployed smart contract. By having a standard that outlines how to view the source code of an arbitrary smart contract, an environment of openness and collaboration is created. | ||
BenKurrek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The initial discussion can be found [here](https://github.com/near/NEPs/discussions/329). | ||
|
|
||
| ## Interface | ||
|
|
||
| Metadata applies at the contract level (`ContractMetadata`): | ||
|
|
||
| ```ts | ||
| type ContractMetadata = { | ||
| version: string|null, // optional, commit hash being used for the currently deployed wasm. If the contract is not open-sourced, this could also be a numbering system for internal organization / tracking such as "1.0.0" and "2.1.0". | ||
| link: string|null, //optional, link to open source code such as a Github repository or a CID to somewhere on IPFS. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BenKurrek @austinabell @MaximusHaximus what are your thoughts of adding a system field so we can get some info on what system helped generate the wasm as well. This way we can try to rebuild the wasm and compare the hashes for auditing purposes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, you would need architecture and toolchain version at least. Would the purpose of this be human-readable so someone could try to replicate it? You would also need some commit or version since the link doesn't specify repo links to commit that it was built with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah ideally i want to be able to reference the source code and source dependencies to help with auditing the contract. Here's what polygon does which is pretty cool: https://polygonscan.com/address/0x217cF04C783818E5b15Ae0723b22Ee2415Ab5fe3#code
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was assuming that the toolchain version would be kept in the Github repo. I don't really see the need to add a system field but would love other people's opinions
Comment on lines
+30
to
+32
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about adding some sort of organization contact link as well that points to the website of the application, or the developers; potentially with more contact information! The difference between it and
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this information could be found by utilizing the thoughts? @austinabell @agileurbanite
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would actually go even further and provide three different fields (similar to crates.io): Some services like npm only have |
||
| } | ||
| ``` | ||
|
|
||
| A new function for querying the metadata must be supported on each smart contract implementing the standard: | ||
|
|
||
| ```ts | ||
| function contract_metadata(): ContractMetadata {} | ||
| ``` | ||
|
|
||
| It is up to the author of the contract to keep the version and link up to date when new code is deployed. They can choose to update the metadata with a setter, have it static on the contract, or any other way of their choosing. | ||
|
|
||
| ### An implementing contract MAY include the following fields on-chain | ||
|
|
||
| - `version`: a string that references the specific commit hash or version of the code that is currently deployed on-chain. This can be included regardless of whether or not the contract is open-sourced and can also be used for organizational purposes. | ||
| - `link`: a string that references the link to the open source code. This can be anything such as Github or a CID to somewhere on IPFS. | ||
BenKurrek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Future possibilities | ||
|
|
||
| - By having a standard outlining metadata for an arbitrary contract, any information that pertains on a contract level can be added based on the requests of the developer community. | ||
Uh oh!
There was an error while loading. Please reload this page.