Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Guides

Setting Up a Smart Contract System for Revenue Splits from Resales

A technical tutorial for developers to implement smart contracts that automatically enforce and distribute royalties from NFT secondary sales across any marketplace.
Chainscore © 2026
introduction
INTRODUCTION

Setting Up a Smart Contract System for Revenue Splits from Resales

This guide explains how to build a smart contract system that automatically distributes revenue from secondary market sales, a key feature for NFT projects and digital collectibles.

Secondary market sales, or resales, represent a significant revenue stream in digital asset ecosystems. A revenue split system allows original creators, project treasuries, or other designated parties to earn a percentage of every subsequent sale. This is typically enforced through a royalty fee mechanism on marketplaces. However, relying solely on marketplace compliance is fragile. A dedicated smart contract system provides a programmable, on-chain enforcement layer, ensuring funds are collected and distributed according to predefined rules without intermediary trust.

The core mechanism involves deploying a smart contract that acts as a payment router. When an asset is sold on a supporting marketplace, the sale proceeds are sent to this contract. The contract's logic then automatically calculates the splits—for example, 5% to the creator, 2.5% to a community treasury—and distributes the funds to the respective Ethereum addresses. This is superior to basic EIP-2981 royalty standards because it handles the distribution logic on-chain, not just signaling a recipient address and expecting them to manage the split off-chain.

Key components of this system include the splitter contract logic, the payment receiving mechanism, and the withdrawal functions for beneficiaries. A common design pattern uses a pull over push payment system for gas efficiency: the contract holds the funds, and authorized addresses can withdraw their share. This avoids failed transactions if a beneficiary address is a contract without a payable fallback function. Security considerations are paramount, as this contract will hold and move significant value; implementing access controls, using audited libraries like OpenZeppelin, and thorough testing are non-negotiable steps.

To implement this, you will typically write a smart contract in Solidity. The contract needs to:

  1. Accept incoming payments via a receive() or fallback() function.
  2. Maintain a record of beneficiaries and their respective shares.
  3. Track the balance owed to each beneficiary.
  4. Provide a function for beneficiaries to withdraw their accrued funds. You can extend ERC-2981 to declare royalties, but the splitter contract itself becomes the receiver address, taking custody before internal distribution.

