EIPs Explained

ERC-7628 · Review · ERC · 2024-02-20

ERC-7628: ERC-721 Ownership Shares Extension

Gives every ERC-721 token a transferable share balance, so a unique NFT can also carry a fractional ownership or profit stake that can be split, moved between tokens, or sent to another address.

What problem does it solve?

Sometimes you want NFTs that are unique and carry a weighted stake, for example membership tokens where dividends are paid per share, or a revenue-sharing collection where some tokens own more than others.

  • ERC-1155 can represent stakes as balances, but identical units of one id are interchangeable, so the uniqueness of each holding is lost.
  • ERC-721 keeps tokens unique but has no standard number for "how much of the thing this token represents", and metadata cannot be freely re-split by holders.

ERC-7628 adds a share balance to each ERC-721 token, with allowance and transfer functions similar to ERC-20.

How it works

Every token id has a shareOf(tokenId) balance; totalShares() is the sum across all tokens and shareDecimals() defines precision.

Function Purpose
addSharesToToken(tokenId, shares) Issue new shares to a token (contract owner only)
transferShares(fromTokenId, toTokenId, shares) Move shares between two existing tokens
transferSharesToAddress(fromTokenId, to, shares) Send shares to an address, which yields a new token (or increases shares) at the recipient
approveShare(tokenId, spender, shares) / shareAllowance Let another address move up to N shares of a token

Events SharesTransfered and SharesApproved record share movements. The reference implementation uses fromTokenId = 0 in SharesTransfered for newly issued shares. The token itself still transfers with normal ERC-721 functions, and its shares travel with it.

Sample code

Interface (from the spec):

// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

interface IERC7628 /* is IERC721 */ {
    event SharesTransfered(uint256 indexed fromTokenId, uint256 indexed toTokenId, uint256 amount);
    event SharesApproved(uint256 indexed tokenId, address indexed spender, uint256 amount);

    function shareDecimals() external view returns (uint8);
    function totalShares() external view returns (uint256);
    function shareOf(uint256 tokenId) external view returns (uint256);
    function shareAllowance(uint256 tokenId, address spender) external view returns (uint256);
    function approveShare(uint256 tokenId, address spender, uint256 shares) external;
    function transferShares(uint256 fromTokenId, uint256 toTokenId, uint256 shares) external;
    function transferSharesToAddress(uint256 fromTokenId, address to, uint256 shares) external;
    function addSharesToToken(uint256 tokenId, uint256 shares) external;
}

Paying out a dividend pro-rata off-chain (ethers v6):

const [total, mine] = await Promise.all([nft.totalShares(), nft.shareOf(tokenId)]);
const payout = (dividendPool * mine) / total; // bigint math, no rounding surprises

Things to know

  • Status is Review: the interface may still change before it is finalized.
  • Note the event name is spelled SharesTransfered in the spec; indexers must match that spelling.
  • Read the reference implementation critically: as written, transferSharesToAddress mints a new token with the shares but does not deduct them from the source token, and shareAllowance is never consumed by the transfer functions. Do not copy it as-is.
  • The spec's security notes: clear approvals when a token changes hands, guard share transfers against re-entrancy, and validate token ids and addresses.
  • For a different take on "unique token with a value balance", see ERC-3525 (semi-fungible tokens).

#nft #erc721 #fractional #shares #ownership

Details

Authors
Chen Liaoyuan (@chenly) <[email protected]>
Status
Review
Type
Standards Track / ERC
Created
2024-02-20
Requires

Machine-readable: Markdown · JSON