📚Register A Smart Contract

How to register a smart contract to SFS

To register a contract in the SFS, you need to invoke the register function from the SFS contract, which will issue an SFS NFT in return. This invocation must be made from your smart contract, necessitating the addition of specific code and logic to facilitate this registration. The necessary code and instructions are provided later in this guide.

Here is the register function from the SFS:

    ///@notice Mints ownership NFT that allows the owner to collect fees earned by the smart contract.
    ///`msg.sender` is assumed to be a smart contract that earns fees. Only smart       ///contract itself can register a fee receipient.
    /// @param _recipient recipient of the ownership NFT
    /// @return tokenId of the ownership NFT that collects fees
    
    function register(address _recipient) public onlyUnregistered returns (uint256 tokenId) {
        address smartContract = msg.sender;

        if (_recipient == address(0)) revert InvalidRecipient();

        tokenId = _tokenIdTracker.current();
        _mint(_recipient, tokenId);
        _tokenIdTracker.increment();

        emit Register(smartContract, _recipient, tokenId);

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

There are two important points to note about the register function:

  1. The register function takes an address (_recipient) as a parameter, which specifies the address to which the NFT will be minted.

  2. The SFS contract uses msg.sender to identify the smart contract being registered. Therefore, you must call the register function from the contract you wish to register. Each contract can only be registered once.

Last updated