I have struct in an external contract that I need access to
Contract Ext{
Struct user{
uint dailybalance;
}
mapping ( address => user[] ) userDailyBalances;
}
How do I access the dailybalance for a specific index in the mapped array of structs?
Contract Need{
function need(){
Ext x = Ext ( Extcontractaddress );
uint256 bal = x.userDailyBalances( msg.sender )[0].dailybalance;
}
}
Does not work nor does
x.userDailyBalances( msg.sender[0].dailybalance )
nor
x.userDailyBalances( msg.sender.[0].dailybalance )
Best Answer
You are trying to access the storage of the external contract directly which is not allowed. Refer here.
You need to have a getter method implemented inside the external contract to make this feasible.
External Contract:
Your Contract:
Hope this helps.