CRYPTO NEWS

How to get index from Mapping array in Solidity/Remix?

I want to create solity for manager set permission to worker.

  1. Manager can set permission to worker by push address of worker to mapping array.
  2. After manager push worker address to mapping array then worker see address of manager.

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?

How to get index from Mapping array in Solidity/Remix?

Shopping cart
There are no products in the cart!
Continue shopping
0