Integration with marketplaces is the final step. Your NFT contract's royaltyInfo function should return your splitter contract's address and the total royalty percentage. Marketplaces like OpenSea, LooksRare, and Blur that support the standard will then route payments to your splitter. For full coverage, you may also need to implement proprietary marketplace protocols (like OpenSea's Operator Filter Registry for optional royalties). Testing the entire flow on a testnet with a marketplace like OpenSea Testnet is crucial before mainnet deployment.

prerequisites
FOUNDATION

Prerequisites

Before building a system for automated revenue splits from secondary market sales, you must establish the core technical and conceptual foundation. This involves understanding the underlying standards, setting up your development environment, and securing the necessary tools.

The core mechanism for tracking and distributing resale royalties on-chain is the ERC-2981: NFT Royalty Standard. This standard defines a universal way for marketplaces to query a smart contract for royalty information. Your revenue split system will implement this interface. You must also be familiar with ERC-721 or ERC-1155 token standards, as your NFTs will be the assets generating the secondary sales. A working knowledge of Solidity, the Ethereum Virtual Machine (EVM), and a development framework like Hardhat or Foundry is essential for writing, testing, and deploying your contracts.

Your local development environment needs specific tools. Install Node.js (v18 or later) and a package manager like npm or yarn. You will use these to manage dependencies for your chosen framework. For contract interaction and deployment, set up a wallet such as MetaMask and fund it with test ETH on a network like Sepolia or Goerli. You'll also need an Alchemy or Infura account to get a reliable RPC endpoint for connecting to these testnets, which is crucial for simulating on-chain interactions.

For efficient development, leverage established OpenZeppelin contracts. Import @openzeppelin/contracts to use their audited implementations of ERC-721, ERC-1155, and access control mechanisms like Ownable or AccessControl. These provide secure, battle-tested foundations, allowing you to focus on your custom royalty logic. You will also need the OpenZeppelin library to implement ERC-2981, as they provide a base ERC2981 contract you can extend. Initialize a new project with npx hardhat init or forge init to create the necessary directory structure.

Understanding the royalty payment flow is critical. When a sale occurs on a compliant marketplace, the marketplace contract calls your NFT's royaltyInfo(uint256 tokenId, uint256 salePrice) function. This function must return the recipient address and the royalty amount. Your system's complexity lies in defining these return values—they could point to a single creator, a splitter contract that distributes funds to multiple parties, or a dynamic on-chain registry. Plan this architecture before writing code.

Finally, ensure you have a plan for testing. Write comprehensive unit tests in Hardhat (using Waffle/Chai) or Solidity tests in Foundry to verify: royalty info is correctly set per token, funds are calculated accurately (e.g., a 5% royalty on a 1 ETH sale yields 0.05 ETH), and the recipient logic works. Test edge cases like zero-address recipients or sale prices of zero. Proper testing at this stage prevents critical financial logic errors after deployment to mainnet.

key-concepts-text
ON-CHAIN ROYALTIES

Setting Up a Smart Contract System for Revenue Splits from Resales

Implementing a robust, on-chain royalty system for secondary market sales requires careful smart contract design. This guide covers the core concepts and architectural patterns for building enforceable revenue splits.

On-chain royalties are a mechanism to automatically pay a percentage of a secondary sale back to the original creator or other designated parties. Unlike off-chain agreements, these rules are embedded directly into the NFT's smart contract logic, enabling trustless and automatic execution. The primary standard for this on Ethereum is EIP-2981: NFT Royalty Standard. It defines a simple interface, royaltyInfo(uint256 tokenId, uint256 salePrice), that marketplaces can query to get the payment recipient and amount. This standardizes communication between the NFT contract and the marketplace, but its enforcement is voluntary.

To build a system that splits revenue among multiple parties, you must extend the basic royalty logic. A common pattern involves a payment splitter contract. After determining the total royalty amount (e.g., 5% of the sale price), the funds are not sent to a single address. Instead, they are forwarded to a splitter contract that distributes the ETH or tokens according to predefined shares. For example, a project might allocate 40% to the artist, 30% to a community treasury, 20% to a co-creator, and 10% to a charity wallet. OpenZeppelin's PaymentSplitter is a popular, audited base contract for this purpose.

Here is a simplified example of a custom NFT contract integrating EIP-2981 and a payment splitter. First, you would deploy a PaymentSplitter with the payees and their shares. Your main NFT contract then stores the splitter's address and implements royaltyInfo to return it as the recipient.

solidity
// SPDX-License-Identifier: MIT
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/finance/PaymentSplitter.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";

contract RoyaltyNFT is ERC721, IERC2981 {
    PaymentSplitter private _splitter;
    uint96 private constant ROYALTY_BPS = 500; // 5.00%

    constructor(address[] memory payees, uint256[] memory shares)
        ERC721("RoyaltyNFT", "RNFT") {
        _splitter = new PaymentSplitter(payees, shares);
    }

    function royaltyInfo(uint256, uint256 salePrice)
        external view override
        returns (address receiver, uint256 royaltyAmount) {
        royaltyAmount = (salePrice * ROYALTY_BPS) / 10000;
        receiver = address(_splitter);
    }
}

This design centralizes distribution logic in the PaymentSplitter, making the royalty payments gas-efficient and upgradeable if needed.

Key considerations for production systems include gas efficiency and upgradeability. Calculating splits on-chain for every sale can be expensive. Using a pre-deployed splitter contract mitigates this. For future-proofing, consider using a proxy pattern where the royalty recipient address points to a manager contract that can update internal logic or splitter addresses without migrating the NFT collection. It's also critical to ensure your system handles ERC20 royalty payments if your marketplace supports them, which may require a more flexible splitter design than the native-ETH-only version.

Enforcement remains the largest challenge. While EIP-2981 provides a standard, marketplaces must choose to respect it. Some projects implement more aggressive enforcement at the contract level using methods like transfer hooks (e.g., the _beforeTokenTransfer function in ERC721) to block trades from non-compliant marketplaces, though this reduces liquidity and is controversial. A balanced approach is to rely on the standard for compliant marketplaces and use allowlists or social consensus for others. Always clearly communicate the royalty policy to holders.

Testing is essential. Use a framework like Foundry or Hardhat to simulate secondary sales on both compliant and non-compliant marketplaces. Verify that the correct amounts are sent to the splitter and that each payee can successfully withdraw their share. Document the royalty percentage and mechanism clearly in your project's documentation, as this transparency builds trust with creators and collectors alike.

ON-CHAIN ENFORCEMENT

Comparison of Royalty Implementation Standards

A technical comparison of primary methods for implementing and enforcing creator royalties on secondary NFT sales.

Implementation FeatureEIP-2981 (Royalty Standard)EIP-721 (Basic NFT)Operator Filter Registry

Standard Type

Royalty Info Interface

Base NFT Standard

Marketplace Allow/Deny List

On-Chain Enforcement

Royalty Recipient Logic

Fixed in royaltyInfo()

None

Uses EIP-2981 or custom

Royalty Percentage Logic

Fixed or dynamic in royaltyInfo()

None

Depends on linked standard

Marketplace Agnostic

Gas Overhead for Transfer

Low (~5k gas)

Base cost

High (checks registry)

Upgradability Post-Deployment

Immutable logic

Immutable logic

Registry list is updatable

Primary Use Case

Universal royalty specification

No built-in royalties

Restricting non-compliant marketplaces

contract-architecture
SYSTEM ARCHITECTURE

Smart Contract Revenue Splits for Resales

Designing a secure and efficient system to automate royalty payments on secondary market sales.

A smart contract system for resale revenue splits, often called on-chain royalties, ensures creators receive a percentage of sales when their digital assets are traded on secondary markets. This architecture typically involves three core components: the primary NFT contract (e.g., ERC-721, ERC-1155), a payment splitter contract to distribute funds, and an integration layer with marketplaces. The system's effectiveness depends on enforcing royalty logic at the point of sale, which can be implemented via the EIP-2981 royalty standard or marketplace-specific fee mechanisms. Without proper design, royalties can be easily bypassed.

The foundation is the NFT contract itself. To support resale royalties, it must expose a function that returns payment information. The widely adopted EIP-2981: NFT Royalty Standard defines a royaltyInfo function that marketplaces can query. This function takes the token's sale price and returns the recipient address and the royalty amount. Implementing this standard is the most reliable method for cross-marketplace compatibility. Your contract's mint function should also record the original creator, often by storing their address in a mapping linked to the token ID.

For splitting revenue among multiple parties—such as a primary creator, a platform, and collaborators—a dedicated payment splitter contract is essential. This contract, which can be based on OpenZeppelin's PaymentSplitter, holds funds securely and allows for pull-based withdrawals. When a marketplace sends royalties to the royaltyInfo recipient (which would be the splitter contract's address), the funds are allocated according to predefined shares. This design separates payment logic from the NFT contract, improving upgradability and gas efficiency for payouts.

Integration with marketplaces is critical. While EIP-2981 is a standard, its support varies. Major platforms like OpenSea, LooksRare, and Blur recognize it, but you must also configure royalty settings in their proprietary seller dashboards. For direct peer-to-peer sales or custom marketplaces, the sale contract must explicitly call the royalty logic. A common security consideration is to make the royalty recipient a immutable contract, like your payment splitter, rather than an EOA, to prevent rug pulls. Always verify fee behavior on testnets before mainnet deployment.

Advanced architectures may incorporate modular upgradeability using proxies or a royalty registry for dynamic fee updates. However, complexity increases risk. A robust, audited approach uses a minimal, non-upgradeable NFT contract with EIP-2981, a simple PaymentSplitter for distribution, and clear documentation for marketplace setup. This system ensures automatic, trustless revenue flows from resales, directly embedding creator economics into the asset's lifecycle on-chain.

DEVELOPER FAQ

Step-by-Step Implementation Guide

Common questions and solutions for implementing a smart contract system that manages revenue splits from NFT or token resales.

A resale royalty system is a smart contract mechanism that automatically distributes a percentage of a secondary market sale to predefined parties, such as the original creator or a DAO treasury. Unlike primary sales, which are a one-time event, this system enforces fees on all subsequent trades.

Key components include:

  • Royalty Standard: For NFTs, this is often EIP-2981, which defines a standard interface (royaltyInfo) that marketplaces can query.
  • Payment Splitter: A contract (like OpenZeppelin's PaymentSplitter or a custom implementation) that holds funds and distributes them to payees based on shares.
  • Marketplace Integration: The marketplace (e.g., OpenSea, Blur) must support the standard to read the fee and send the correct amount to the royalty receiver address.

The workflow is: 1) A user lists an NFT for sale. 2) Upon sale, the marketplace calls royaltyInfo(tokenId, salePrice). 3) The contract returns the receiver address and royalty amount. 4) The marketplace sends that amount to the receiver, which is the splitter contract. 5) The splitter contract holds the funds until payees call release() to claim their share.

