Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import {RedirectAll, ISuperToken, IConstantFlowAgreementV1, ISuperfluid} from "./RedirectAll.sol";
import {ERC721} from "";
import {ERC1155} from "";
/* Hello and welcome to your first Super App!
* In order to deploy this contract, you'll need a few things
* Get the deployed SF addresses here:
* or using the js-sdk as shown here
contract DemurrageNFT is ERC721, RedirectAll {
address private _author;
address private _ipfsPinningProviderWallet;
address private _storageTrust;
uint256 private _royaltyFee;
uint256 private constant _storageFee = 5; //TODO: adjust to filecoin market price
constructor (
address author, // This allows someone other than an author to mint an NFT
// Holds wrapped tokens to be streamed to provider wallet (fDAIx, for example)
address ipfsPinningProviderWallet, //Holds the address to the wallet that will be deposited with an IPFS streaming provider, eventually using filecoin market for storage
address storageTrust,
string memory _name,
string memory _symbol,
uint256 royaltyFee,
ISuperfluid host,
IConstantFlowAgreementV1 cfa,
ISuperToken acceptedToken
ERC721 ( _name, _symbol )
RedirectAll (
assert(host != ISuperfluid(address(0)));
assert(ipfsPinningProviderWallet != address(0));
assert(author != address(0));
assert(storageTrust != address(0));
_author = author;
_royaltyFee = royaltyFee;
_storageTrust = storageTrust;
_ipfsPinningProviderWallet = ipfsPinningProviderWallet;
_mint(author, 1);
function transferPinningProviderWallet( address to) public {
//Only the author can chamge where the storage fee is being paid
if(msg.sender == _author) {
//approve(sender, tokenId) in ERC721
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override {
assert(from == address(0) || from == this.ownerOf(tokenId)); //from address is 0 when token minted
if(_author == to) return;
if(_acceptedToken.balanceOf(to) < _royaltyFee + _storageFee ){
revert("Not enough money sent to cover royalty + storage costs.");
// assert(_acceptedToken.increaseAllowance(to, _royaltyFee + _storageFee));
assert(_acceptedToken.transferFrom(to,_author, _royaltyFee));
assert(_acceptedToken.transferFrom(to, _storageTrust, _storageFee));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment