Insert into dht using cli

I want to use the command
ipfs dht put

I first created a key using
ipfs key gen --type=rsa --size=2048 Sample
(A hash has been generated)

Then I tried publishing
ipfs.exe name publish --key=Sample /ipfs/QmOfSample
(But the above command kept waiting)

Then I used ipfs dht put
ipfs.exe dht put /ipns/QmOfSample
(Error: record could not be unmarshalled)

Can I have more understanding on how to use these commands? Is there any example on how I can use dht put and get commands?

Please let me know if I am missing anything.

Thank you.

@adin Can you please help me?

Thank you.

@susarlanikhilesh the ipfs dht put /ipns/QmOfSample command needs an actual IPNS record as described in ipfs dht put --help

The value must be a valid value for the given key type. For example, if the key
is /ipns/QmFoo, the value must be IPNS record (protobuf) signed with the key
identified by QmFoo.

This means that you’d need to actually construct or get the full IPNS record protobuf into a file and then ipfs dht put /ipns/QmOfSample /path/to/ipns/record.

Why are you trying to do this instead of just doing ipfs name publish? Is it because you’re concerned about how long it was taking? Doing ipfs dht put will not make things go any faster as they both have to do puts to the DHT which is currently slower than we might like (unfortunately a good chunk of the DHT server nodes are still on go-ipfs <0.5.0 which had a number of significant DHT improvements, as more of those nodes update the network performance should improve).

What use case is causing you to be concerned about IPNS publishing performance? You might consider using IPNS over PubSub, while the ipfs name publish command will still wait to return until the DHT publish is completed the PubSub publish will happen quite quickly.