I am trying to distribute ERC-1155 NFT copies (not the token ID 1
but the copies of token ID 1
) to multiple wallets. I am calling the _safeTransferFrom
in a for loop. Would it cost gas in each for loop or only once since I am calling it within another function in a single transaction? The code is below. The _safeTransferFrom
is here
function distributeNFTs(
address _from,
address[] calldata _recipients,
uint256 _tokenId
) external {
require(_from == _msgSender() || isApprovedForAll(_from, _msgSender()), "CryptoStamp: caller is not owner nor approved");
for (uint256 i = 0; i < _recipients.length; i++) {
_safeTransferFrom(_from, _recipients[i], _tokenId, 1, "");
}
}