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

Withdraw from the SFS

In this section you will learn different ways of withdrawing from the SFS.

Last updated 1 year ago

Was this helpful?

There is a minimum to claim the SFS earned fees and it's 0.01 ETH

There are 3 ways of claiming your funds:

  1. In one click from the (Recommended)

  2. Directly from a wallet that holds the NFT

  3. Programmatically from a smart contract that should also hold the NFT

The SFS contract works as a balance sheet. It contains all the mappings tracking which contracts are linked to which SFS NFTs. All balances are kept in the contract, until the users withdraw them. The revenue of the SFS is calculated by an offchain component that distributes the fees at the end of an epoch. You will not see your balance immediately going up after registering your contract because this off-chain component updates the balances every first day of the month on mainnet and every 24 hours on testnet.

To withdraw, you must hold the SFS NFT to be allowed to get the revenue. If not, the transaction will revert. It doesn’t matter if it’s an EOA (Externally Owned Account) or a smart contract, any of them must have the NFT in their balance in order to withdraw the funds. This is the withdrawal function:

    /// @notice Withdraws earned fees to `_recipient` address. Only callable by NFT owner.
    /// @param _tokenId token Id
    /// @param _recipient recipient of fees
    /// @param _amount amount of fees to withdraw
    /// @return amount of fees withdrawn
    function withdraw(uint256 _tokenId, address payable _recipient, uint256 _amount)
        public
        onlyNftOwner(_tokenId)
        returns (uint256)
    {
        uint256 earnedFees = balances[_tokenId];

        if (earnedFees == 0 || _amount == 0) revert NothingToWithdraw();
        if (_amount > earnedFees) _amount = earnedFees;

        balances[_tokenId] = earnedFees - _amount;

        emit Withdraw(_tokenId, _recipient, _amount);

        Address.sendValue(_recipient, _amount);

        return _amount;
    }

Note that the function has the onlyNftOwner modifier which reverts the transaction if the entity calling the function is not the owner of the NFT.

developer dashboard