Textile launches the first Filecoin storage bridge on Polygon, and it's free

Aug 20, 2021

Textile is excited to announce that starting today, you can use our fully-functional Filecoin Storage Bridge from any Polygon-network enabled application or service. We have added support for Mumbai Testnet and Polygon/Matic Mainnet, which means you and your users can start storing data on Filecoin from any Polygon address without any conversions, signups, developer tokens, or secrets exchanged. To sweeten the pot even further, Filecoin, Polygon, and Textile are covering storage costs for all projects using the Textile Filecoin Storage Bridge. You heard that right folks, all storage costs using the Bridge are free for the foreseeable future.

Read this announcement on the Filecoin Blog and Polygon Blog.

What is it?

Textile is building a Filecoin Bridge to the Polygon network. Filecoin brings many of the best parts of the IPFS stack, including verifiable data, peer-to-peer (p2p) data exchange, de-duplication, and more. We can create a more secure data storage layer for Polygon applications and their users by bridging the Filecoin and Polygon blockchains.

When using the Bridge, your users, app, or smart contract will still reference and retrieve data over IPFS. Additionally, the raw data will be available in storage contracts created with miners on the Filecoin network. The metadata for that storage is reported back to the Polygon ecosystem as open and reusable building blocks.

Read out previous announcement post for why this is a huge step forward for off-chain storage for blockchain-enabled applications and services.

How does it work?

The core Filecoin Storage Bridge revolves around two key concepts: deposits and storage. The Deposit APIs all happen on-chain (on ETH, Polygon, NEAR, etc), whereas the storage APIs interact off-chain with a storage Validator that will interface with Filecoin.

Leaving a deposit provides a degree of Sybil resistance, such that users looking to store data on Filecoin via a Validator must first deposit funds proportional to the length of time they'd like to continue storing data (~100 GWEI per second, or about 0.00036 MATIC per hour, which is the default). After funds expire, they can be released by the user or any other party interacting with the Smart Contract (such as the Validator itself). This provides a means to release funds after a storage session has completed, without locking funds in the contract during the Filecoin proof process.

Once a valid deposit is available, the app/user can push data to the Validator using their stated API endpoint (available via the Validator's apiEndpoint getter function). This off-chain REST API endpoint simply takes files for upload, and sends their bytes off to the Validator for preparation and Filecoin storage. The status of each storage request can be queried using its id. The storage process ranges from "batching" files together, to "preparing" the storage deal, to "auctioning" the set of storage deals, to the actual "deal making" and "success" of the final storage deal on Filecoin. Along the way, clients may query the status in order to provide feedback to users.

How do you use it?

Textile's Filecoin Storage Bridge provides zero-config Typescript/Javascript SDKs that make it easy to store data on the Filecoin network from any blockchain-based application or service. In particular, @textile/eth-storage should feel comfortable to developers already familiar with common ETH/Polygon Javascript libraries such as ethersjs. The ETH/Polygon SDK provides a small but powerful API surface that integrates nicely with existing ETH/Polygon development best practices. Simply import the library, have your user deposit some funds, and they are ready to start submitting data to be stored on the Filecoin network.

Installation is just an npm install away; or for the more adventurous, you can interact with the smart contracts directly, see https://github.com/textileio/eth-storage-bridge for details.

npm i @textile/eth-storage

And getting started is just about as easy, and leverages common ethersjs/web3 patterns.

import { providers } from "ethers";
import { init } from "@textile/eth-storage";

// Basic Polygon dApp 
await window.ethereum.enable();
const provider = new providers.Web3Provider(window.ethereum);
const wallet = provider.getSigner();

// Initialize and sign
const storage = await init(wallet);

// Add a deposit with the on-chain component
await storage.addDeposit();

// Create or get some data
const blob = new Blob(["Hello, world!"], { type: "text/plain" });
const file = new File([blob], "welcome.txt", {
  type: "text/plain",
  lastModified: new Date().getTime(),
});

// Store it and automatically include a JWT for validation
const { id, cid } = await storage.store(file);

// Get status, and more
const { request, deals } = await storage.status(id)
console.log(request.status_code)
console.log([...deals])

Ready to start buidling? Try our simple "uploader" demo, or jump into the documentation at https://eth.storage. If you are building on Polygon, Ethereum, Near, or another chain and would like to collaborate or have ideas for using the new Storage Bridge, get in touch here, on Twitter, or find us on https://slack.textile.io/.

Interested in governance? Join our next community governance call and get involved!

If you'd like to come work with us on these kinds of projects, we are hiring!

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.