How to import key to let others publish in same IPNS record

I was trying to implement a function(in HTML) such that people can hit a button and automatically generate a new file and publish it to an IPNS record. I’ve successfully implemented the first part(generating files).

As for the second part, I want to know several things:

  1. Does the user need to have the same key to publish to the same IPNS record?
  2. If so, how to import the key with ipfs.key.import? it says we need PEM format and how can we get it?
  3. If I have the key locally, how to convert it to PEM format so that others can import the key?
  4. how to initialize IPFS(with js-IPFS) so that node used the key that is assigned?

Here is my workflow: 1. in a website, the user hit a button and adds a new file to IPFS; 2. automatically publishes the generated file to the same IPNS record and lets the user retrieve it.


Bad idea. Kubo isn’t designed to work that way.

The main issue is that it “reprovides” the IPNS record every 4 hours. So, if you publish a new record on a node, it provides it. If you later publish to the same address from another node, it provides the new one. But, a bit later, the original node will “reprovide” its own record, walking it back. Then the other will reprovide its record, etc… The more nodes you have, the more they will fight (and only one has the real record at any one time). Also, they each keep the count locally, so multiple nodes will start providing records with the same count, but with different content. In the end, it’ll be a mess.

In short, don’t share keys between nodes.


So with IPFS/IPNS, it is not possible to collaborate on changing files but preserving the link at the same time?

Not without all communicating with one centralized point that will do the IPNS publish (as far as I know).

1 Like

@ylempereur is right. There’s a grow only counter in every IPNS records. It’s for knowing which record is newest. If you can’t save this value anywhere then it’s not going to work.

1 Like