In my PersonalInfo.sol file I want to pass address array Users(maybe by function SendUserArray, but I don't know how...) to another contract System.sol file. Is it possible to use import {Users} from PersonalInfo in System.sol to access the Users address array?

This is my PersonalInfo.sol

pragma solidity ^0.4.17;
contract PersonalInfo{
    address public userAddress;
    address public manager;
    address[] public Users;  // include Recruiters and Workers  

    modifier restricted (){
        require(msg.sender == manager);

    function PersonalInfo () public{
        manager = msg.sender;

    function AddUsers()public payable{
        if(msg.sender != manager)
    function SendUsersArray()public{


  • "Pass to another contract" - what does that even mean? Did you perhaps mean "pass to another contract's function"? In this case....... just pass it to that other contract's function when you call it. – goodvibration Sep 18 '19 at 7:26
  • @goodvibration Yes! I mean to pass the address array to another smart contract's function to access it. – Jessie Sep 18 '19 at 7:27
  • Well... what's stopping you from doing that? – goodvibration Sep 18 '19 at 7:28
  • I just want to check if it is technically possible... and see if there is any other better option of doing so? – Jessie Sep 18 '19 at 7:32
  • Yes, it is technically possible (though you'll only be able to access that array for reading of course). – goodvibration Sep 18 '19 at 7:46

There are three options:

  1. Call function in System contract, which will call PersonalInfo's Users function (automatically generated getter function, as Users array is public) and get the addresses (the function will have uint256 argument - address index in the array).

  2. Create a function that returns the whole array and again, call it from System contract.

  3. Call System's function that has an address array as an argument and pass Users array there.

Anyway, be careful, reading the whole array may be too expensive and (starting from some moment) will not fit in the block.

| improve this answer | |

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.