Skip to content

Instantly share code, notes, and snippets.

@nicola
Last active November 15, 2022 08:37
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicola/a750bfb7485c79020822a243b755eb69 to your computer and use it in GitHub Desktop.
Save nicola/a750bfb7485c79020822a243b755eb69 to your computer and use it in GitHub Desktop.
NFT stored on Filecoin in perpetuity (+ NFT Storage DAO bonus)

Perpetual Storage on FIL

From @nicola and @zx

The goal is to have a way to store a file perpetually on Filecoin. This build on top of three ideas:

  • Native Deals: Storing data on Filecoin from other chains
  • Crowdfunded Storage: Crowdfunding data storage
  • Perpetual Storage: Storing data forever on Filecoin

Note that step 1 and 2 are technically not required but they would massively simplify the user experience.

Tl;dr of the idea

Directly from Ethereum, one can create a contract that will create on-going bounties to store data on Filecoin (note this can be done natively in Filecoin as well, but making this into ETH allows for more interop), anyone can put money to these contracts. These perpetual storage contracts can be hooked directly into an exchange contract, so that a % of the trades of an NFT goes into the cost of storing the file virtually forever.

Native Storage: Enabling other blockchains to storage data on Filecoin

The goal is to provide a seamless native storage functionality to any blockchain by using Filecoin under the hood and without having users directly interacting with Filecoin.

The high level idea is that users create Bounty contracts on the host chain for storing files on Filecoin, special filecoin nodes can store the requested file on Filecoin and claim the bounty. In this way, the host users do not need to interact with Filecoin directly and can pay for storage in tokens of their choice.

Why is this step important? We want to enable NFT platforms to build directly on ETH the storage functionality.

Crowdfunded Storage: User funded storage

The goal is to allow users to pool funds together in order to make a storage deal. This follows the same idea as the Bounty contract, but where everyone can deposit to the contract.

Why is this step important? This can enable users, DAOs and other services to pool resources together to store NFTs. For example the NFT issuer could set a % of trades to go into the crowdfunding storage contract.

Perpetual storage: Storing data forever on Filecoin (self-repaying deals)

The core functionality of the Filecoin Storage Market is the "storage deal": an agreement made between a client and miner which specifies the file stored, the duration of the storage and the total cost for the service.

When making a storage deal, the client must decide on the total duration and pay the total cost of storage upfront. A client interested in storing a file for a year can make a single 1-year long deal or several shorter deals.

A client that wants to store a file for 100 years finds themselves making this difficult decision: be around to pay for storage monthly or pay upfront 100 years worth of deals.

Idea:

A perpetual storage contract is a contract where the creator can decide: (1) at what price deals should be made and the strategy for increasing the deal bid, (2) what is the replication parameter, (3) for how long individual deals should be made, (4) how the governance of this perpetual contract should change through time (e.g. allow a set of keys, a DAO or no one to change these parameters).

Anyone can add tokens to the perpetual storage contract.

If the total number of deals made on Filecoin is less or equal than the replication parameter or if one of the deals made is expiring soon, the contract unlocks some tokens in a Bounty contract.

Why is this step important? Any DAO, community, artist can create a perpetual storage contract for a specific CID or set of CIDs. As long as there are funds in the perpetual storage contract and the filecoin miners are willing to accept the price, the NFT file will be continuosly being stored.


Bonus: NFT Storage DAO

The NFT Storage DAO is a DAO with a governance tokens that governs how NFTs should be preserved.

  • The DAO offers a contract for creating perpetual storage deals.
  • The DAO offers NFTStorage tokens to those who fulfill the perpetual storage deals into Filecoin
  • The NFTStorage tokens allow to vote on prices, replication strategy and may take a fee out of the perpetual storage contracts which goes into the treasury and the DAO token holders can vote how to spend it.

Bonus: Bounty Contract Detailed overview

Users:

  • "host blockchain users": users of the blockchain that want to store a file but do not need to use Filecoin directly
  • "storage dealers": special users that can read the host blockchain state and can make deals on Filecoin

High level protocol:

  • Creating bounties: the host blockchain has a "Storage Bounty" contract where users create a bounty depositing the payment and specifying the file hash and its duration
  • Claiming bounties: "storage dealers" store the proposed file on Filecoin and post a receipt that the file has been stored and win the bounty

Tools needed to make this work:

  • A Filecoin Storage Deal oracle: an oracle that can provide a statement that a file is marked as stored on Filecoin - this can be done via Chainlink, or via a potential ad-hoc Filecoin Oracle DAO.
  • A filesharing tool that can make the file available from the user to the storage dealer - this can be done via IPFS.

Naive Candidate protocol:

  • Storage Bounty has two methods: CreateBounty, ClaimBounty, ListBounty
    • CreateBounty(hash, start, duration, expiry) -> bountyid: Anyone can call CreateBounty which adds this information to the list of bounties.
    • ClaimBounty(bountyid, dealid, ownershipsig): Anyone can call ClaimBounty which calls the Filecoin Oracle on the dealid, which returns the hash, the duration

Other notes: There are several ways to implement the Storage Bounty contract, which itself could be a DAO with its own governance, liquidity bootstrap strategy (e.g. farming for making filecoin deals) and profit-making strategy (e.g. earning a fee out of each deal)

Open problems: Multiple miners store the file but only one claims the bounty

@wheresaddie
Copy link

@nicola what is the status of this build out? I have a bunch of institutions interested in building out best solutions and best practices for computational art and Id love to get IPFS established as the standard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment