Lesson: Generate and Use a New IPNS Name Keypair
This lesson shows you how to generate an new name keypair and use it to publish a different IPNS webpage than your original Peer ID.
Goals
After doing this Lesson you will be able to
Generate a new name keypair and use it along with IPNS.
Steps
Step 1: Generate a new name keypair
Imagine that you want to create a new name keypair called "trains". Run the following command:
Output should be a hash similar to the following:
Now you might list the keys that you have on your local node:
Note that "self" is the default name for the keypair of your Peer ID. This keypair is used when you ipfs name publish
without specifying the name.
Step 2: Create new webpage directory and content
Create a new webpage directory in your user's home directory for trains.
Download 2 train images using ipfs:
Using a text editor, create a file called index.html
and copy/paste the following content:
Save index.html
in the trains-webpage
directory and close the text editor. If you like, you may open index.html
in the browser to see the webpage.
Step 3: Add your webpage to IPFS and IPNS
Now you can add your trains-webpage
directory to IPFS
You should see output like the following:
You now know from the earlier lessons that you can view your webpage by using the hash from the last line above (Note that your own hash may be different):
https://ipfs.io/ipfs/QmTVgwpmruEWN8Dyx71FnBzymxfs8B5qV9Wuy8W4NZehPB
Now you can publish your trains webpage to IPNS using your new "trains" keypair with the hash of the trains-webpage/ directory:
You should see output like the following:
Note that the "Published to" hash above is the new name keypair "trains" hash that you created at the top of this page.
View the new webpage using the IPNS link with your "trains" hash:
https://ipfs.io/ipns/QmexZbauipkBBrV8vZv8WjeYe8F7ojCm4UZXuAhxk5vFF1
Use the same procedure that you learned earlier to update this webpage, add to IPFS, and republish to IPNS.
Explanation
At any time you like you may generate a new name keypair to use with IPFS/IPNS work. This will allow you to work with multiple keypairs other than your primary Peer ID.
Next Steps
Next, proceed to the Merkle Trees and the IPFS DAG tutorial.
Last updated