All Projects → truffle-box → filecoin-box

truffle-box / filecoin-box

Licence: other
Filecoin flavored Ganache Truffle box

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
solidity
1140 projects
CSS
56736 projects

Projects that are alternatives of or similar to filecoin-box

nifty-game
🃏🎮A NFT(ERC721) card game build on Ethereum, Truffle, Ganache and hosting on IPFS.
Stars: ✭ 222 (+865.22%)
Mutual labels:  ipfs, truffle, ganache
filecoin-client
Golang的轻量级filecoin客户端,支持离线签名,基本满足钱包交易所充值提现逻辑
Stars: ✭ 50 (+117.39%)
Mutual labels:  ipfs, lotus, filecoin
Dapp
TypeScript React Redux Ethereum IPFS Starter Kit
Stars: ✭ 33 (+43.48%)
Mutual labels:  ipfs, truffle
Supply Chain
Supply chain management on blockchain using Angular 4 + Truffle + IPFS + Ethereum
Stars: ✭ 76 (+230.43%)
Mutual labels:  ipfs, truffle
estuary-www
https://estuary.tech
Stars: ✭ 32 (+39.13%)
Mutual labels:  ipfs, filecoin
nft-website
NFT School: Community education platform for developers in the non-fungible token space.
Stars: ✭ 260 (+1030.43%)
Mutual labels:  ipfs, filecoin
nft.storage
😋 Free decentralized storage and bandwidth for NFTs on IPFS and Filecoin.
Stars: ✭ 309 (+1243.48%)
Mutual labels:  ipfs, filecoin
sentinel
Filecoin Network monitoring and analysis tools.
Stars: ✭ 26 (+13.04%)
Mutual labels:  filecoin, filecoin-lotus
valist
Web3-native software distribution. Publish and install executables, Docker images, WebAssembly, and more. Powered by Ethereum, IPFS, and Filecoin.
Stars: ✭ 107 (+365.22%)
Mutual labels:  ipfs, filecoin
estuary
A custom IPFS/Filecoin node that makes it easy to pin IPFS content and make Filecoin deals.
Stars: ✭ 195 (+747.83%)
Mutual labels:  ipfs, filecoin
nebula-crawler
🌌 A libp2p DHT crawler, monitor, and measurement tool that exposes timely information about DHT networks.
Stars: ✭ 97 (+321.74%)
Mutual labels:  ipfs, filecoin
add-to-web3
⁂ Github Action to upload your website to web3.storage
Stars: ✭ 22 (-4.35%)
Mutual labels:  ipfs, filecoin
borg
Client-server stack for Web3! Turn your Raspberry Pi to a BAS server in minutes and enjoy the freedom of decentralized Web with a superior user experience!
Stars: ✭ 25 (+8.7%)
Mutual labels:  ipfs, filecoin
Docuhash
Simple PoC that shows you how to use IPFS and Ethereum blockchain to store files and their information.
Stars: ✭ 17 (-26.09%)
Mutual labels:  ipfs, truffle
InstaContract
Smart contracts comprising the business logic of the InstaDApp
Stars: ✭ 40 (+73.91%)
Mutual labels:  truffle, ganache
eth-plot
r/place inspired Dapp
Stars: ✭ 36 (+56.52%)
Mutual labels:  ipfs, truffle
ethdock
Ethereum development package in docker.
Stars: ✭ 25 (+8.7%)
Mutual labels:  truffle, ganache
pop
Run a point-of-presence within Myel, the community powered content delivery network.
Stars: ✭ 28 (+21.74%)
Mutual labels:  ipfs, filecoin
web3.storage
⁂ The simple file storage service for IPFS & Filecoin
Stars: ✭ 417 (+1713.04%)
Mutual labels:  ipfs, filecoin
kotal
Blockchain Kubernetes Operator
Stars: ✭ 137 (+495.65%)
Mutual labels:  ipfs, filecoin

Filecoin Box

box-artwork

