0

Why am I getting Uncaught (in promise) Error: Invalid number of arguments to Solidity function

sol file:

uint id  = 1;
    struct Multihash {
        bytes32 digest;
        uint8 hashFunction;
        uint8 size;
    }
    mapping (uint => Multihash) private ipfsHashes;

    function addFile(bytes32 _digest, uint8 _hashFunction, uint8 _size) external {
        Multihash memory entry = Multihash(_digest, _hashFunction, _size);
        ipfsHashes[id] = entry;
        id = id + 1;
    }

calling the function is js:

storageInstance
        .addFile(digest, hashFunction, size,{ from: account })
        .then(() => {
        });
  • 2
    Make sure all variables hold some value – Aniket May 10 at 12:36
  • Yes, all variables hold some value. It works when I include another parameter for example - 0. Why is this happening? – ak07_ May 10 at 12:40
  • 1
    Maybe your version of the sol file and the ABI you are usng in your js script aren't corresponding. Try to compile your latest contract and use it in your JS. – Eli Drion May 10 at 13:00
  • Thank you! One of the parameters was not in the correct format as it was required. – ak07_ May 10 at 13:39

Your Answer

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

Browse other questions tagged or ask your own question.