Skip to content

Instantly share code, notes, and snippets.

Embed
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 https://remix.ethereum.org/#version=soljson-v0.7.0+commit.9e61f92b.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import {RedirectAll, ISuperToken, IConstantFlowAgreementV1, ISuperfluid} from "./RedirectAll.sol";
import {ERC721} from "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.2.0-solc-0.7/contracts/token/ERC721/ERC721.sol";
import {ERC1155} from "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.2.0-solc-0.7/contracts/token/ERC1155/ERC1155.sol";
/* 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: https://docs.superfluid.finance/superfluid/resources/networks
* or using the js-sdk as shown here https://docs.superfluid.finance/superfluid/protocol-tutorials/setup-local-environment
*/
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 (
host,
cfa,
acceptedToken,
ipfsPinningProviderWallet
)
{
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) {
_changeReceiver(to);
}
}
//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