You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apologies in advance for the general question in the issues section, but I felt it is a simple enough query to not be a bother.
I wanted to get some help understanding the happy path for the contract recipient check during mint functions:
function _callonERC1155BatchReceived(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts, uint256 _gasLimit, bytes memory _data) internal { // Pass data if recipient is contract if (_to.isContract()) { bytes4 retval = IERC1155TokenReceiver(_to).onERC1155BatchReceived{gas: _gasLimit}(msg.sender, _from, _ids, _amounts, _data); require(retval == ERC1155_BATCH_RECEIVED_VALUE, "ERC1155#_callonERC1155BatchReceived: INVALID_ON_RECEIVE_MESSAGE"); } }
I am not certain what input in bytes during mint and batchMint would allow me to distribute tokens to a contract address. I do not fully understand how this check works. I can see the set values in the ERC1155.sol contract state variables, but do not know what needs to be input in arguments for an actual mint to pass this check.
Any help would be appreciated :) I am 90% done with an implementation of ERC1155 that borrows from this repository's fantastic framework. Thank you in advance.
The text was updated successfully, but these errors were encountered:
After a bit of tinkering I believe I have solved my own query, but want to leave this open for confirmation at your leisure. :)
I was tripped up because I forgot the small detail that the onERC1155Received() function uses abi.encodePacked() which returns unpadded bytes. So when implementing this method in the receiving contract, I was using the magic value input (default "Hello from the other side") and trying to pass the padded bytes32 representation of that in _data. Hence, none of the contracts, including ERC1155ReceiverMock with the function implemented were working without reverting.
Apologies in advance for the general question in the issues section, but I felt it is a simple enough query to not be a bother.
I wanted to get some help understanding the happy path for the contract recipient check during mint functions:
function _callonERC1155BatchReceived(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts, uint256 _gasLimit, bytes memory _data) internal { // Pass data if recipient is contract if (_to.isContract()) { bytes4 retval = IERC1155TokenReceiver(_to).onERC1155BatchReceived{gas: _gasLimit}(msg.sender, _from, _ids, _amounts, _data); require(retval == ERC1155_BATCH_RECEIVED_VALUE, "ERC1155#_callonERC1155BatchReceived: INVALID_ON_RECEIVE_MESSAGE"); } }
I am not certain what input in bytes during mint and batchMint would allow me to distribute tokens to a contract address. I do not fully understand how this check works. I can see the set values in the ERC1155.sol contract state variables, but do not know what needs to be input in arguments for an actual mint to pass this check.
Any help would be appreciated :) I am 90% done with an implementation of ERC1155 that borrows from this repository's fantastic framework. Thank you in advance.
The text was updated successfully, but these errors were encountered: