I am trying to create different structs by passing the necessary components of the struct through an array in the arguments. So far, the compiler does not complain but when i execute the transaction, it doesn't show that the structs have been created. This is how the code looks. Any way I can create different structs with one call by passing the necessary components of the struct in the arguments?

 struct Schedule {
        uint releaseTime;
        bool signed;
    struct Beneficiary {
        bool isAuthorized;
        uint percentage;
        uint received;
    mapping(address => Beneficiary) private _beneficiaries;
    mapping(address => uint) internal rewards;
    address[] internal _beneficiariesList;
    mapping(uint => Schedule) private _schedules;
    Schedule[] internal _schedulesList;

constructor(address[] memory beneficiaries, uint[] memory _percentages, uint[] memory schedules) public {
        require(beneficiaries.length == _percentages.length, 'Beneficiary and percentage arrays must have the same length');
        for(uint i = 0; i < _beneficiariesList.length; i++) {
            _beneficiaries[_beneficiariesList[i]].isAuthorized = true;
            _beneficiaries[_beneficiariesList[i]].percentage = _percentages[i];
            uint _totalPercentage = 0;
            _totalPercentage = _totalPercentage.add(_beneficiaries[_beneficiariesList[i]].percentage);
            require(_totalPercentage == 100, 'Percentages must sum up to 100');
        for(uint s = 0; s < _schedulesList.length; s++) {
            _schedulesList[s].releaseTime = now + schedules[s];

1 Answer 1


On the first line of second for loop did you mean to populate _schedules mapping instead of _schedulesList array? if not then change

            _schedulesList[s].releaseTime = now + schedules[s];


            _schedules[s].releaseTime = now + schedules[s];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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