0

I come from nodejs and this seems odd to me.. can't seem to push anything to a temporary array.

    function get_unconfirmed() public view returns (address[] memory, uint[] memory, uint[] memory) {
   
        address     [] memory _address;
        uint        [] memory _wei;
        uint256     [] memory _ssboe;

        for(uint i = 0; i < deposit_request.length; i++){
            
            if(deposit_request[i]._confirmed){
                _address.push(deposit_request[i]._owner);
                _wei.push(deposit_request[i]._value);
                _ssboe.push(deposit_request[i]._ssboe);
            }

        }

        return (_address, _wei, _ssboe);
    }
0

It is not possible memory arrays have a fixed size and you need to allocate the space previous assigning it.

For example something like this:

    address[] memory _address;

    uint256 count = 0;

    for (uint i = 0; i < deposit_request.length; i++){
        if (deposit_request[i]._confirmed){
            ++count;
        }
    }

    _address = new address[](count);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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