Welcome to the Filecoin box. The goal of this box is to both get you hands-on with all the official Filecoin support available within Truffle and Ganache, and to kick-start your journey into the Filecoin ecosystem and the benefits that robust decentralized storage can bring to your DApps.

The context of the box is that of a decentralized art gallery. It comprises both Lotus and IPFS nodes (simulating the process of creating a storage deal), an Ethereum node (for the deployment of the ERC-721 based NFT contracts) and a front-end for viewing the gallery and the assets decentrally stored within.

Requirements

The Filecoin box has the following requirements:

  • Node.js 12.x or later
  • NPM version 5.2 or later
  • Windows, Linux or MacOS

Installation

Installation takes place in three parts:

Installing the Filecoin Box

In a terminal window, start off by installing this box.

truffle unbox filecoin
npm install

Installing the Filecoin Network Explorer

The Filecoin Network Explorer can help view data about the Chain, Miners, Markets, and Deals being made on the Lotus and IPFS nodes. The explorer can be installed by opening a new terminal window and running the following.

git clone https://github.com/trufflesuite/filecoin-network-inspector
cd filecoin-network-inspector
git checkout ganache-changes
npm install

Note that these steps could potentially change as branches are merged into master/main or other updates take place.

Installing the Front-End Gallery

Open a new terminal window and navigate to the directory where the Filecoin Box was installed in the first step. From there, run:

cd ui
npm install

Box Overview

Now that all of the necessary components are installed, this box will allow you to:

Lotus/IPFS Node Setup

The Lotus and IPFS nodes can be run using either Ganache-CLI or Ganache-UI.

Running Filecoin Ganache

In a terminal window, navigate to the directory where the Filecoin box is installed. Run the following command.

npx ganache filecoin

This creates 10 accounts, each loaded with 100 FIL, and displays both their account addresses and associated private keys.

Available Accounts
==================
(0) t3rvcqmc5otc3sh3cngqg2ttzcu7ezpco466lbafzaoygxvnzsw7e7n2zbjwhiv5fdzhs6uxm2qckwt6lp5wga (100 FIL)
(1) t3s3la37547tijmoeiep7ktogws3tep2eqrralh7rhi2mpe46q574gceyy467356onblzvwf7ejlelo2rdsg4q (100 FIL)
(2) t3wk7a46e2dcqb7qxeuz2zq7wodwycdgtbgdpr37hhvelfilf5yvssg5xbsolgusqsumomtmtqhnobh4carhyq (100 FIL)
...

It also starts the Lotus and IPFS daemons running over http and ws respectively:

Lotus RPC listening on 127.0.0.1:7777
IPFS  RPC listening on 127.0.0.1:5001

Optionally running the Filecoin Ganache GUI

An alternative to running Filecoin Ganache via the CLI is to use Filecoin Ganche UI. As per the screenshot below, this exposes all the core Filecoin protocol elements as tabs, which is particularly useful if you're just starting out.

filecoin-ganache-ui

Filecoin Ganche UI can be downloaded here.

Running the Filecoin Network Explorer

The Filecoin Network Explorer can help view data about the Chain, Miners, Markets, and Deals being made on the Lotus and IPFS nodes. It can also be used to facilitate creating storage deals. To run, navigate to its installed location in a terminal window and run:

npm run start

The Filecoin Network Explorer can now be viewed at http://localhost:3000

Deploying the NFT Minting Contract

Deploying the contract will first require an Ethereum node to connect to. A local Ethereum node can be run using Ganache. This will supply the needed wallet and addresses for deploying the contract and owning the NFTs. To run a Ganache node, open a terminal window and run:

npx ganache ethereum

The following output should be displayed at the end of the log:

RPC Listening on 127.0.0.1:8545

To deploy the contract to the local node, the contract needs to be compiled and migrated. Open a terminal window at the Filecoin box and run:

truffle compile

followed by

truffle migrate

Note the address of the deployed contract, as it will be used in setting up the gallery UI.

