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.
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.
Collections | Presale + Public sale | Royalty |
---|---|---|
Bored Ape Yacht Club | 800 ETH | 15220 ETH |
Azuki | 8700 ETH | 12435 ETH |
Doodles | 1230 ETH | 6700 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.
// 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;
npm install erc721e
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
……
}
- 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.
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.
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.
- 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