violetprotocol / ERC1238-token

Implementation of EIP-1238 for non-transferable tokens (fungible & non-fungible).
https://erc1238.notion.site/
16 stars 3 forks source link

Batching for multiple addresses? #2

Closed ra-phael closed 2 years ago

ra-phael commented 2 years ago

I wonder if it would make sense to allow minting and burning for multiple addresses at the same time.

ERC1155 enables batch transfers:

 function safeBatchTransferFrom(address _from, address _to, uint256[] calldata _ids, uint256[] calldata _values, bytes calldata _data) external;

However as it can be seen, the _to address parameter is not an array. Although the first draft of ERC1155 actually suggested just that.

An application might have compiled a list of addresses off-chain corresponding to attendees of an event and wants to mint tokens for all of them. In fact, POAP has such function:

 function mintEventToManyUsers(uint256 eventId, address[] memory to)

https://github.com/poap-xyz/poap-contracts/blob/5f9a31ed3b95e63d8de5a2b5057aeed0f6ed6750/contracts/Poap.sol#L130

So for ERC1238, it would mean allowing minting with multiple addresses (same for burning):

function _mintBatch(
        address[] to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    )

Or

function _mintTokenForMany(
        address[] to,
        uint256 id,
        uint256[] memory amounts,
        bytes memory data
    )
ra-phael commented 2 years ago

Done in 4373b1fa07f61f4f5d268491f42d93e3bdc23315