Mode Docs
  • Introduction
    • 🟡Introducing Mode
    • ✅AI Agent Dev Roadmap
  • AI AGENTS
    • Mode AI Terminal
    • 🤷What are AI Agents?
    • 🏗️Building your first agent
    • Tutorials
      • Quickstart
    • 🛠️AI Tooling
      • AI Audits
      • AI APIs
      • Frameworks
  • Tools
    • 🖥️RPC
    • 🪶Multisig wallets
    • 🔁Bridge
    • 🚰Testnet Faucets
    • 🕵️Block Explorers
    • 🗂️Data Indexers
    • 🧙‍♂️Oracles
    • ⛓️Interoperability
    • ⁉️Randomness
    • 🌎General Tooling
  • Tutorials
    • Interacting with Smart Contracts using ethers.js
    • Deploying a Smart Contract
      • Using Hardhat
      • Using Thirdweb
      • Using Foundry
      • Using Remix
    • Verifying your smart contract
      • Using Hardhat
      • Using Foundry
  • User Guides
    • ℹ️Network Details
    • 🦊Add Mode
    • 🏡Contract Addresses
      • Tokens
      • L1/L2 Mainnet Contracts
      • Testnet Contracts
    • 🌉Bridge
      • ➡️Bridge to Mode
      • ⬅️Bridge from Mode
      • 🏗️Bridging to Testnet
    • 📤Move to/from CEX
  • $MODE
    • 🟡MODE Tokenonomics
    • 1️⃣Season 1 (ended)
    • 2️⃣Season 2 (ended)
    • 3️⃣Governance Season 3 (ended)
      • Governance Contract Addresses
    • 4️⃣Mode Governance Season 4
    • 5️⃣Season 5
  • Other Docs
    • 🔓General Security
      • 🔓Mode L2 Security Model
      • ⛑️Optimism Bug Bounty
      • Security Upgrades
        • 01/08/2024 Bridge Upgrade Fund Rescue
        • 06/08/2024 Mode Mainnet Key Handover
      • 🔐Audits
    • 🔗Official Links
    • 🤘Branding Guidelines
    • ⌨️Node Operators
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Tutorials
  2. SFS - Sequencer Fee Sharing

Register a Smart Contract

Learn to register a smart contract to the SFS

Registering a contract in the SFS means calling the register function defined in the SFS contract and getting an SFS NFT in exchange. The call to the register function must be made from your smart contract. This means you will have to add some code and logic to your contract in order to register it to the SFS. You’ll find code to do this later on this guide.

This 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 2 interesting things to note from the register function:

  1. The register function receives (address _recipient) as a parameter. This is the address where the NFT will be minted to.

  2. The SFS contract looks at the msg.sender in order to know what smart contract is being registered. This is why you need to call the register function from the contract you want to register. You can only do this once per contract.

Last updated 1 year ago

Was this helpful?