Invalid arrayify value, set uri for erc1155

Hello,

I am getting this error
(argument=ā€œvalueā€, value=ā€œhttps://ipfs.moralis.io:2053/ipfs/Qmc1TvL5RwDQhFUTNRBv7V5WVSeoWjs87RypJvZ1qfGJrUā€, code=INVALID_ARGUMENT, version=bytes/5.4.0)

Hereā€™s my code

        const encodedFunction= web3.eth.abi.encodeFunctionCall({
          name:"mint",
          type:"function",
          inputs:[{
            type:'address',
            name:'account'
          },{
            type:'uint256',
            name:'id'
          },{
            type:'uint256',
            name:'amount'
          },{
            type:'bytes',
            name:'memory data'
          }
        ]
      },[ethereum.selectedAddress,100,1,_uri])

        const transactionParameters= {
          to:contract,
          from:ethereum.selectedAddress,
          data:encodedFunction
        }
        const txt = await ethereum.request({
          method:'eth_sendTransaction',
          params:[transactionParameters]
        });

        resolve(txt)

Hereā€™s the contract function

    function mint(address account, uint256 id, uint256 amount, bytes memory data)
        public
        onlyRole(MINTER_ROLE)
    {
        _mint(account, id, amount, data);
    }

This is for an erc1155, I used the example on this youtube tutorial

1 Like

it looks like you receive bytes as parameter, in the tutorial it was string as parameter.
Somehow youā€™ll have to convert that string to bytes if you want to send it as bytes as the mint function expects.

the tutorial is for erc721, iā€™m using erc1155

Ok, in erc1155 it may be a different way to set the url, setBaseMetadataURI would set a base uri and uri would generate an uri based on base uri and id.

Iā€™m new to this, how would I redo the code with your answer?

converting it using web3 seems to work, but thereā€™s an error in the contract still that I canā€™t seem to fix

web3.utils.asciiToHex(_uri)

The name of the parameter is not ā€œmemory dataā€. It is only ā€œdataā€. memory is a type and not the name.

So, you have to do this -
const encodedFunction=

web3.eth.abi.encodeFunctionCall({
          name:"mint",
          type:"function",
          inputs:[{
            type:'address',
            name:'account'
          },{
            type:'uint256',
            name:'id'
          },{
            type:'uint256',
            name:'amount'
          },{
            type:'bytes',
            name:'data'
          }
        ]
      },[ethereum.selectedAddress,100,1,_uri])

Hope this helps.

Also, it is advisable to always pick the contract method objects from ABI itself to avoid human error.

Happy BUIDLing!

I think that youā€™ll have to take a look at the erc1155 standard to understand what is going on there.
https://eips.ethereum.org/EIPS/eip-1155