npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kodex-data/hardhat-ipfs

v0.0.1-rc.3

Published

Hardhat TypeScript plugin for using IPFS

Downloads

30

Readme

Hardhat IPFS Documentation

Overview

Hardhat IPFS is a plugin for Hardhat, a popular development environment for Ethereum smart contracts. This plugin allows you to easily integrate IPFS (InterPlanetary File System) into your development workflow.

With Hardhat IPFS, you can upload and retrieve data to and from IPFS directly from your smart contracts or Hardhat tasks. This can be useful for various purposes such as storing large files, publishing metadata, or creating decentralized applications.

Installation

To install Hardhat IPFS, use the following command:

yarn add @kodex-data/hardhat-ipfs
# or
npm install @kodex-data/hardhat-ipfs 

Configuration

Once you have installed Hardhat IPFS, you need to configure it by adding the following line to the top of your hardhat.config.ts file:

import '@kodex-data/hardhat-ipfs'; 

This will register the IPFS plugin with Hardhat.

IPFS Instance Configuration

By default, the IPFS client will be configured to use Infura. If you want to use a different IPFS node, you can configure it in your hardhat.config.ts file like so:

const config: HardhatUserConfig = {
  ipfs: {
    host: 'ipfs.example.com',
    port: 5001,
    protocol: 'https'
  },
  // ...
}

Replace ipfs.example.com with the hostname of your IPFS node, and adjust the port and protocol settings as necessary.

Usage

Hardhat IPFS provides several utility functions that can be accessed through the hre.ipfs object.

Adding Data to IPFS

To add data to IPFS, use the addFolder function. This function takes a local file or directory path, and uploads it to IPFS. It returns an array of AddFolderResult objects, each of which contains the CID of the added data.

const results = await hre.ipfs.addFolder('/path/to/data', '**/*')
console.log(results.map(r => r.cid.toString()))

The second argument to addFolder is an optional glob pattern, which can be used to select specific files within the directory.

Retrieving Data from IPFS

To retrieve data from IPFS, use the getData function. This function takes a CID or string, and returns the data stored in IPFS as a string.

const cid = 'QmWzHm1ZhymhMNUZTzT8WJ7RnRgTR9XhNEKv62Dahx2CYT'
const data = await hre.ipfs.getData(cid)
console.log(data)

Storing Data in IPFS as a DAG

To store data in IPFS as a DAG (directed acyclic graph), use the putDag function. This function takes an object containing the data you want to store, and returns the CID of the stored DAG.

const data = { foo: 'bar' }
const cid = await hre.ipfs.putDag(data)
console.log(cid.toString())

Retrieving a DAG from IPFS

To retrieve a DAG from IPFS, use the getDag function. This function takes a CID or string, and returns the DAG stored in IPFS as a GetResult object.

const cid = 'QmWzHm1ZhymhMNUZTzT8WJ7RnRgTR9XhNEKv62