0

I work on Truffle. My contract is A and its function is infoRep(). infoRep() returns some data. Whenever i call the function in Truffle console the below error occurs:

Error: Returned error: VM Exception while processing transaction: invalid opcode    at PromiEvent (C:\Users\lenovo\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\contract\lib\promievent.js:9:1)

I don't know what is the solution. Please guide me to solve the problem.

A:

pragma solidity ^0.5.12;
contract A{
bytes[] info;
    function infoRep() public returns(string memory, string memory, string memory, string memory){
        info[0]="Alireza Kiakojouri";
        info[1]="500";
        info[2]="0098";
        info[3]="AUT";
           return(string(info[0]), string(info[1]), string(info[2]), string(info[3]));
    }
}
0

Change this:

bytes[] info;

To this:

bytes[4] info;

Or this:

info[0]="Alireza Kiakojouri";
info[1]="500";
info[2]="0098";
info[3]="AUT";

To this:

info.push("Alireza Kiakojouri");
info.push("500");
info.push("0098");
info.push("AUT");

But not both!

| improve this answer | |

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.