0.2.0 • Published 3 years ago

erc721e v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

ERC721E

What is ERC721E?

ERC721E is a royalty-sharing contract that complies with ERC721 contract. It brings all royalties generated by every transaction to NFT minters while providing continuous low gas mint like ERC721A.

Problems solved by ERC721E

It is well known that NFT project parties derive their income from two main sources:

  • Presale / Public sale
  • Royalty income

The following is a comparison of the two income components in some current projects.

CollectionsPresale + Public saleRoyalty
Bored Ape Yacht Club800 ETH15220 ETH
Azuki8700 ETH12435 ETH
Doodles1230 ETH6700 ETH

This shows that there is a huge volume of transactions in top-streaming projects, which leads to a much larger royalty income than pre-sales/public sales. And again, we see a new possibility for higher income for early investors (OG or Early Minter): an equal share of royalty income for Minter, which would greatly encourage people to mint in top-streaming projects.

How the ERC721E works

// Access balance + amount already withdrawn by the project owner + amount already withdrawn by the user + accidental withdrawals >= contract revenue (excluding accidental withdrawals) = (sell profit + royalty profit)
// Contract revenue = (sell profit + royalty profit) = (project owner's undrawn cash + project owner's withdrawn cash) + (user's undrawn cash + user's withdrawn cash)
// Contract revenue = money to the project owner + money to the user = (amount of cash undrawn by the project owner + amount of cash withdrawn by the project owner) + (amount of cash undrawn by the user + amount of cash withdrawn by the user)
// Contract Revenue = Projector's undrawn cash + Projector's withdrawn cash + User's undrawn cash + User's withdrawn cash = (sell profit + royalty profit)
uint256 overage = address(this).balance;

// Project revenue = number of units currently sold * selling price = amount of cash undrawn by the project + amount of cash withdrawn by the project
// Project's undrawn cash = Number of units currently sold * Sold price - Project's withdrawn cash
uint256 notWithdrawnProfit = (_currentIndex - _burnCounter - _startTokenId()) *
  _price - withdrawned;

// royalty profit = balance + amount withdrawn by the project owner + amount withdrawn by the user - sell profit = balance + amount withdrawn by the user - (sell profit - amount withdrawn by the project owner)
// Royalty Earnings = Balance + User's Withdrawn Cash - Projector's Undrawn Cash = Balance + (Royalty Earnings - User's Undrawn Cash) - Projector's Undrawn Cash
// User's undrawn cash = balance - project owner's undrawn cash
uint256 royaltyProfit = overage - notWithdrawnProfit;

// sender's share of royalties = royalty profit / total number of issues * number of sender's purchases - the sender's share of royalties
uint256 giveSender = (royaltyProfit /
                      (_currentIndex - _burnCounter - _startTokenId())) *
  mintMountOfAddress[userAddress] -
  hadWithdrawedAddress[userAddress];

// If there is a situation where a late mint user comes in, and the total undrawn amount for all current users < the calculation of the equal share (royalties to be shared), it will need to be calculated after subsequent royalty increases
// This case returns 0
if (giveSender <= 0) return 0;
return giveSender;

How to use ERC721E in your project?

Install

npm install erc721e

UseCase

import "erc721e/contracts/ERC721E.sol";

contract Coroodles is ERC721E {
  uint256 public publicSalePrice = 0.06 ether;
  constructor(
    string memory _name,
    string memory _symbol,
  ) ERC721E(_name, _symbol, publicSalePrice) {
    setNotRevealedURI(_initNotRevealedURI);
  }
  // your project code
  ……
}

Precautions

  • If there are operational tools in your program that involve changes in contract balances such as airdrops, or whitelist price reductions, please replenish the discount amount in time.
  • Disclaimer: The use of this program does not guarantee that the collection of this contract will be free from other deceptive practices so we remind you to invest with caution.

Disclaimer

Using ERC721E doesn't mean minters can get the royalty, it still depends how project use ERC721E, and there's certain risk that project uses ERC721E as a title to rug users. There's some sample of flaws

  • The project party doesn't submit address on opensea
  • The project party sets the wrong price or doesn't make the payment in time to the contract when there's a discount like presale price.
  • There are other withdrawal codes or loopholes in the project contract
  • There are loopholes in this contract

This contract is just a tech sample. ERC721E assumes no responsibility for errors or flaws of project using ERC721E contract. Coroodles reserves the right to make additions, deletions, or modifications to the contents on the Service at any time without prior notice.

How to contribute to the ERC721E

Disclosure of safety issues

If there is any security vulnerabilities in ERC721E, please submit it to coroodles@gmail.com so that we can address it before the issue is publicly disclosed.

Other contributions

  • Optimise code to reduce gas costs
  • Refine automated unit tests in the Test directory
  • Submit best practice in Example
  • Tell everyone in Project.md that you are applying erc721e to your project
0.2.0

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago