Build your first DataDAO on Filecoin

Rishikesh Kale
4 min readNov 25, 2022

This guide will enable you to program the Filecoin deal market and to make FVM Data DAOs.

Before moving ahead let us get a quick insight on how the cycle between storage provider, storage, client and marketplace revolves.

Storage deals refer to the stored data that is picked up by a Storage Provider in the Filecoin network. A deal is initiated with the Storage Client to store the data. The deal’s details and metadata of the stored data is then uploaded onto the Filecoin blockchain. FVM/FEVM allows interaction with this metadata, effectively computing over state.

Coding Data DAO contract

This article would be based on this repo. You can clone it and get started.

git clone https://github.com/rk-rishikesh/client-contract/blob/data-dao-example

Well you must have gone through the example Data DAO contract. Let’s deploy it and understand the flow.

Time to head over to Remix IDE.

Once your are done with compiling the contract, deploy the Data DAO contract on Wallaby- Testnet for Filecoin. You can find the contract at this path : /src/DataDAOExample.sol

This contract enables the storage provider to add the CID inorder to store data with the Filecoin builtin deal market. The process of adding the CID has to go through policy check where the CID needs to be approved by DAO members via voting mechanism.

Let’s us now go step by step. The storage provider can create a proposal to add his CID using createAddCIDProposal function.

As FEVM is pre-launch to Filecoin’s main net, FEVM actors today cannot yet interact easily with storage deals on the Filecoin network.

To simulate this for the hack, we have a sample CID related data. These deals are built into the Wallaby test network and your actor is able to interact with them.

Sample Test Data

testCID = "0x000181E2039220206B86B273FF34FCE19D6B804EFF5A3F5747ADA4EAA22F1D49C01E52DDB7875B4B";
testSize = 2048
testProvider = "0x0066";
testmessageAuthParams = "0x8240584c8bd82a5828000181e2039220206b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b190800f4420068420066656c6162656c0a1a0008ca0a42000a42000a42000a";

Let us create a add CID proposal, using the above test data.

Once you have created the proposal, you would be able to see all the basic data related to that proposal.

Now, its time for the DAO members to vote on that proposal before the voting period ends. If the total count of upvotes is greater than the total count of downvotes then the proposal would be passed else it would be considered as rejected. This contract uses a simple DAO mechanism, you can frame and implement your own rules and make its more interesting and secure.

Note : Only members apart from the storage provider would be able to cast a vote and each member can vote only once.

Enough said. It’s time to vote ! To keep it simple, I would be upvoting and passing this proposal. You can always play around with this.

If you go back and check the details of the proposal the count of upvotes would have been incremented to 1 whereas the downvotes would be still zero.

Note : This voting process should be completed with 5 minutes from creation of the proposal. You can make changes in the contract and increase the timer accordingly.

Okay. All done with voting part !!

Now since we have passed the proposal, now its time to publish our deal. Incase the DAO failed the proposal, the storage provider won’t be able to publish his deal.

We have a mock marketplace contract, lets deploy that first. This contract takes the contract address of our DAO contract i.e the client contract inside its constructor.

Let us publish the deal, this function takes two inputs the message auth param which you can get from the test data and the respective proposal ID.

If the proposal was passed this function would get executed successfully else, it would fail.

That’s it ! This was a quick guide as in how you can play around with the basic client contract.

If you wanna learn more about Filecoin and storage deals. Check this out.

Find me on following socials, I would love to hear from you!

LinkedIn : https://www.linkedin.com/in/rishikeshkale

Twitter : Rishikesh Kale (@0xrishikesh) / Twitter

--

--