sale-tracking-distribution
GUIDE

Setting Up a Smart Contract System for Revenue Splits from Resales

This guide explains how to implement a smart contract system that tracks secondary market sales and automatically distributes royalties to creators and stakeholders.

A resale royalty system requires a mechanism to detect sales and execute programmed distributions. The core challenge is that most NFT marketplaces handle sales off-chain in their own order books. Your smart contract must be designed to interact with these marketplaces' settlement logic. The most common approach is to implement the ERC-2981 royalty standard, which provides a universal interface for marketplaces to query royalty information. However, ERC-2981 is a read-only standard; it does not enforce payment. For enforcement, you need a system that can intercept the sale's fund flow.

The most effective enforcement method is using a transfer hook. By overriding the _update function in an ERC-721A or similar token contract, you can execute logic before or after a token transfer occurs. When a sale is detected (often by checking if the from address is not the zero address and the to address is not the zero address), the hook can calculate the royalty fee based on a known sale price. This price must be made available to the contract, typically by having the marketplace call a function on your contract as part of the settlement process.

Here is a simplified code snippet for a transfer hook that calculates a 10% royalty:

solidity
function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address) {
    address from = _ownerOf(tokenId);
    // Execute royalty logic if this is a transfer between two users
    if (from != address(0) && to != address(0) && from != to) {
        uint256 salePrice = getSalePriceForToken(tokenId); // This must be set by the marketplace
        uint256 royaltyFee = (salePrice * 1000) / 10000; // 10%
        address royaltyRecipient = getRoyaltyRecipient(tokenId);
        // Transfer royalty fee to recipient
        (bool success, ) = payable(royaltyRecipient).call{value: royaltyFee}("");
        require(success, "Royalty transfer failed");
    }
    return super._update(to, tokenId, auth);
}

The critical dependency is getSalePriceForToken, which requires integration with the marketplace.

To make the sale price available on-chain, you must integrate with marketplace protocols. For Seaport (OpenSea's protocol), your contract should implement the IConduitController interface or similar to be notified of filled orders. Alternatively, many projects use an off-chain indexer that listens for Sale events from major marketplaces and then calls a permissioned function on the royalty contract to submit the sale data. This creates a trusted dependency on the indexer's honesty and liveness, which is a centralization trade-off.

For complex distributions—splitting royalties between a creator, a DAO treasury, and a charity—you can use a payment splitter contract like OpenZeppelin's PaymentSplitter or a custom solution. Upon receiving the royalty payment, your main contract would forward the funds to the splitter, which then holds them for withdrawal by payees according to their shares. This separates the distribution logic from the sales detection logic, making the system more modular and easier to audit.

Key considerations for production systems include: gas efficiency in the transfer hook to avoid failed transactions, handling of ERC-20 payments in addition to native ETH, ensuring compliance with marketplace policies to avoid being blacklisted, and setting up a fallback mechanism in case an indexer fails. Testing against forked mainnet environments using tools like Foundry is essential to simulate real marketplace interactions before deployment.

REVENUE SPLIT CONTRACTS

Common Pitfalls and Security Considerations

Implementing a robust revenue split system for NFT resales requires careful attention to gas efficiency, security, and protocol compatibility. This guide addresses frequent developer challenges.

Marketplace compliance is the primary reason. Your contract must implement the correct royalty standard for each chain.

Key Standards:

  • EIP-2981 (Universal): The most widely supported standard. Your royaltyInfo function must return the recipient address and royalty amount.
  • Marketplace-Specific: Platforms like Rarible or LooksRare may have legacy interfaces. Missing these can cause payments to default to zero.

Common Failure Points:

  • Not returning the correct values (royalty amount in basis points, e.g., 500 for 5%).
  • Hardcoding recipient addresses that cannot receive funds (e.g., a zero address or a non-payable contract).
  • Failing to implement supportsInterface to return true for type(IERC2981).interfaceId.

Always test with the marketplace's own test suite or a forked mainnet environment.

IMPLEMENTATION

Platform-Specific Considerations

Implementation on EVM Chains

Revenue split contracts on Ethereum, Polygon, Arbitrum, and other EVM chains primarily use the ERC-2981 standard for on-chain royalty reporting. This standard defines a royaltyInfo function that marketplaces call to determine payment splits.

Key Implementation Details:

  • Your smart contract must implement the IERC2981 interface.
  • The royaltyInfo function returns a recipient address and royalty amount.
  • Royalties are typically a percentage of the sale price, calculated in the marketplace contract.
  • For secondary sales, the split is enforced if the marketplace supports ERC-2981. Major platforms like OpenSea, LooksRare, and Blur support it.

Code Snippet (Solidity):

solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "@openzeppelin/contracts/interfaces/IERC2981.sol";

contract RevenueSplitNFT is IERC2981 {
    address private royaltyRecipient;
    uint256 private royaltyBasisPoints; // e.g., 500 for 5%

    function royaltyInfo(
        uint256 /*_tokenId*/,
        uint256 _salePrice
    ) external view override returns (address, uint256) {
        uint256 royaltyAmount = (_salePrice * royaltyBasisPoints) / 10000;
        return (royaltyRecipient, royaltyAmount);
    }
}

Consideration: Enforcement relies on marketplace compliance. Some marketplaces may bypass on-chain standards, requiring off-chain allowlists or legal frameworks.

SMART CONTRACT REVENUE SPLITS

Frequently Asked Questions

Common technical questions and solutions for developers implementing on-chain revenue share systems for secondary market sales.

A resale royalty smart contract is a program deployed on a blockchain (like Ethereum) that automatically enforces a fee on secondary market sales and distributes the proceeds. It works by integrating with NFT marketplaces via standards like EIP-2981 for royalty information and executing logic upon token transfer.

Core mechanics include:

  • Intercepting the transferFrom or safeTransferFrom function calls.
  • Calculating a percentage fee (e.g., 10%) of the sale price.
  • Splitting that fee among predefined beneficiaries (e.g., the original creator, a DAO treasury).
  • Forwarding the remaining sale proceeds to the seller.

This is typically implemented by overriding ERC-721 or ERC-1155 transfer functions or by using a modular approach with the Solidity paymentSplitter pattern.

conclusion
IMPLEMENTATION SUMMARY

Conclusion and Next Steps

You have now built a foundational system for automating revenue splits from NFT resales using a modular smart contract architecture.

This guide demonstrated a practical approach using the ERC-2981 royalty standard for on-chain metadata and a separate payment splitter contract for fund distribution. By separating logic, you achieve greater flexibility and security. The core components are: the NFT contract with _setTokenRoyalty, a factory or deployer for creating individual splitter contracts, and a mechanism to update the royalty recipient. This pattern is used by protocols like Manifold's Royalty Registry to handle complex payout structures.

For production deployment, several critical steps remain. First, conduct thorough testing on a testnet like Sepolia or Goerli using frameworks like Hardhat or Foundry. Write unit tests for minting, secondary sales, and royalty forwarding. Second, implement access control (e.g., OpenZeppelin's Ownable or AccessControl) for functions like setRoyaltyRecipient to prevent unauthorized changes. Finally, verify and publish your contract source code on block explorers like Etherscan to establish transparency and trust.

To extend the system's capabilities, consider integrating with on-chain revenue tracking or automated treasury management. You could develop an off-chain indexer that listens for RoyaltyPaid events to generate financial reports. For more dynamic splits, explore EIP-6110 (Programmable Royalties) or ERC-5218 (Fractionalized Royalty Payouts), which allow for logic within the royalty payment itself. Always audit the security of any payment splitter implementation, as flaws can lead to permanent fund loss.

The next logical step is to interact with your deployed system. Use the ethers.js or viem libraries in a frontend dApp to let users: check their royalty earnings, view splitter contract details, or (if permitted) claim their share of funds. Remember that gas optimization is crucial for user experience; batch transactions or consider layer-2 solutions like Arbitrum or Base if you anticipate high volume.

This architecture provides a robust foundation. Continue your learning by studying real-world implementations from Art Blocks, Sound.xyz, or the Zora Protocol. The landscape of creator monetization is rapidly evolving, and building on established, audited standards is the best path to creating secure and sustainable revenue systems for digital assets.

How to Build a Smart Contract for NFT Resale Royalties | ChainScore Guides