Creating Storage Deals

A storage deal is an agreement between a client and a storage miner to store some data in the network for a given duration. Note that while in the case of Filecoin's mainnet, a deal must be secured with a miner before data is stored, in Filecoin Ganache a deal is reached automatically.

Via the Filecoin Network Explorer

The simplest way to store data, open the Filecoin Network Explorer and navigate to the "Market" tab. From here you can select a file by clicking "Choose File" followed by "Upload to the Filecoin Network".

Via Truffle Preserve

Truffle now has a preserve command which allows for the 'preservation' of files directly from the Truffle CLI. This is currently experimental and thus on specific branch; installation details available at here.

Once installed, you'll be able to preserve your assets via the following command. Note that you'll need to include the environments object in your truffle-config.js to point at the respective node (although these are already preconfigured in the box).

truffle preserve --environment development ./assets/ --filecoin

For broader help with this command run truffle help preserve.

Via Curl (or equivalent)

Lastly, you can send the following curl request directly to the Lotus RPC. Note that the you'll need to update both the wallet address (t3s3la3754...) and Content Identifier (aka CID) (QmZTR5bcpQ...).

curl -X POST \
     -H 'Content-Type: application/json' \
     -d '{"jsonrpc":"2.0","id":0,"method":"Filecoin.ClientStartDeal","params":[{"Data":{"TransferType":"graphsync","Root":{"/":"QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V"},"PieceCid":null,"PieceSize":0},"Wallet":"t3s3la37547tijmoeiep7ktogws3tep2eqrralh7rhi2mpe46q574gceyy467356onblzvwf7ejlelo2rdsg4q","Miner":"t01000","EpochPrice":"2500","MinBlocksDuration":300}]}' \
     http://localhost:7777/rpc/v0

Minting an NFT

In the example below, we've already created a deal for the 3 assets (metadata, thumbnail, and the original asset respectively) that comprise our NFT. These are as follows, with their corresponding CIDs.

Assuming the local Ethereum Ganache node is running, you'll be able to open a console and mint a new NFT with the following steps. As the base URL is set to that of an IPFS gateway, we'll just need to pass in the CID to the asset metadata. To create your own metadata, you can use the Filecoin Network Explorer to upload a JSON file with the following contents:

{
  "title": "<NFT Title>",
  "thumbnail": "<CID of the desired thumbnail>",
  "media": "<CID of the desired media>",
  "vintage": "<Date of Creation>",
  "author": "<Author>"
 }

From there, the metadata can be minted with:

truffle console
truffle(development)> const gallery = await MyGallery.deployed()
truffle(development)> gallery.mint(accounts[0], "<CID of Metadata>")

In the above example the owner of the NFT is set (via accounts[0]) to that of the first account generated by the mnemonic.

Transferring Ownership

If we want to transfer it to a new owner, we'll be able to do so with the following.

truffle console
truffle(development)> gallery.transferFrom(accounts[0], accounts[1], 1)

Gallery UI

A sample gallery interface is available here.

sample-ui

To run this locally, open a terminal window at the location that the front-end gallery was installed and run:

npm run start

Note that this does not display the images uploaded to your local node. Out of the box, the UI pulls from a contract deployed to the Rinkeby testnet. To point to your own contract, navigate to filecoin-box/ui/src/App.js. Find the following section and follow the instructions in the comments:

// TODO - comment the following two lines
const provider = new ethers.providers.InfuraProvider("rinkeby");
const myGallery = "0x6cb457d583340099CadcBde4E05Eaa32488a6027";

// TODO - uncomment the following and update the contract address to that of your local migration
//const provider = new ethers.providers.JsonRpcProvider(`http://localhost:8545`);
//const myGallery = "0x9aaec9900de8292b31c5eb0d49644e8456972fc8";

Rerun the UI server to view your gallery!

Support

Support for this box is available via the Truffle community available here. In addition, Filecoin support is available here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].