pragma solidity ^0.4.17;

contract Signature{

struct signature {
    string value;
    uint rate;
    address sender_acc;
    
}

signature[5] public unverified_sig; // struct array is fixed but I want dynamic, if i del 5 then it 
                                    //gives error  mentioned in the end


function add_signature(string rec_signature) public {
    unverified_sig[0].sender_acc=msg.sender;
    unverified_sig[0].value=rec_signature;
    unverified_sig[0].rate=0;
}

}

Output Error: transact to Signature.add_signature errored: VM error: invalid opcode. invalid opcode The execution might have thrown. Debug the transaction to get more information.

1

There are 1 best solutions below

1
On

Which version of Solidity do you use? I compiled with 0.5.0 in Remix. There isn't any problem with the dynamic array of struct. But there is a warning about the gas cost of the function that is too high which will exceed the gas limit.

Gas requirement of function Storage.add_signature is infinite: If the gas requirement of a function is higher than the block gas limit, it cannot be executed. Please avoid loops in your functions or actions that modify large areas of storage (this includes clearing or copying arrays in storage)