Hi! We’re the HonestNFT Protocol development team.
We’re first working on v1 of the 3 smart contracts relevant in our architecture. Here’s an outline of the contracts written so far.
You can check out the github repo here: GitHub - Honest-Protocol/honest-protocol-v0.1
This is the first version of many, so we appreciate any questions, feedback, and comments!
Overview
Label Contract
Label contract is, in essence, the on-chain database of labels for audited NFT collections. It is designed to hold all the NFT collections, the label values of each NFT collection, and the proof of those labels for the NFT collection. For example, it would hold the address of the Vigilante NFT collection, 1 for “Commit-Reveal” Label, and a pointer (ex. an IPFS link) to the proof of commit-reveal for the Vigilante NFT collection.
Filter Factory Contract
Filter Factory contract is designed to create and hold “filters” or selections of labels that a user will deem relevant for their use case. APIs, users, or other contracts can interact directly with this contract to determine if a NFT collection meets their filter criteria.
Filter Contract
Filter Contract is where APIs, users, or contracts interact directly with this contract to determine if a NFT collection meets this particular filter’s criteria.
Overall notes
-
Throughout these contracts, you will see the label values and filters in the form of a
uint256
. This is because we are treating theuint256
as simply an array of booleans, where the 0th place bool pertains to label 0 (let’s say, level of gas fees), the first place bool pertains to label 1 (let’s say, uniformity of rarity map distribution), etc. The label ↔ index assignment follows the order in which label types are added to the label contract. -
v1 does not include the consensus mechanisms (where auditors and agree/disagree, and validators confirm the audit). That will be added later. Ergo, in order to audit an NFT collection through these contracts, you must be a whitelisted auditor (see Label Contract).
Technical Details
Label Contract
Main variables (excluding helper variables):
-
mapping(address => LabelData) labelInfo
: nested map containing label data for all NFT collections-
LabelData
is astruct
containing 1) labelValues and 2) the proofs
-
-
mapping(address => bool) whiteListedAuditors
: keeps track of who is allowed to edit label data (for v1 only) -
mapping(string => uint256) labelIndices
andstring[] labelIndicesKeys
: keeps track of which index of theuint256
refers to which label.
Public methods:
For reading label data:
-
getLabelOfAsset(address asset, uint256 labelIndex) returns (bool)
: gets label value for a single label type (defined by its index, e.g. 0) of an NFT collection. -
getLabelOfAsset(address asset, string calldata labelName) returns (bool)
: gets label value for a single label type (defined by its name, e.g. “COMMIT REVEAL”) of an NFT collection. -
getLabelData(address asset) returns (uint256)
: gets data for all labels of an asset, represented as an array of bools (uint256
) -
getProofs(address asset) returns (string[] memory)
: gets the array of proofs for all labels for a given NFT collection -
getProof(address asset, string calldata _label) returns (string memory)
: gets the proof for a specific label of a specific NFT collection.
For editing label data:
-
editLabelData(address asset, string calldata _label, bool _labelValue, string calldata _labelProof)
: changes the value of a single label for a single NFT collection (and adds the proof of this audit) -
editMultipleLabelsForAsset(address asset, string[] calldata labelsToChange, bool[] calldata newValues, string[] calldata proofs)
: changes the values of multiple labels for a single NFT collection (and adds the respective proofs) -
editLabelForMultipleAssets(string calldata labelName, address[] calldata assets, bool[] calldata newValues, string[] calldata proofs)
: changes the values of a single label but for multiple NFT collections (and adds the respective proofs)
For adding a new label type/metric in general:
addLabel(string calldata _newLabel)
Other:
-
addWhitelistAuditor(address newAuditor)
: whiteLists a new auditor address. (can only be done by the owner of the Label contract)
Filter Factory Contract
Main variables:
-
mapping(uint256 => mapping(uint256 => address)) getFilterAddress
: nested map to get the address of existing filters. The key of the outer map is auint256
representing which labels must be compared in order for an NFT collection to pass that filter (AKAlabelsRequired
). The key of the inner map is auint256
representing what those required label values must be (AKAvaluesRequired
). (E.g. Not all of the booleans in the inner key will be looked at.)
Public Methods:
-
createFilter(uint256 labelsRequired, uint256 valuesRequired) returns (address newFilter)
: creates a new filter given a novel (labelsRequired, valuesRequired) pair. If the pair already exists as a filter, it will through an error. Returns the address of the new created filter. -
getMissedCriteria(address asset, uint256 labelsRequired, uint256 valuesRequired) external view returns (uint256 passes)
: returns the boolean array (uint256
) representing which labels of the NFT collection didn’t pass the filter. For example, if the returned value ends in …010, that means that the label corresponding to index 1 didn’t meet the filter criteria.
Filter Contract
Main variables:
-
uint256 labelsRequired
: a boolean array representing what labels this filter “cares” about. It will only check these labels when evaluating an NFT collection. -
uint256 valuesRequired
: a boolean array representing what values the filter requires for the labels it cares about. For example, if labelsRequired ends with a 1 (i.e.labelsRequired
is odd) andvaluesRequired
ends with a 1 as well, then the label corresponding to index 0 NFT collection
Methods:
-
initialize(uint256 _labelsRequired, uint256 _valuesRequired, address _labelContract)
: initializes the new filter contract with the labelsRequired and valuesRequired (called by filterFactory) -
getUnknowns(address assetAddress) returns (uint256)
: returns a boolean array (uint256
) of the traits that have not been audited yet. -
getMissedCriteria(address assetAddress) returns (uint256)
: returns boolean array (uint256
) of the traits that did not pass the filter (either because it was explicitly audited to be a different value, or because it had not been audited yet)