Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: invalid data for function output #764

Closed
thecircleoflifefree opened this issue Mar 24, 2020 · 3 comments
Closed

Error: invalid data for function output #764

thecircleoflifefree opened this issue Mar 24, 2020 · 3 comments
Labels
discussion Questions, feedback and general information.

Comments

@thecircleoflifefree
Copy link

thecircleoflifefree commented Mar 24, 2020

Hello Richard Sir,

I am currently experiencing a similar problem to issue #521

This is the complete error I get:

Error: invalid data for function output (arg="data", errorArg="type", errorValue="Bit", value="0x0000000000000000000000000000000000000000000000000000000000000001", reason="invalid type", version=4.0.45)

This is the contract I am using(tested on remix with 0.5.1 compiler):

[pragma solidity >=0.5.0 <0.6.0;

contract structEnumPOC {
    
    string word;

   enum Bit {
        OFF,
        ON
    }    
    
    Bit a;
    
    struct S {
        
        Bit b;
    }
    
    mapping (uint256 => S) public route;
    
    function clampy() public view returns(Bit){
        
        return a;
    }
    
    /// two different ways to test the same thing
    function clampoo(uint256 name) public view returns(Bit){
        
        return route[name].b;
    }
    
    function clamclam(uint256 name) public view returns(Bit){
        
        S memory s = route[name];
        return s.b;
    }
    ////
    
    function setClampName (uint256 name)public{
        route[name]=S(Bit.ON); 
        
    }


    //side testing to verify if issue happens with a plain string
    function setString(string memory random)public{
        word = random;
    }

    function getString() public view returns (string memory){
        return word;
    }
}
]

This is the function I am using:

async function check() {

   // let a = ethers.utils.bigNumberify(document.getElementById("circuit").value);
    let a = document.getElementById("foo").value;

    let o = await contract.clamclam(a);

    console.log(o);
    let receipt = await o.wait(1);

    console.log('receipt');
    let event = receipt.events.pop();
    console.log(event);
 }

The other side issue/question I have is how to define the abi for signatures that include the keyword memory? If I include the word memory it gives an error message otherwise if I remove it,when I transact I get: Error: VM Exception while processing transaction: revert etherjs xxxxx
which I think is Truffles fault.

I checked the guide: https://docs.ethers.io/ethers.js/html/api-contract.html#connecting-to-a-contract but do not see particular examples concerning this.

Please let me know if you can provide further suggestions on what am I doing wrong or how to proceed.

Best Regards

@thecircleoflifefree
Copy link
Author

thecircleoflifefree commented Apr 8, 2020

I know this example seems childish, but it represents in a simplistic matter the issue that I am having. Would anything else be required on my end?

@ricmoo ricmoo added the discussion Questions, feedback and general information. label Apr 8, 2020
@ricmoo
Copy link
Member

ricmoo commented Apr 8, 2020

Are you only intermittently getting this error and only under load? Is that why you think it related to the other issue?

If you use v5, it won't mind the "memory" keyword. But you can safely remove the memory keyword from the ABI passed into ethers. If it is reverting, it is unrelated.

Can you include the code you are using th instantiation the contract? Also, can you make sure the code is deployed before you call the clam clam function, using await provider.getCode(contract.address)? If you are using Truffle, often removing the build files and re-building can help, since it isn't reliable at times when it comes to updating artifact files.

@thecircleoflifefree
Copy link
Author

This is during testing and reproducible. Error is the same as the prior issue, that is the only simility I based that comment about, and may not be related at all.
Moving to v5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Questions, feedback and general information.
Projects
None yet
Development

No branches or pull requests

2 participants