0

pragma solidity ^0.8.4;

contract Vote {

address[] public Initiator;

function Initiator() public { Initiator = msg.sender;

}

}

1 Answer 1

0

When you want to put an element into an array you can use or: push() method or can specificy the index where this value must be stored like: array[index] = value;.

In your smart contract, you must change your method function name because it has the same name of address[] variable and then you can put the element into array using one of methods that I described you above.

Example:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

contract Vote {
    address[] public Initiator;

    function setInitiator() public { 
        Initiator.push(msg.sender);
    }

}

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.