Created
March 20, 2021 23:01
Star
You must be signed in to star a gist
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=
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 payable private _author; | |
address private _ipfsPinningProviderWallet; | |
address payable private _storageTrust; | |
uint256 private _royaltyFee; | |
uint256 private constant _storageFee = 5; | |
constructor ( | |
address payable 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 payable 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)); | |
_author = author; | |
_royaltyFee = royaltyFee; | |
_storageTrust = storageTrust; | |
_ipfsPinningProviderWallet = ipfsPinningProviderWallet; | |
_mint(author, 1); | |
} | |
function transferPinningProviderWallet(address to) public { | |
if(msg.sender == _author) { | |
_changeReceiver(to); | |
} | |
} | |
function _beforeTokenTransfer(address from, address /*to*/, uint256 tokenId) internal virtual override { | |
assert(msg.sender == this.ownerOf(tokenId)); | |
assert(from == this.ownerOf(tokenId)); | |
if(msg.value < _royaltyFee + _storageFee ){ | |
revert("Not enough money sent to cover royalty + storage costs."); | |
} | |
_author.transfer(_royaltyFee); | |
_storageTrust.transfer(_storageFee); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment