I have this code snippet:

pragma solidity >=0.5.0 <0.7.0;

import "@aztec/protocol/contracts/libs/NoteUtils.sol";

library EscrowUtils {
    using NoteUtils for bytes;

    struct Note {
        address owner;
        bytes32 noteHash;

    function noteBytesToStruct(bytes memory note)
        returns (Note memory codedNote)
        (address owner, bytes32 noteHash, ) = note.extractNote();
        return Note(owner, noteHash);

which does not throw any errors. However, when I change the visibility modifier on the function to public, I get:

This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.

Why changing modifier causes this error?


1 Answer 1


Because calling a function which returns a struct is currently not supported:

  • From another contract instance
  • From an off-chain script or app

Change returns (Note memory codedNote) and return Note(owner, noteHash),

To returns (address, bytes32) and return (owner, noteHash).

  • the issue is that if we use internal then for internal calls it is supported, but as soon as we make this function public we no longer have the ability to do this?
    – nz_
    Commented Mar 12, 2020 at 12:40
  • @isquared-KeepitReal: What part of the first bullet in my answer did you not understand??? Internal functions can be called only from the same contract instance. Commented Mar 12, 2020 at 12:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.