safe-airdrop icon indicating copy to clipboard operation
safe-airdrop copied to clipboard

ERC1155 amount should default to 1

Open bh2smith opened this issue 3 years ago • 0 comments

It looks like the default value for the "amount" field is being set to zero which would send nothing if the amount field isn't filled. It looks like it should default to 1

https://github.com/bh2smith/safe-airdrop/blob/da04fc5d4a578b35aed37c28e53edf8a0f7e5f03/src/transfers/transfers.ts#L54

Looking at the implementation of safeTransferFrom

    function _safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }
        _balances[id][to] += amount;

        emit TransferSingle(operator, from, to, id, amount);

        _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
    }

here in this contract: https://etherscan.io/address/0x142fd5b9d67721efda3a5e2e9be47a96c9b724a4#code

We should probably also update the README to give more details on the data format for NFT transfers.

bh2smith avatar May 03 '22 16:05 bh2smith