🏷️Assign a Smart Contract

Let's assign a smart contract to an existing SFS NFT

Assigning a contract to the SFS involves linking your smart contract to an existing SFS NFT. This allows the revenue generated by that smart contract to be claimed using the linked NFT.

When you assign a contract, no new NFT is minted. This is particularly useful for dApps with multiple smart contracts, as you can register one contract to create the SFS NFT and then assign the remaining contracts to that single NFT. By doing so, all revenue from those contracts will accumulate on one NFT.

  • Multiple contracts can be assigned to the same SFS NFT.

  • Each contract can only be assigned to one SFS NFT.

Here is the code for the assign function:

    /// @notice Assigns smart contract to existing NFT. That NFT will collect fees generated by the smart contract.
    ///         Callable only by smart contract itself.
    /// @param _tokenId tokenId which will collect fees
    /// @return tokenId of the ownership NFT that collects fees
    function assign(uint256 _tokenId) public onlyUnregistered returns (uint256) {
       address smartContract = msg.sender;


       if (!_exists(_tokenId)) revert InvalidTokenId();


       emit Assign(smartContract, _tokenId);


       feeRecipient[smartContract] = NftData({
           tokenId: _tokenId,
           registered: true,
           balanceUpdatedBlock: block.number
       });


       return _tokenId;
   }

Here are a few important points to consider:

  • The assign function must be called by a smart contract, not an externally owned account (EOA), similar to the register function.

  • Instead of minting an ownership NFT, the assign function links your smart contract to an existing SFS NFT.

  • You can initially assign a contract to one SFS NFT and later reassign it to another.

Last updated