Aggregation Unter Aggregation wird bei SusScope2 die Zusammenfassung von mehreren Belegquellen für Treibhausgasemissionen zu einer Identität (Konto). Belegquellen können einzelne GHG-Wallets sein, wobei jede Aggregation für sich eine Identität ist. Dies hat zur Folge, dass die Emissionen aktiv mit einem Transfer von der Quelle an die Aggregation übertragen werden müssen. Aggregationen finden ausschließlich in der Distributed Ledger Technologie statt, weshalb benötigte Metadaten auf einem anderen Weg übertragen werden müssen. Solidity Smart-Contract - Aggregationpragma solidity ^0.8.6; import "@openzeppelin/contracts/access/Ownable.sol"; import "./GHGNFT.sol"; import "./GHGERC20.sol"; import "./GHGTOKEN.sol"; contract GHGAggregation is Ownable { GHGToken ghgToken; GHGERC20 ghgSavings; GHGERC20 ghgEmissions; GHGNFT ghgCertificates; uint256 public savings=0; uint256 public emissions=0; uint256 public cntNFTs=0; uint256 public cntAggregations=0; mapping (uint256 => uint256) public idToNft; mapping (uint256 => address) public adToNft; mapping (address => uint256) public approvedContributors; constructor(GHGToken _ghgToken) { ghgToken = _ghgToken; ghgSavings = _ghgToken.ghgSavings(); ghgEmissions = _ghgToken.ghgEmissions(); ghgCertificates = _ghgToken.ghgCertificates(); } function approveContributor(address _contributor) public onlyOwner { approvedContributors[_contributor] = 1; } function declineContributor(address _contributor) public onlyOwner { approvedContributors[_contributor] = 0; } function addNFT(uint256 _tokenId) public { if ((msg.sender != owner()) && (approvedContributors[msg.sender] == 0)) { revert(); } if(ghgCertificates.ownerOf(_tokenId) == address(this)) { for(uint256 i=0;i= bytes1('0') && bytes1(c) <= bytes1('9')) { return c - uint8(bytes1('0')); } if (bytes1(c) >= bytes1('a') && bytes1(c) <= bytes1('f')) { return 10 + c - uint8(bytes1('a')); } if (bytes1(c) >= bytes1('A') && bytes1(c) <= bytes1('F')) { return 10 + c - uint8(bytes1('A')); } return 0; } function hexStringToAddress(string memory s) public pure returns (bytes memory) { bytes memory ss = bytes(s); require(ss.length%2 == 0); // length must be even bytes memory r = new bytes(ss.length/2); for (uint i=0; i= 1 + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), 1)), 0x1000000000000000000000000) } return tempAddress; } }