I can push worker address to mapping with manager address. I try to get manager address like this code.

contract Test {

   struct Worker{
        address manager_add;
        address worker_add;

   mapping(address => Worker[]) manager;

   function setWorkerAddress(address worker_add) public{

      manager[msg.sender].push(Worker(msg.sender, worker_add));  // push worker address map with manager address


   function getManagerAddress() public returns(uint){
      return manager[msg.sender].x;  // worker get manage address

It show error like this.

TypeError: Return argument type address is not implicitly convertible to expected type (type of first return variable) uint256.
  --> contracts/test.sol:21:14:
21 |       return manager[msg.sender][index].manager_add;
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

How to fix it?

1 Answer 1


You are trying to see the address of the worker's manager. Because you are returning an address, you have to change function getManagerAddress(uint index) public returns(uint) to function getManagerAddress(uint index) public returns(address)

Your Answer

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

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