0

We needed to distribute a fongible ERC1155 token to a thousand addresses.

We created for this task a new batchMint function simplified here :

function batchMint(address[] addresses, id, amount) {
   for (uint i = 0; i < addresses.length; i++) {
     _mint(addresses[i], id , amount, '');
   }
}

This function is not working properly.

We managed to make it work the first time with a list a 20 addresses. Then it failed the next 10 times.

Metamask cannot estimate gas fees.

It seems like a wrong approach, but in this case how could you implement such a feature ?

5
  • what is the error message? Mar 19 at 15:35
  • I don't really know the error details. The status is just "failed" and "reverted". This is an example of such a failed transaction : etherscan.io/tx/…
    – Manel
    Mar 19 at 16:14
  • can you get your contract verified? it will help us to help you etherscan.io/address/… Mar 19 at 16:20
  • So according to you there is nothing wrong with the code above ? If this method is ok then maybe my problem come from Metamask not having sufficient gas limit ?
    – Manel
    Mar 19 at 16:25
  • please check the answer I edited Mar 19 at 16:37

1 Answer 1

0

If one of the addresses refers to a smart contract, it must implement IERC1155Receiver.onERC1155Received and return the acceptance value (bytes4).

edit: It seems that the array of addresses is not equal to your array of ids and values, I don't have access to the code, but IMO they should have the same length

the code you shared here is incorrect:

function batchMint(address[] addresses, id, amount) {
   for (uint i = 0; i < addresses.length; i++) {
     _mint(addresses[i], id , amount, '');
   }
}

id, should be array of uint[] and amount same you should then check that address.length == id.length == amount.length

3
  • Addresses are wallets and not smartcontracts.
    – Manel
    Mar 19 at 16:15
  • I don't see why "ids" and "values" would be necessary arrays. In fact in my real function they are, but it is not required.
    – Manel
    Mar 19 at 18:45
  • I have no idea what your real function looks like, but I can see that on the tx that fails it has 55 inputs, I'm only guessing til I don't have the code that you deployed it's really hard find the exact problem Mar 19 at 18:56

Your Answer

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

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