[SOLVED] safeTransferFrom Function ERC-1155

I have an ERC-1155 Contract with the following override

function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) public override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not owner nor approved"
        );
        _safeTransferFrom(from, to, id, amount, data);
        resetSendHomeCountdown();
    }

within remix I try to use the following function with the following input:

safeTransferFrom(0x5B38Da6a701c568545dCfcB03FcB875f56beddC4, 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c, 1, 1, "") and it returns

transact to aeToken.safeTransferFrom errored: Error encoding arguments: Error: invalid arrayify value (argument="value", value="", code=INVALID_ARGUMENT, version=bytes/5.4.0)
>
  1. The Token ID is correct within the contract,
  2. At least 1 token is minted and displays on the โ€œfrom addressโ€ with balanceOf

I think that you should convert those addresses to string and not to send them as numbers.
Like using โ€œ0x5B38Da6a701c568545dCfcB03FcB875f56beddC4โ€ instead of 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4

Iโ€™ve tried and It does not work, or least doesnโ€™t make a difference. Remix will automatically do it for your too.

if you remove this part then it works fine?
assuming that this is the only part that you added to the original function code.

No, the whole function does not work with or without the override. I canโ€™t get it to work using the input (0x5B38Da6a701c568545dCfcB03FcB875f56beddC4, 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c, 1, 1, โ€œโ€) whatso ever. It is deployed, there is at least 1 token in balance, the token_id is right,

I tested it in remix, it looks like you have to use [] instead of โ€œโ€ for last argument, like

safeTransferFrom(0x5B38Da6a701c568545dCfcB03FcB875f56beddC4, 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c, 1, 1, [])

2 Likes

Excellent, very much appreciate it!

The error message said, that an array was expected, but an empty string was given. :slight_smile:
It is bc _safeTransferFrom has expects an array as fourth input parameter.

Hey @Rainmaker

Please create a new topic and provide us as much info as possible :raised_hands:

1 issue = 1 topic