Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sample package 2.0 contract
contract RepoPackage {
event NewVersion(uint256 versionId, uint16[3] semanticVersion);
struct Version {
uint16[3] semanticVersion;
address contractAddress;
bytes contentURI;
mapping (bytes32 => Version) versions;
function newVersion(uint16[3] _newSemanticVersion, address _contractAddress, bytes _contentURI) public {
versions[semanticVersionHash(_newSemanticVersion)] = Version(_newSemanticVersion, _contractAddress, _contentURI);
function getBySemanticVersion(uint16[3] _semanticVersion) public view returns (uint16[3], address, bytes);
Version storage version = versions[semanticVersionHash(_semanticVersion)];
return (version.semanticVersion, version.contractAddress, version.contentURI);
function semanticVersionHash(uint16[3] version) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(version[0], version[1], version[2]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment