0

I have been using EternalStorage contract with my contracts for the storage purpose. Now the structure is some like this:

Eternal Storage <- Contract (A) <- Contract (B) <- Contract (C)

Now on deploying the contracts together using deploy and link function in the migration file Eternal Storage and Contract A are deployed properly but when it comes on Contract (B)'s deployment. It burst out with an error stating that Contract (B) is an abstract contract or an interface and cannot be deployed.

Contract Eternal Storage:
    pragma solidity ^0.5.1;


    contract EternalStorage{

      struct Storage {
        mapping(bytes32 => address) _address;
        mapping(bytes32 => string) _string;
       }

      Storage internal s;

      address public owner;

     function setString(bytes32 h, string memory v) public  {
        s._string[h] = v;
     }

function getString(bytes32  h) public view returns (string memory){
    return s._string[h];
  }

function setAddress(bytes32 h, address v) public  {
    s._address[h] = v;
  }
function getAddress(bytes32 h) public view returns (address){
    return s._address[h];
  }
}

Contract A:

       pragma solidity ^0.5.1;

        contract EternalStorage {

            function setString (
                bytes32 h,
                string memory v
                ) public;

            function getString (
                bytes32 h
                ) public view returns (
                    string memory
                );
function setAddress (
        bytes32 h,
        address v
        ) public;

    function getAddress (
        bytes32 h
        ) public view returns (
            address
        );


        }

        contract Contract(A){

              EternalStorage s;

constructor(address _mySign) public {

         s = EternalStorage(_mySign);
    }

    struct Agreement {
        bytes32  id;
        address owner;
        string hash;
}            

function createData(
             bytes _id,
             address _owner,
             string memory _hash) public returns (bool success) {

            Data[_id].id = _id;
            Data[_id].owner = _owner;
            Data[_id]._hash = _hash;

    s.setAddress(keccak256(abi.encodePacked("Agreement - Owner",_id)), agreements[_id].owner);
            s.setString(keccak256(abi.encodePacked("Agreement - FileHash",_id)), agreements[_id].fileHash);

    }

}

Contract B:

pragma solidity ^0.5.1;

import "./Contract(A).sol";

contract Contract(B) is Contract(A) {

  constructor(
        address _mySign
        ) public {
        s = EternalStorage(_mySign);

   }

function getData(
    bytes32 _id,
    string memory _hash,
    address _owner
    ) public returns (bool success) {
    s.setAddress(keccak256(abi.encodePacked("data- crypto",_id)), data[_id].owner);
    s.setString(keccak256(abi.encodePacked("data- crypto",_id)), data[_id]._hash);
}
}

Error is displayed below:

Error: Error: Error:  ** Deployment Failed **                                                                                                     

"Contract(B)" is an abstract contract or an interface and cannot be deployed.                                                            
   * Import abstractions into the '.sol' file that uses them instead of deploying them separately.                                                  
   * Contracts that inherit an abstraction must implement all its method signatures exactly.                                                        
   * A contract that only implements part of an inherited abstraction is also considered abstract.                                                  

    at Object.run (C:\Users\shparmar\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-migrate\index.js:92:1)                
    at process._tickCallback (internal/process/next_tick.js:68:7)

Truffle v5.0.26 (core: 5.0.26)
Node v10.16.0

Can anyone help me out with this stuff?

  • to begin with I strongly recommend not to use () in your contract name - it's probably even not allowed. – Lauri Peltonen Sep 3 at 12:20
  • And to continue with, your indentation is totally messed up. Your entire code looks obfuscated, and it makes one wonder why you are obfuscating your code to those you ask help from. Please fix it! – goodvibration Sep 3 at 12:29
  • To answer your question - Not even one function in contract EternalStorage is implemented - what exactly did you expect to happen??? You cannot instantiate (create an instance of) such contract, because it is abstract (not ALL functions implemented)! – goodvibration Sep 3 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.