Running multiple JS IPFS nodes
Explore the docs
·
View Demo
·
Report Bug
·
Request Feature/Example
- Table of Contents
- About The Project
- Getting Started
- Usage
- References
- Documentation
- Contributing
- Want to hack on IPFS?
- Read the docs
- Look into other examples to learn how to spawn an IPFS node in Node.js and in the Browser
- Consult the Core API docs to see what you can do with an IPFS node
- Visit https://dweb-primer.ipfs.io to learn about IPFS and the concepts that underpin it
- Head over to https://proto.school to take interactive tutorials that cover core IPFS APIs
- Check out https://docs.ipfs.io for tips, how-tos and more
- See https://blog.ipfs.io for news and more
- Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io
Make sure you have installed all of the following prerequisites on your development machine:
- Git - Download & Install Git. OSX and Linux machines typically have this already installed.
- Node.js - Download & Install Node.js and the npm package manager.
> npm install
> npm start
This example takes you through the process needed to run 2 or more JS IPFS nodes on the same computer.
Firstly, you'll want to use the IPFS_PATH
env variable to get a different repo for each instance. Initialise a new IPFS repo like this:
# IPFS_PATH by default is `~/.jsipfs`.
# The following instructs JS IPFS to use the path `~/.jsipfs2` instead:
IPFS_PATH=~/.jsipfs2 jsipfs init
# Repeat this for as many nodes as you want to run...
Secondly, you'll need them to bind to different ports because otherwise bad things happen.
With the CLI, after you've run ipfs init
you can either edit the config file at ~/.jsipfs/config
(replacing ~/.jsipfs
with the repo path you specified above) or use the config command to update the config e.g. ipfs config Addresses.API /ip4/0.0.0.0/tcp/4012
. Then start the node with ipfs daemon
:
# edit the address ports
vi ~/.jsipfs2/config
# OR
IPFS_PATH=~/.jsipfs2 jsipfs config Addresses.API /ip4/127.0.0.1/tcp/5012
# Repeat this for as many nodes as you want to run...
# ...and then start the daemon
IPFS_PATH=~/.jsipfs2 jsipfs daemon
# Repeat this for as many nodes as you want to run...
Firstly, you'll want to pass the repo
option to the constructor to get a different repo for each instance:
// The repo path by default is `os.homedir() + '/.jsipfs'`.
await IPFS.create({ repo: os.homedir() + "/.jsipfs2" });
Secondly, you'll need them to bind to different ports because otherwise bad things happen.
To do this, simply pass the different ports to the config
constructor option. All together:
await IPFS.create({
repo: os.homedir() + "/.jsipfs2",
config: {
Addresses: {
Swarm: ["/ip4/0.0.0.0/tcp/4012", "/ip4/127.0.0.1/tcp/4013/ws"],
API: "/ip4/127.0.0.1/tcp/5012",
Gateway: "/ip4/127.0.0.1/tcp/9191",
RPC: "/ip4/127.0.0.1/tcp/4839",
},
},
});
For more examples, please refer to the Documentation
- Documentation:
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.
- Fork the IPFS Project
- Create your Feature Branch (
git checkout -b feature/amazing-feature
) - Commit your Changes (
git commit -a -m 'feat: add some amazing feature'
) - Push to the Branch (
git push origin feature/amazing-feature
) - Open a Pull Request
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 IPFS 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.
- Join the Weekly Core Implementations Call it's where everyone discusses what's going on with IPFS and what's next