Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 1.27 KB

File metadata and controls

25 lines (20 loc) · 1.27 KB
title Create a DAG node and return a Content Identifier (CID)
type code

In this tutorial we'll be exploring the IPFS DAG API, which lets us store data objects in IPFS. (You can store more exciting things in IPFS, like your favorite cat GIF, but you'd need to use a different API for that.)

You can create a new DAG node by passing a data object into the ipfs.dag.put method, which returns a Content Identifier (CID) for the newly created node.

ipfs.dag.put({ hello: 'world' })

A CID is an address for a block of data in IPFS that is derived from its content. Every time someone puts the same { hello: 'world' } data into IPFS, they'll get back an identical CID to the one you got. If they put in { hell0: 'w0rld' } instead, the CID will be different.

Note: Throughout our lessons we'll be using a code editor like the one below. Enter your solution code within the run function that's pre-populated for you, being sure to return the requested value within that function. (You won't need to update the return run line at the end; that's just there to make the code editor work.)