opensea-creatures icon indicating copy to clipboard operation
opensea-creatures copied to clipboard

What does the `fireTransferEvents` function do?

Open samanshahmohamadi opened this issue 3 years ago • 5 comments

Hi I was exploring the contracts and came to the CreatureFactory contract which in its constructor the fireTransferEvents function is called. This function emits Transfer events n times which n is equal to number of minting options. I couldn't understand:

  1. Why the Transfer event is emitted in constructor when no token is minted yet?
  2. Why the Transfer event is emitted n times? What is the relevance of NUM_OPTIONS here?
    The codes:
constructor(address _proxyRegistryAddress, address _nftAddress) {
        proxyRegistryAddress = _proxyRegistryAddress;
        nftAddress = _nftAddress;
        lootBoxNftAddress = address(
            new CreatureLootBox(_proxyRegistryAddress, address(this))
        );

        fireTransferEvents(address(0), owner());
    }

...

function fireTransferEvents(address _from, address _to) private {
        for (uint256 i = 0; i < NUM_OPTIONS; i++) {
            emit Transfer(_from, _to, i);
        }
    }

samanshahmohamadi avatar Aug 30 '21 14:08 samanshahmohamadi

Hi @dfinzer @rheaplex @alexanderatallah @TheMaxKim @DJViau @joshuawu @Beasta @Lynaj , Would you please help us with this question as we are working with this repo, we would appreciate your input on this matter.

Thank you all in advance

renaishiva avatar Aug 31 '21 12:08 renaishiva

Hi I was exploring the contracts and came to the CreatureFactory contract which in its constructor the fireTransferEvents function is called. This function emits Transfer events n times which n is equal to number of minting options. I couldn't understand:

  1. Why the Transfer event is emitted in constructor when no token is minted yet?
  2. Why the Transfer event is emitted n times? What is the relevance of NUM_OPTIONS here? The codes:
constructor(address _proxyRegistryAddress, address _nftAddress) {
        proxyRegistryAddress = _proxyRegistryAddress;
        nftAddress = _nftAddress;
        lootBoxNftAddress = address(
            new CreatureLootBox(_proxyRegistryAddress, address(this))
        );

        fireTransferEvents(address(0), owner());
    }

...

function fireTransferEvents(address _from, address _to) private {
        for (uint256 i = 0; i < NUM_OPTIONS; i++) {
            emit Transfer(_from, _to, i);
        }
    }
  1. as I know emit Transfer event is called to mint factory item to address 0 and transfer from address 0 to you
  2. factory will mint factory item (on this repo is lootbox) for owner after deployed total as NUM_OPTIONS

akantora avatar Sep 02 '21 07:09 akantora

@samanshahmohamadi Basically using fire events you are emitting events for your interaction with the blockchain and you can listen to that specific event on your front end and can change data accordingly or can show data dynamically.

chahakshah111 avatar Sep 09 '21 17:09 chahakshah111

2. factory will mint factory item (on this repo is lootbox) for owner after deployed total as NUM_OPTIONS

could you please clarify what do you mean? Does the factory contract need to be deployed NUM_OPTIONS times? or?

ubudragon avatar Oct 11 '21 04:10 ubudragon

In the factory contract of OpenSea (CreaturesFactory.sol) there are three options

0: Mint one random NFT 1: Mint NUM_NFTS_IN_MULTIPLE_NFT_OPTION random NFTs 2: Mint one LootBox

For options 0 and 1 the NFT contract Creature is called for each NFT to be minted

For option 2 the lootbox NFT contract CreatureLootBox is called for creating a lootbox NFT (the lootbox NFT represents the right to mint 3 random NFTs)

If you display the factory contract in OpenSea you do not see any NFTs but only these three options. And the contract creator ist the owner of these three options. From OpenSea the three options are handled like NFTs in the real NFT contracts, but there are no NFTs minted for the three options.

For what the event for each option is needed I don't know. Maybe OpenSea uses them? Can somebody answer this question? I would appreciate a answer

thomasoss avatar Mar 06 '22 12:03 thomasoss