Skip to content

Error: invalid data for function output  #764

Closed
@thecircleoflifefree

Description

@thecircleoflifefree

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionQuestions, feedback and general information.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions