0

I am facing a head scratching issue. I have created two contracts UserRole which has a map of username to a role and a Base contract that has a modifier which checks if the role is < 10.

So I deploy the first UserRole contract first and then I called the set function with the parameters _username = "jamesbond" and _role=7.

After the transaction is mined I call the getRole passing _username = "jamesbond" and I get back 7.

Now I deploy Base and pass the address of the the UserRole contract that I deployed earlier. I call the testModifier function and I pass it _username = "jamesbond". I expect that I get the value 7 back.

I tested this on http://remix.ethereum.org first. Then I tried it on quorum and parity. On remix it works as expected but on both quorum and parity I do not get any values back.

I am not sure what I am doing wrong.

pragma solidity ^0.4.24;

contract UserRole {
    address owner;

    mapping (string => uint8) userRoles;

    constructor() 
        public
    {
        owner = msg.sender;
    }

    function set(string _username, uint8 _role) 
        public
        returns (bool sucesss)
    {
        userRoles[_username] = _role;
        return true;
    }

    function getRole(string _username) 
        public
        view
        returns (uint8 _role)
    {
        return userRoles[_username];
    }
}

contract Base {
    address owner;
    UserRole userRole;
    address public userRoleAddress;

    constructor(address _t) 
        public
    {
        owner = msg.sender;
        userRoleAddress = _t;
        userRole = UserRole(_t);
    }


    modifier isAuthorized(string _username) {
        uint8 role = 5;
        require(role < 10);
        _;
    }

    function testModifier(string _username)
        public
        isAuthorized(_username)
        view
        returns (uint8 result)
    {
        return userRole.getRole(_username);
    }
}
shresthaal
  • 675
  • 4
  • 13
  • 28

1 Answers1

0

I have faced similar issues when compiling the contract with Remix. The solution is as follows:

  1. Install solcjs using

    npm install -g solc It will provide executable binary of solcjs.

    2.Create two file named UserRole.sol and Base.sol and copy the respective code in the files. Compile both the contracts using solcjs compiler (binary installed in your system.).

    solcjs -o output --bin --abi UserRole.sol

    solcjs -o output --bin --abi Base.sol

  2. It will produce two abi and two bin file inside output folder.

  3. Use these abi and bin of respective contracts to create similar script like web3deploy and deploy them in quorum or parity.

This will work.

geekybot
  • 128
  • 10