Skip to content

Latest commit

 

History

History
25 lines (13 loc) · 1.67 KB

design_pattern_decisions.md

File metadata and controls

25 lines (13 loc) · 1.67 KB

Design Pattern Decisions

General considerations

Vehicle Lifecycle Token NFT is implemented based on ERC721 standard with Enumerable and Metadata features. Main contract VehicleLifecycleToken is inherited from openzeppelin ERC721 implementation.

Metadata interface

To save on-chain storage space (thus reducing cost) and support potentially unlimited amount of information associated with NFT (stored securely and in immutable form) it was decided to store metadata separately from data.

Openzeppelin ERC721 already implements metadata interface (ERC721Metadata) to have additional fields (name, description, image).

Openzeppelin ERC721URIStorage implementation is used to store arbitrary link to metadata json file on IPFS.

Enumerable interface

To simplify UI part and have an ability to iterate over tokens owned by particular address ERC721Enumerable selected as a second base contract for VehicleLifecycleToken.

Main methods that are widely used tokenOfOwnerByIndex to enumerate tokens for address and totalSupply+tokenByIndex to enumerate all tokens.

Security model

Main contract VehicleLifecycleToken is also inherited from openzeppelin Ownable implementation to set ownership to deployer to keep control on contract and have ability to transferOwnership to another account if necessary. This could simplify compliance aspects of production deployment.

To segregate permissions for participants (Government, Manufacturers, ServiceFactories, and PoliceDepartments) openzeppelin AccessControl smart contract is used. So all public methods that change state variables are restricted to particular role.