I am new to Solidity, and I am experimenting on smart contracts using Remix-IDE connected to a deployed local Geth instance.

What I am trying to do is to create a struct containing multiple fields for identification, sort of mimicking a consolidated identification system. I created a struct and a mapping to point to that struct. I need to separate the contracts for adding user information and reading user information. Code is below:

enter image description here

What I am finding is that I am unable to get any information when the get functions are in separate contracts from the set functions. The decoded output of the above is shown as an empty string:

enter image description here

But if I take all of the get functions and put them into the RegisterUserData contract, it is able to make successful calls and produce the right output:

enter image description here

Could anyone help?


  • Please, provide any source code and error message as text. It is much easier for testing.
    – Ismael
    Commented Feb 28, 2023 at 4:21

1 Answer 1


Here, you have inheritence issue in ObtainUserData contract. You need to inherit RegisterUserData or both the contract.


contract ObtainUserData is VariableDefination, RegisterUserData {}

Then deploy ObtainUserData contract to see the result.

Note: you have to deploy only ObtainUserData contract. If you deploy other contracts as well this will not work. Though you have code splitted using different contracts deployment should be one which is inheriting other contract.

  • Hi Safi, thanks for your response. You are correct -- it did work. But isn't this approach the same as just combining all the functions into a single contract? Is there a way in Solidity to have some functions within a smart contract deployable only by select users (or addresses)? My goal was to have some users have "write" access and some only have "read" access which is why I initially separated the get and set functions. Thanks.
    – AAA
    Commented Feb 26, 2023 at 9:42
  • Yes it is same as combining all functions together, but it is good approach for huge code base not for contract with limited small code base. Regarding accessibility of the functions you have to learn about modifiers. Using modifier you can apply some logic to restrict the write access of the functions. You can refer openzeppelin Ownable contract in this case.
    – Safi
    Commented Feb 26, 2023 at 10:04

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.