0

I cannot get my code to compile under 0.8.18.

I get the error:

Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
  --> contracts/Provenance.sol:14:3:
   |
14 |        constructor(bytes32 _UID, bytes mem ... , bytes memory _PhotoHash) public {
   |        ^ (Relevant source part starts here and spans across multiple lines).

Here is the offending code snippet:

pragma solidity ^0.8.18;

    contract Object {
        bytes32 private UID;
        bytes private Desc;
        uint    private ObjectValue;
        uint    private LastPrice;
        uint    private CertificateDate;
        bytes   private DocCID;
        bytes   private PhotoCID;
        bytes   private DocHash;
        bytes   private PhotoHash;

        constructor(bytes32 _UID, bytes memory _Desc, uint _ObjectValue, uint _LastPrice, uint _CertificateDate, bytes memory _DocCID, bytes memory _PhotoCID, bytes memory _DocHash, bytes memory _PhotoHash) public {
            UID             = _UID;
            Desc            = _Desc;
            ObjectValue     = _ObjectValue;
            LastPrice       = _LastPrice;
            CertificateDate = _CertificateDate;
            DocCID          = _DocCID;
            PhotoCID        = _PhotoCID;
            DocHash         = _DocHash;
            PhotoHash       = _PhotoHash;
            }

        function getUID() view public returns (bytes32) {
            return UID;
            }

        function getDesc() view public returns (bytes memory) {
            return Desc;
            }

        function getObjectValue() view public returns (uint) {
            return ObjectValue;
            }

        function getLastPrice() view public returns (uint) {
            return LastPrice;
            }

        function getCertificateDate() view public returns (uint) {
            return CertificateDate;
            }

        function getDocCID() view public returns (bytes memory) {
            return DocCID;
            }

        function getPhotoCID() view public returns (bytes memory) {
            return PhotoCID;
            }

        function getDocHash() view public returns (bytes memory) {
            return DocHash;
            }

        function getPhotoHash() view public returns (bytes memory) {
            return PhotoHash;
            }

        function isDocAuthentic(bytes memory _testDocHash) view public returns (bool) {
            if (keccak256(abi.encodePacked(DocHash))  == keccak256(abi.encodePacked(_testDocHash)))
                return true;
            else
                return false;
            }

        function isPhotoAuthentic(bytes memory _testPhotoHash) view public returns (bool) {
            if (keccak256(abi.encodePacked(PhotoHash))  == keccak256(abi.encodePacked(_testPhotoHash)))
                return true;
            else
                return false;
            } // function isPhotoAuthentic(bytes32 _testPhotoHash)

        function getBalances() public view returns (uint, uint) {
            return (ObjectValue, LastPrice);
            } // function getBalances() public view returns (uint, uint)

    } // Object

I last compiled it using pragma solidity ^0.7.6 so I am not surprised, but I don't understand the error...

Can someone please help?

1 Answer 1

1

remove public in constructor().

1
  • Thank-you! I feel rather foolish... :-) Commented Jun 27, 2023 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.