I have a struct (Activity) where one of the arguments is an array of int. What i want to do is to initialize the struct and set the routinesID argument as an array like i did in the createActivity function but when i test the code on Remix i get this error:

The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance.

If you have any suggestions please help me, it would be very useful.

The Code:

  struct Activity {
        address owner;
        uint start;
        uint end;
        bool status;
        string activity;
        uint id;
        int[] routinesID;
    Activity[] public activities;    

function createActivity(
        uint _start,
        uint _end,
        string memory _activity
    ) public {
        int[] memory ids = new int[](activities.length);
        ids[0] = -1;

        Activity memory newActivity = Activity(

        activities[activities.length] = newActivity;

1 Answer 1


There isn't any declared size of the array. Instead of

activities[activities.length] = newActivity;



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.