โ›ฝApplication fees

Monetizing your dApps with minimal effort on Haven1

Introduction

Haven1โ€™s application fee design offers a straightforward and powerful way for developers to monetize their decentralized applications (dApps). Unlike traditional gas models that send fees to validators, Haven1 empowers developers by allowing them to earn 80% of the fees generated by their applications. This provides a sustainable and developer-friendly revenue stream while still supporting the infrastructure that powers the network.

Whether youโ€™re building a game, a DeFi product, or a marketplace, Haven1โ€™s application fee model enables you to monetize specific features with just one line of code, giving you the flexibility to control what you charge for and how you charge.


How It Works

The application fee system on Haven1 is designed to be simple and customizable. Developers can charge users for specific actions or interactions within their dApp, ensuring they capture the value of their application in a transparent and direct way.

Hereโ€™s how you can get started:

  1. Define the Actions You Want to Charge For Developers can be as opinionated as they want when it comes to monetization. You can choose to make certain actions free and others paid. For example:

    • Allow free deposits but charge for withdrawals.

    • Offer a few free interactions (e.g., 10 free trades), then charge for the next ones.

    • Monetize premium features within your app, such as unlocking new levels or exclusive content.

  2. Set a Dollarized Fee The fee you set is denominated in USD, but users pay it in $H1 tokens. This ensures predictable revenue stream for you, as the dollarised amount remains consistent regardless of $H1โ€™s volatility.

  3. Fee Split: 80/20

    • 80% of the fees go directly to you, the developer, rewarding you for the value your application brings to the ecosystem.

    • 20% of the fees go to the Haven1 network to support infrastructure, validators, and ecosystem growth.


Why Use Haven1โ€™s Application Fees?

Haven1โ€™s application fee model stands out by offering:

  • Simple Monetization: With just one line of code, you can start charging users for specific features or interactions within your dApp. No need for complex fee structures or custom smart contracts.

  • Developer-Centered Earnings: Unlike traditional gas models, where fees go to validators, Haven1 ensures that developers capture the majority of the value they createโ€”80% of fees go to you.

  • Flexible Usage: You can charge for anythingโ€”whether itโ€™s a pay-per-use model in a game, a subscription feature, or one-time premium features.

  • Predictable Pricing: Users pay a consistent dollarized fee in $H1, giving you more control over the cost structure without worrying about fluctuations in token prices.


Use Case: Gaming

Imagine youโ€™re developing a game on Haven1. You want players to get 3 free lives, but after that, theyโ€™ll need to pay to continue playing. With Haven1โ€™s application fee, this is simple to set up. You define the fee for buying additional lives, and with one line of code, the system charges the user when they purchase more lives.

  • Example: You could charge $0.50 for every additional life after the free ones. Players continue enjoying the game while you monetize without needing complex payment setups. 80% of the $0.50 goes to you, with the remaining 20% going to support the Haven1 network.

This model allows you to experiment with different pricing strategies to optimize both user experience and revenue.


Use Case: DEPIN Protocols

Haven1โ€™s application fees are also ideal for developers building DEPIN (Decentralized Physical Infrastructure Networks) protocols. If youโ€™re developing a service where users run nodes (e.g., providing Wi-Fi access), you can easily set up a monetization structure using Haven1โ€™s application fees.

  • Example: Letโ€™s say users who run Wi-Fi routers on your Deepin network charge $0.10 per hour of usage. 80% of that fee goes to the node operator, and 20% goes to your protocol to maintain and grow the network. This simple setup allows you to quickly monetize services in a way that benefits both your users and the network.


How to Implement Application Fees

  1. Step 1: Set the Fee for Your Functions

    When initializing your contract, you can specify the fees for each function. In this example, we set the fee for incrementing and decrementing the counter:

    solidityCopy codefunction initialize(
        address feeContract,
        address guardianController,
        address association,
        address developer,
        address feeCollector,
        string[] memory fnSigs,  // Function signatures for setting fees
        uint256[] memory fnFees,  // Corresponding fees for each function
        bool storesH1
    ) external initializer {
        __H1DevelopedApplication_init(
            feeContract,
            guardianController,
            association,
            developer,
            feeCollector,
            fnSigs,
            fnFees,  // This array specifies the fees for the functions
            storesH1
        );
    }
    • fnSigs: Array containing the function signatures (e.g., increment or decrement).

    • fnFees: Array containing the fees corresponding to the function signatures (e.g., $2.00 for increment, $3.00 for decrement).

    The fees are passed as part of the initialization process, allowing developers to define the cost for each action.


  2. Integrate with Your Smart Contracts

    Once the fees are set, you can easily integrate them into your functions. For example:

    solidityCopy codefunction incrementCount() public payable whenNotGuardianPaused developerFee(false, true) {
        // Function logic for incrementing the counter
        _count++;
        emit Count(msg.sender, Direction.INCR, _count, getFnFeeAdj(msg.sig)); // Emitting the fee and event
    }

    In this example:

    • developerFee(false, true): This modifier ensures that the correct fee is paid before the function executes.

    • getFnFeeAdj(msg.sig): Fetches the fee associated with the specific function being called (in this case, incrementing the counter).

    The same pattern applies for decrementing or any other function you want to charge for.


  3. Test and Deploy

    Once your fee structure is in place, test your app in the Haven1 testnet environment. Then, deploy your smart contract to the Haven1 mainnet and start monetizing your dApp with application fees.


Conclusion

Haven1โ€™s application fee model offers a simplified, developer-friendly, and highly flexible approach to monetizing decentralized applications. Whether youโ€™re a game developer, DeFi builder, or working on a decentralized infrastructure project, this system empowers you to align your revenue model with the value you provideโ€”all with minimal code and effort.

Explore Haven1โ€™s Spotlight Apps for more examples of how application fees can be integrated into your dApp today!

Last updated