I have the following contract:
pragma solidity ^0.4.18;
contract ReferralProgram {
// referrer => array of referrals
mapping (address=>address[]) private referrals;
function becomeReferral(address referrer) public {
require(referrer != 0x0);
referrals[referrer].push(msg.sender);
}
function getReferrals() public view returns (address[]) {
return referrals[msg.sender];
}
}
I call method becomeReferral
multiple times from different
accounts and specifying the same referrer
address (function parameter).
Then I call getReferrals
from referrer address and it returns empty array. It is possible use dynamic arrays in mappings? Documentation says:
_ValueType can actually be any type, including mappings.
What am I doing wrong? Thanks.
P.S Testing in remix browser