Hi,
I have implemented a tipping system for NFTs (ERC-721) and mult tokens (ERC-1155) that I feel is very general purpose and can fit many use cases as NFTs evolve. So, I made a submission for an EIP.
In my own system, I am using it as a way for users to easily tip content creators with ERC20 rewards, whilst keeping gas costs as low as possible. Tips can be sent in batches to save on gas costs.
Tipping allows a user to show appreciation for an NFT that monetary rewards the NFT’s holder.
The interface specification without events and comments for brevity…
interface ITipToken {
function setApprovalForNFT(address holder, address nft, uint256 id, bool approved) external;
function isApprovalForNFT(address holder, address nft, uint256 id) external returns (bool);
function tip(address nft, uint256 id, uint256 amount) external;
function tipBatch(address[] memory users, address[] memory nfts, uint256[] memory ids, uint256[] memory amounts) external;
function deposit(address user, uint256 amount) external payable;
function withdraw(uint256 amount) external payable;
function balanceOf(address user) external view returns (uint256);
function balanceDepositOf(address user) external view returns (uint256);
function rewardPendingOf(address holder) external view returns (uint256);
}
setApprovalForNFT
registers an NFT for tipping, provided that the NFT has approved the tip token contract. It checks that the holder account is the NFT holder and reverts if not. There is no limit to how many NFTs that can be registered. When a tip is sent, the deposited ERC20 that backs the tip is sent pending to the NFT holder and the tip itself is burnt. tipBatch allows a provider who wishes to save gas costs, to send batches of tips from many users for the NFTs to the NFT holders in one transaction.
deposit
function allows a user to buy tip tokens with ERC20 compatible tokens. The deposited ERC20 can be held in the tip token contract account or an external escrow account, to be used later for when a holder decides to withdraw.
balanceDepositOf
returns the deposited balance of a user. This divided by the value returned from the tip token contract balanceOf
function, can be used to calculate the cost of each tip.
rewardPendingOf
allows the holder to find out how much money they are owed, and can choose to withdraw, for example, when there is enough accumulated that it is worth the gas costs to do so.
Tip tokens can also be transferred directly to other users as they are ERC20. Each NFT that can be registered to receive tips, can be an ERC-721 or an NFT/fungible token in an ERC-1155.
A tip token contract can implement ERC20 to allow for transfer of tips directly between users.
I am excited to create a topic here and see what the wider community thinks of it.