Skip to content

How to pin content to a remote IPFS pinning service using Helia

Notifications You must be signed in to change notification settings

ipfs-examples/helia-remote-pinning

Repository files navigation

Helia logo

How to pin content to a remote IPFS pinning service using Helia


Explore the docs · View Demo · Report Bug · Request Feature/Example

About

When we add content to an IPFS node, it needs to remain online in order for others to retrieve that content.

Some environments such as web browsers are fundamentally short lived - the user may navigate away from the page, close their browser or laptop lid, for example.

Where users are creating content in these environments, we should use a remote pinning service to ensure the content is resolvable long after the original creator has gone offline.

A remote pinning service is a third party node that stores content on behalf of other nodes. It may be a commercial service or one you have set up yourself.

Network

We are going to start four nodes.

  1. Publisher

This is a browser node which we will use to create some content.

  1. Pinning service

This will run under Node.js and it will be used to make the content available after the publisher has gone offline.

  1. Resolver

Another browser node that wishes to fetch the content created by the publisher.

  1. Bootstrapper

A Node.js node we will use to allow these peers to discover each other.

Start the servers

First start the bootstrapper:

$ npm run bootstrapper
bootstrapper listening on
/ip4/127.0.0.1/tcp/64484/p2p/12D3KooWNkqtx14iU9sJV76PgksX3nYW7CPdKZAQPG6ueqzAMgxD
... more addresses here

Next start the pinning service:

$ npm run pinning-service.js
pinning service listening on
http://127.0.0.1:64486

Now start the publisher:

$ npm run publisher

A web browser will open.

Wait for the status to become "Ready". When this has happened, the libp2p node running on the page has acquired a relay address from the bootstrap node and can accept incoming WebRTC connections from the pinning service node. This is necessary for the pinning service to request pinned blocks from the publisher.

Enter some text into the input box and click the "Publish" button.

Copy the CID that is shown on the screen.

You may now close the publisher window if you wish.

Finally start the resolver:

$ npm run resolver

When the web browser opens, take the CID you copied previous and enter it into the input box.

Click "Resolve", after a short delay you should see the content you entered into the input on the publisher page.

You have just published content using a remote pinning service, then resolved that content using a different node.

About The Project

For more examples, please refer to the Documentation

Documentation

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the IPFS Project
  2. Create your Feature Branch (git checkout -b feature/amazing-feature)
  3. Commit your Changes (git commit -a -m 'feat: add some amazing feature')
  4. Push to the Branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Want to hack on IPFS?

The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out:

Read the Code of Conduct and JavaScript Contributing Guidelines.

  • Check out existing issues The issue list has many that are marked as 'help wanted' or 'difficulty:easy' which make great starting points for development, many of which can be tackled with no prior IPFS knowledge
  • Look at the Helia Roadmap This are the high priority items being worked on right now
  • Perform code reviews More eyes will help a. speed the project along b. ensure quality, and c. reduce possible future bugs
  • Add tests. There can never be enough tests

About

How to pin content to a remote IPFS pinning service using Helia

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •