> For the complete documentation index, see [llms.txt](https://koii-network.gitbook.io/getting-started/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://koii-network.gitbook.io/getting-started/microservices-and-tasks/task-development-kit-tdk/using-the-task-namespace/storage-via-ipfs.md).

# Storage via IPFS

IPFS can be easily implemented as decentralized storage for a task. Using libraries such as [web3.Storage](https://web3.storage/), data can easily be stored, retrieved, and maintained on IPFS. The stored data will be referenced using [IPFS content identifiers](https://docs.ipfs.tech/concepts/content-addressing/) that are unique to the data, making your data completely portable and accessible from anywhere broadcasting data to the IPFS network, whether on a local or peer device or uploaded to web3.storage.

Import the library and create a new client in your executable file:

```javascript
// Using Web3Storage to make uploading to IPFS easier
const { Web3Storage, getFilesFromPath } = require('web3.storage');
// Create new client
const storageClient = new Web3Storage({ token: process.env.WEB3_STORAGE_KEY });
```

In the task function, store file and retrieve `cid:`

```javascript
async function task() {
  const randomJoke = getRandomJoke();
  // TODO sign data uploaded to IPFS to prove node uploaded it
  const qodJSON = JSON.stringify(randomJoke);
  const signedJSON = await namespace.signData(qodJSON);
  
  fs.writeFileSync("qod.json", signedJSON);
  
  if (storageClient) {
    // Storing on IPFS through web3 storage as example
    const file = await getFilesFromPath("./qod.json");
    const cid = await storageClient.put(file);
    console.log("CID of Uploaded Data: ", cid);
    
    await namespace.checkSubmissionAndUpdateRound(cid);
  } else {
    console.error("No web3 storage API key provided");
  }
}
```
