### Install storetheindex Go tool Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Installs the `storetheindex` command-line tool using the Go package manager. This fetches the specified version of the tool from GitHub and compiles it, making the `storetheindex` executable available in your Go binary path. Requires Go to be installed and configured. ```Shell go install github.com/ipni/storetheindex@v0.5.8 ``` -------------------------------- ### Install index-provider Go Tool Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Installs the index-provider command-line tool using the Go package manager at a specific version. ```Shell go install github.com/ipni/ipni/cmd/provider@v0.10.2 ``` -------------------------------- ### Start IPFS Daemon (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/setup.md Starts the IPFS daemon process, connecting the local node to the IPFS network and making it available for operations like adding, retrieving, and sharing data. ```Shell ipfs daemon ``` -------------------------------- ### Start index-provider Daemon Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Starts the index-provider daemon process, making it available to announce and serve index data. ```Shell provider daemon ``` -------------------------------- ### Verify IPFS Installation (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/setup.md Checks the installed version of the IPFS command-line interface (CLI) to confirm successful installation. ```Shell ipfs --version ``` -------------------------------- ### Start storetheindex daemon Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Starts the local `storetheindex` daemon process. This command launches the indexer, allowing it to listen for connections and process advertisements from IPFS nodes. It runs in the foreground by default. ```Shell storetheindex daemon ``` -------------------------------- ### Starting IPFS Node (CLI) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/basics/index.md Starts the local IPFS daemon process. This command is necessary to run an IPFS node and interact with the network. It will output information about the node, including listening addresses and the WebUI URL. ```Shell ipfs daemon ``` -------------------------------- ### List .ipfs Directory Contents (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/setup.md Lists the contents of the `.ipfs` repository directory, showing configuration files, data stores, and other repository components. ```Shell ls ``` -------------------------------- ### Initialize IPFS Node (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/setup.md Initializes a new IPFS repository on the local machine, creating the necessary configuration files and generating a unique peer identity for the node. ```Shell ipfs init ``` -------------------------------- ### Start Kubo IPFS daemon Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Starts the Kubo IPFS node daemon process. This command brings the IPFS node online, enabling it to connect to the IPFS network, serve content, and utilize the custom routing configuration defined previously. It typically runs in the foreground unless daemonized. ```Shell ipfs daemon ``` -------------------------------- ### Configure index-provider Reframe Settings Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Shows an example configuration for the 'Reframe' section of the index-provider config file, including listen addresses, timeouts, and the ProviderID. ```JSON ... "Reframe": { "ListenMultiaddr": "/ip4/127.0.0.1/tcp/50617", "ReadTimeout": "10m0s", "WriteTimeout": "10m0s", "CidTtl": "24h0m0s", "ChunkSize": 1, "SnapshotSize": 100, "ProviderID": "12D3KooWBEQR33uW1T6axtpspeyJo6m8Sy531fQ8mzQbW1JBnWxJ", "DsPageSize": 5000, "Addrs": [ "/ip4/0.0.0.0/tcp/4001", "/ip6/::/tcp/4001", "/ip4/0.0.0.0/udp/4001/quic", "/ip6/::/udp/4001/quic" ] } ``` -------------------------------- ### Inspect Data Field via IPLD Path (Bash) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipld/ipld-pathing/index.md Demonstrates using IPLD pathing (`/ipld/.../Data`) with `ipfs dag get` to directly access and inspect the `Data` field of a block. This example targets the data of a specific link identified by index. ```bash ipfs dag get /ipld/QmQ2ocFLq6d7ZiVEQfuEGEr4niJmdSscoyLkgTKRWmAEqg/Links/7/Hash/Data | jq ``` -------------------------------- ### Formatting Video Title with Presenter | Markdown/Hugo Source: https://github.com/protocol/launchpad/blob/main/STYLE-GUIDE.md Demonstrates the markdown and Hugo shortcode structure for adding a video title, presenter names, and embedding a YouTube video using the `youtube` shortcode. ```Markdown/Hugo Shortcode #### Video Title | Organization Name(if not PL) - Name(s) of Presenters In this talk by Steven & Dietrich, they review some of the customs and best practices involved when becoming a part of an open source community. {{< youtube GcvGc3pgOT8 >}} ``` -------------------------------- ### Embedding Google Form | Hugo Shortcode Source: https://github.com/protocol/launchpad/blob/main/STYLE-GUIDE.md Provides an example of using the `embed` Hugo shortcode to embed a Google Form into the page content using its public viewform URL. ```Hugo Shortcode {{% embed src="https://docs.google.com/forms/d/e/1FAIpQLSfBhz3elo3K8U6MpMKeO1-0CfTdTQwPaMSYJPi3bSNyFLm0Dw/viewform?usp=sf_link" %}} ``` -------------------------------- ### Change Directory to .ipfs (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/setup.md Changes the current working directory to the `.ipfs` repository directory created during initialization, allowing inspection of its contents. ```Shell cd .ipfs ``` -------------------------------- ### Example Multiaddress String Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/libp2p/core-concepts/index.md This snippet shows an example of a libp2p multiaddress. Multiaddresses are self-describing network addresses that specify the protocol stack required to reach a peer or resource. ```Multiaddress /ip4/127.0.0.1/tcp/8080/http/my-image.png ``` -------------------------------- ### Referencing Local Image | Markdown Source: https://github.com/protocol/launchpad/blob/main/STYLE-GUIDE.md Shows the markdown syntax for embedding an image file located in the same directory as the `index.md` file, using only the image filename. ```Markdown ![Protocol Labs Logo](name-of-image.png) ``` -------------------------------- ### Examining Downloaded IPFS File (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/basics/index.md An example command showing how to open a file downloaded from IPFS (identified by its CID, e.g., QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR) using the vim text editor. This allows inspection of the file's local content. ```Shell vim QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR ``` -------------------------------- ### List Directory Contents (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/setup.md Lists all files and directories, including hidden ones (`-a`), in a long format (`-l`) within the current directory. Used here to show the created `.ipfs` directory. ```Shell ls -la ``` -------------------------------- ### Getting Raw IPFS Block Data (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipld/ipld-pathing/index.md Demonstrates the `ipfs block get` command to retrieve the raw binary bytes of an IPFS block identified by its CID. This shows the underlying data format (like DAG-PB) before it is interpreted or formatted. ```Shell ipfs block get QmQ2ocFLq6d7ZiVEQfuEGEr4niJmdSscoyLkgTKRWmAEq ``` -------------------------------- ### Embedding Online Image | Markdown Source: https://github.com/protocol/launchpad/blob/main/STYLE-GUIDE.md Illustrates the standard markdown syntax for embedding an image hosted on an external URL, including the alt text and the image source URL. ```Markdown ![Distributed Web](https://protocol.ai/assets/img/pl_projects.87ac4e1b.png) ``` -------------------------------- ### Embedding YouTube Video | Hugo Shortcode Source: https://github.com/protocol/launchpad/blob/main/STYLE-GUIDE.md Demonstrates the simplified `youtube` Hugo shortcode for embedding a YouTube video by providing only the video ID. ```Hugo Shortcode {{< youtube 2RCwZDRwk48 >}} ``` -------------------------------- ### Example Output of Running Go IPFS Client Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/ipfs-api.md This Bash snippet shows the expected console output when running the Go IPFS client application. It demonstrates the successful addition of a file to IPFS, displaying its CID, and the resolution of the IPNS record to that CID. ```Bash > go run . Adding file to IPFS File added with CID: QmNsA8eUBSbpdCVHMLa8Py5TcNoZ1D9U5GkginqktrqNF1 ...output omitted... IPNS is pointing to: /ipfs/QmNsA8eUBSbpdCVHMLa8Py5TcNoZ1D9U5GkginqktrqNF1 ``` -------------------------------- ### Load index.html via IPFS Path (Bash) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipld/ipld-pathing/index.md Demonstrates using `ipfs dag get` with a standard IPFS path to retrieve the content of an `index.html` file within a CID. The output is piped to `jq` for formatting. ```bash ipfs dag get QmQ2ocFLq6d7ZiVEQfuEGEr4niJmdSscoyLkgTKRWmAEqg/index.html | jq ``` -------------------------------- ### Tagging Content Section by Level | Hugo Shortcode Source: https://github.com/protocol/launchpad/blob/main/STYLE-GUIDE.md Demonstrates using the `level` Hugo shortcode to wrap a block of content, making it visible only to users assigned the specified learning level (e.g., `deep`). ```Hugo Shortcode {{% level type="[deep]" %}} Text for deep residents {{% /level %}} ``` -------------------------------- ### Adding Page Metadata (Front Matter) | YAML/Hugo Source: https://github.com/protocol/launchpad/blob/main/STYLE-GUIDE.md Illustrates the YAML front matter structure used to configure page settings like title, description, menu placement, weight, category, and assign learning levels (`shallow`, `deep`) to the entire page. ```YAML --- title: "IPLD Resources" description: "Explore beyond the curriculum" draft: false menu: curriculum: parent: "curriculum-ipld" weight: 280 category: lecture level: - shallow - deep --- ``` -------------------------------- ### Navigate IPLD Block using Paths with ipfs dag get Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/ipld/distributed-data-structures.md These commands demonstrate using IPLD paths with `ipfs dag get` to retrieve specific fields or nested values within a block addressed by its CID. The path is appended to the CID, allowing navigation through the data structure. ```bash $ ipfs dag get bafyreiaqpwbbyjo4a42saasj36kkrpv4tsherf2e7bvezkert2a7dhonoi/Message "This is the Genesis Block of the Filecoin Decentralized Storage Network." ``` ```bash $ ipfs dag get bafyreiaqpwbbyjo4a42saasj36kkrpv4tsherf2e7bvezkert2a7dhonoi/TokenAmounts/ProtocolLabs/Foundation "100,000,000" ``` -------------------------------- ### Set Go Environment Variables Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md These commands set the GOPATH environment variable to the user's home directory and add the Go binary directory ($GOPATH/bin) to the system's PATH. This is necessary to ensure Go tools and installed binaries are accessible from the command line. ```Shell $ export GOPATH=$HOME/go $ export PATH=$PATH:$GOPATH/bin ``` -------------------------------- ### Stop IPFS Daemon (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/setup.md Terminates all running IPFS daemon processes on the system. This is an alternative way to stop the node compared to using Ctrl+C. ```Shell killall ipfs ``` -------------------------------- ### Load Directory via IPFS Path (Bash) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipld/ipld-pathing/index.md Illustrates how to navigate into a directory structure within a CID using `ipfs dag get` and a standard IPFS path. This command retrieves the block representing the specified directory. ```bash ipfs dag get QmQ2ocFLq6d7ZiVEQfuEGEr4niJmdSscoyLkgTKRWmAEqg/docs/codecs/known | jq ``` -------------------------------- ### Embedding Google Doc | Hugo Shortcode Source: https://github.com/protocol/launchpad/blob/main/STYLE-GUIDE.md Demonstrates using the `embed` Hugo shortcode to create an iframe for a Google Document, specifying the source URL and custom width and height attributes. ```Hugo Shortcode {{% embed src="https://docs.google.com/document/d/1EP6S8k-DNsDgIKmtrA_9YrCghq3F21IqhDh9THNuoOU/edit" width="500px" height="600px" %}} ``` -------------------------------- ### Running Basic Docker Job with Bacalhau CLI (Bash) Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/bacalhau/index.md This command submits a new job to the Bacalhau network. It uses the `docker run` subcommand to specify a Docker container (`ubuntu`) and the command to execute inside it (`echo Hello World`). This is a simple example demonstrating how to run a basic computation. ```Bash bacalhau docker run ubuntu echo Hello World ``` -------------------------------- ### Load Data with Raw Codec via IPLD Path (Bash) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipld/ipld-pathing/index.md Illustrates how to use the `--output-codec=raw` flag with `ipfs dag get` and IPLD pathing to retrieve the raw bytes of the data field, bypassing the default DAG-JSON transformation. ```bash ipfs dag get --output-codec=raw /ipld/QmQ2ocFLq6d7ZiVEQfuEGEr4niJmdSscoyLkgTKRWmAEqg/Links/7/Hash/Data ``` -------------------------------- ### Inspecting IPLD DAG Node with jq (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipld/ipld-pathing/index.md Executes `ipfs dag get` on a given CID to retrieve its DAG structure in DAG-JSON format. The output is piped to `jq` for pretty-printing, making the `Data` and `Links` properties of the node easily readable. ```Shell ipfs dag get QmQ2ocFLq6d7ZiVEQfuEGEr4niJmdSscoyLkgTKRWmAEqg | jq ``` -------------------------------- ### Running Tailwind CSS Daemon Source: https://github.com/protocol/launchpad/blob/main/README.md This command starts the Tailwind CSS daemon, which watches for changes in the input CSS file (`./static/css/tailwind-input.css`) and generates a minified output CSS file (`./static/css/tailwind-output.css`). It's used for managing the CSS for the Launchpad homepage. ```Shell npx tailwindcss -i ./static/css/tailwind-input.css -o ./static/css/tailwind-output.css --minify --watch ``` -------------------------------- ### Output: Directory Loaded via IPFS Path (JSON) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipld/ipld-pathing/index.md Displays the expected JSON output when retrieving a directory block using `ipfs dag get` via an IPFS path. The output structure reflects the links (files/subdirectories) within that directory. ```json { "Data": { "/": { "bytes": "CAIS0s4BPCFET0CUWVBF... "} }, "Links": [] } ``` -------------------------------- ### Embedding Google Drive File | Hugo Shortcode Source: https://github.com/protocol/launchpad/blob/main/STYLE-GUIDE.md Illustrates using the `embed` Hugo shortcode to embed a Google Drive file (like a presentation or PDF) using its shareable link and setting width and height as percentages. ```Hugo Shortcode {{% embed src="https://drive.google.com/file/d/1EHUXFm0SA4DiBlHTXnRQQ-vHXuQdyBCo/view?usp=sharing" width="100%" height="100%" %}} ``` -------------------------------- ### Stopping IPFS Node (CLI) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/basics/index.md Terminates all running IPFS daemon processes. This is an alternative way to stop the node besides using Ctrl+C, and can also resolve issues where a lock file prevents a new daemon from starting. ```Shell killall ipfs ``` -------------------------------- ### DAG-CBOR Encoded Data (Hexadecimal) Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/ipld/data-model-and-codecs.md Shows the hexadecimal representation of binary data encoded using the DAG-CBOR format. This is the raw binary output of the example data, represented for inspection. DAG-CBOR is a purely binary format. ```Hex a764696e74731905396562797465734401030307656c696e6b73d82a58250001711220785197229dc8bb115294 5da58e2348f7e279eeded06cc2ca736d0e879858b501666172726179738301020366666c6f617473fb402abd70 a3d70a3d66737472696e67781ae298baefb88f202077652063616e20646f20737472696e67732168626f6f6c65 616e73f5 ``` -------------------------------- ### Load Link by Index via IPLD Path (Bash) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipld/ipld-pathing/index.md Shows how to use IPLD pathing (`/ipld/...`) with `ipfs dag get` to access a specific link within a block by its numerical index (`Links//Hash`). This retrieves the CID of the target link. ```bash ipfs dag get /ipld/QmQ2ocFLq6d7ZiVEQfuEGEr4niJmdSscoyLkgTKRWmAEqg/Links/3/Hash | jq ``` -------------------------------- ### Output: index.html Loaded via IPFS Path (JSON) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipld/ipld-pathing/index.md Shows the expected JSON output when retrieving an `index.html` file using `ipfs dag get` via an IPFS path. The `Data` field contains the Base64 encoded content, and `Links` is empty for a single file. ```json { "Data": { "/": { "bytes": "CAIS0s4BPCFET0NUWVBF... "} }, "Links": [] } ``` -------------------------------- ### Example DAG-JSON Structure Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/ipld/data-model-and-codecs.md Illustrates the structure of data encoded using the DAG-JSON format, showing various data types like arrays, booleans, bytes, floats, integers, links, and strings. Note that DAG-JSON strips extraneous whitespace. ```JSON { "arrays": [1, 2, 3], "booleans": true, "bytes": { "/": { "bytes": "AQMDBw" } }, "floats": 13.37, "ints": 1337, "links": { "/": "bafyreidykglsfhoixmivffc5uwhcgshx4j465xwqntbmu43nb2dzqwfvae" }, "string": "☺️ we can do strings!" } ``` -------------------------------- ### Listing Local Files (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/basics/index.md A standard shell command used to list the files and directories within the current working directory. In this context, it's used to verify that a file downloaded from IPFS using `ipfs get` has appeared locally. ```Shell ls ``` -------------------------------- ### Read File Content Using Go IPFS API Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/ipfs-api.md This Go function reads the content of a file from IPFS using its CID. It utilizes the `sh.Cat` method to get a reader, then `io.ReadAll` to buffer the data into bytes, and finally converts the bytes to a string. ```Go func readFile(sh *shell.Shell, cid string) (*string, error) { reader, err := sh.Cat(fmt.Sprintf("/ipfs/%s", cid)) if err != nil { return nil, fmt.Errorf("Error reading the file: %s", err.Error()) } bytes, err := io.ReadAll(reader) if err != nil { return nil, fmt.Errorf("Error reading bytes: %s", err.Error()) } text := string(bytes) return &text, nil } ``` -------------------------------- ### Retrieve Filecoin Genesis Block via ipfs dag get Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/ipld/distributed-data-structures.md This command fetches the Filecoin genesis block using its CID and outputs its content translated into the DAG-JSON codec for human-readable printing. It demonstrates retrieving an entire block's data. ```bash $ ipfs dag get bafyreiaqpwbbyjo4a42saasj36kkrpv4tsherf2e7bvezkert2a7dhonoi {"Datetime":"2017-05-05 01:27:51","Message":"This is the Genesis Block of the Filecoin Decentralized Storage Network.","Network":"Filecoin","Token":"Filecoin","TokenAmounts":{"Miners":"1,400,000,000","ProtocolLabs":{"Development":"300,000,000","Foundation":"100,000,000","Fundraising":"200,000,000"},"TotalSupply":"2,000,000,000"}} ``` -------------------------------- ### Example Circuit Relay Multiaddress Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/libp2p/nat-traversal/index.md This multiaddress string demonstrates the format used in libp2p to specify a connection that should be routed through a circuit relay. It includes the address of the relay peer (`/ip4/127.0.0.1/tcp/2330/p2p/PEER_ID_OF_C`) followed by the `/p2p-circuit/p2p/PEER_ID_OF_A` part, indicating that the connection should be relayed to peer `A` via peer `C`. ```Multiaddress /ip4/127.0.0.1/tcp/2330/p2p/PEER_ID_OF_C/p2p-circuit/p2p/PEER_ID_OF_A ``` -------------------------------- ### Implement Source Node - Go Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/libp2p/handlers-tutorial.md This function creates a source libp2p node, connects it to a target node using provided information, opens a stream for the "/hello/1.0.0" protocol, and sends a "Hello from Launchpad!" message over the stream. It uses `context.Background()` and handles potential errors by panicking. ```Go func runSourceNode(targetNodeInfo peer.AddrInfo) { log.Printf("Creating source node...") sourceNode := createNode() log.Printf("Source node created with ID '%s'", sourceNode.ID().String()) sourceNode.Connect(context.Background(), targetNodeInfo) // TO BE IMPLEMENTED: Open stream and send message stream, err := sourceNode.NewStream(context.Background(), targetNodeInfo.ID, "/hello/1.0.0") if err != nil { panic(err) } message := "Hello from Launchpad!\n" log.Printf("Sending message...") _, err = stream.Write([]byte(message)) if err != nil { panic(err) } } ``` -------------------------------- ### Test Application - Bash Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/libp2p/handlers-tutorial.md This snippet shows how to run the Go application from the command line using `go run .`. It also includes the expected console output demonstrating the creation of source and target nodes, the connection, message sending, and message reception via the "/hello/1.0.0" protocol stream. ```Bash > go run . 2022/09/08 12:08:02 Creating target node... 2022/09/08 12:08:02 Target node created with ID '12D3KooWF7r4SxND9Qf8uu9u3PtDduG5ET4NZf1Pw25BMqQEvXRP' 2022/09/08 12:08:02 Creating source node... 2022/09/08 12:08:02 Source node created with ID '12D3KooWMErSsjs4nPzTDjSvGcWipqyfJYxoSQJM57mTPWccEYQA' 2022/09/08 12:08:02 Sending message... 2022/09/08 12:08:02 /hello/1.0.0 stream created 2022/09/08 12:08:02 Message from '12D3KooWMErSsjs4nPzTDjSvGcWipqyfJYxoSQJM57mTPWccEYQA': Hello from Launchpad! ``` -------------------------------- ### Running libp2p Node Application (Bash) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/libp2p/creating-simple-node/index.md This Bash snippet shows the command to execute the Go libp2p application and its expected output. Running `go run .` in the application directory compiles and runs the program, which prints information about the created nodes and confirms the connection by showing the source node has one peer. ```Bash > go run . -- SOURCE NODE INFORMATION -- ID: 12D3KooWCGcgrrrfDwzLmNeZ25543kYcewKxXzgDkGJGNXw1ZUf3 Multiaddresses: /ip4/192.168.0.10/tcp/63678, /ip4/127.0.0.1/tcp/63678, /ip6/::1/tcp/63681 -- TARGET NODE INFORMATION -- ID: 12D3KooWLkzhtJxcSnasfzkXGQzgKGqxGtUDpACZSXt3HM4Rn3op Multiaddresses: /ip4/192.168.0.10/tcp/8007, /ip4/127.0.0.1/tcp/8007 Source node peers: 1 ``` -------------------------------- ### Creating New Tutorial Module Directory (Shell) Source: https://github.com/protocol/launchpad/blob/main/templates/README.md Creates a new directory for a tutorial module within the content structure. This directory will contain the markdown files for the individual tutorials belonging to this module. ```Shell mkdir /content/en/tutorials/ ``` -------------------------------- ### Creating a basic libp2p Node in Go Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/libp2p/connections/index.md This snippet demonstrates how to create a new libp2p host (node) in Go using the `go-libp2p` library. It initializes a node with default settings and includes basic error handling for the creation process. ```Go import ( libp2p "github.com/libp2p/go-libp2p" ) func main() { host, err := libp2p.New() if err != nil { panic(err) } } ``` -------------------------------- ### Configuring Tutorial Header Metadata (TOML) Source: https://github.com/protocol/launchpad/blob/main/templates/README.md Sets the front matter metadata for a new tutorial markdown file. Includes the title, description, draft status, and specifies the parent tutorial module using its identifier for navigation. This configuration is used by the site generator. ```TOML title: "Title (Tutorial)" description: "Deep/Shallow Dive Tutorial – Subtitle" draft: false menu: tutorials: parent: "" ``` -------------------------------- ### Copying Tutorial Template File (Shell) Source: https://github.com/protocol/launchpad/blob/main/templates/README.md Copies the tutorial markdown template file to a new location within a specific tutorial module directory. This is the first step in creating a new tutorial page. Requires the template file and the target module directory to exist. ```Shell cp templates/tutorial-temp.md /content/en/tutorials// ``` -------------------------------- ### Orchestrating Node Creation with go-libp2p in Go Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/libp2p/handlers-tutorial.md This function sets up the main execution flow for the libp2p application. It creates a context, initializes the target node using `runTargetNode`, retrieves its address information, and then initializes the source node using `runSourceNode`, passing the target node's details. It concludes by waiting on the context. ```Go func main() { ctx, _ := context.WithCancel(context.Background()) // Create target node info := runTargetNode() // Create source node and provide the target node information runSourceNode(info) <-ctx.Done() } ``` -------------------------------- ### Connecting libp2p Nodes (Go) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/libp2p/creating-simple-node/index.md This Go function connects a source libp2p node to a target node. It uses `host.InfoFromHost` to obtain the target node's address information and then calls `sourceNode.Connect()` to establish the connection. The function requires the source and target `host.Host` interfaces as input. ```Go func connectToTargetNode(sourceNode host.Host, targetNode host.Host) { targetNodeAddressInfo := host.InfoFromHost(targetNode) err := sourceNode.Connect(context.Background(), *targetNodeAddressInfo) if err != nil { panic(err) } } ``` -------------------------------- ### Creating a Default libp2p Node (Go) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/libp2p/creating-simple-node/index.md This Go function creates a basic libp2p node using `libp2p.New()`. It initializes the node with a default configuration, assigning a random peer ID and listening on a random TCP port. The function returns the `host.Host` interface representing the created node. ```Go func createSourceNode() host.Host { node, err := libp2p.New() if err != nil { panic(err) } return node } ``` -------------------------------- ### Creating a Configured libp2p Node (Go) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/libp2p/creating-simple-node/index.md This Go function creates a libp2p node with specific configuration options. It uses `libp2p.New()` with `libp2p.ListenAddrStrings` to make the node listen on TCP port 8007. The function returns the configured `host.Host` interface. ```Go func createTargetNode() host.Host { node, err := libp2p.New( libp2p.ListenAddrStrings( "/ip4/0.0.0.0/tcp/8007" ), ) if err != nil { panic(err) } return node } ``` -------------------------------- ### Placeholder Code Block Source: https://github.com/protocol/launchpad/blob/main/templates/tutorial-temp.md This snippet represents a placeholder code block within a tutorial step. It is intended to be replaced with actual code relevant to the specific tutorial topic. The surrounding text provides context and instructions for the step. ```placeholder some code\n\n ``` -------------------------------- ### Negotiating Multistream Protocol (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/libp2p/connections/index.md Demonstrates the initial handshake using the multistream-select protocol to verify peer compatibility. Shows the request for the protocol version and the peer's positive response. ```shell # Request: Do you understand "/multistream/1.0.0"? > /multistream/1.0.0 # Response: I do. + /multistream/1.0.0 ``` -------------------------------- ### Initialize index-provider Configuration Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Initializes the default configuration and repository for the index-provider daemon. ```Shell provider init ``` -------------------------------- ### Defining New Tutorial Module in Menu Config (TOML) Source: https://github.com/protocol/launchpad/blob/main/templates/README.md Adds a new entry to the site's menu configuration file to define a new tutorial module. Specifies the module's display name, weight for ordering, a unique identifier, category, and an associated image. This makes the module appear in the site navigation. ```TOML [[tutorials]] name = "" weight = identifier = "" [tutorials.params] category = "libp2p" image = "/tutorials/libp2p.png" ``` -------------------------------- ### Initialize storetheindex config Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Initializes the configuration and data repository for the local `storetheindex` instance. This command creates the necessary directory structure and default configuration file (`config.json`) in the user's home directory (`~/.storetheindex`). It prepares the indexer for first use. ```Shell storetheindex init ``` -------------------------------- ### Configure index-provider Direct Announce Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Adds the 'DirectAnnounce' section to the index-provider config, specifying URLs for direct HTTP announcements instead of libp2p pubsub. ```JSON "DirectAnnounce": { "URLs": ["http://0.0.0.0:3001"] } ``` -------------------------------- ### Setting Stream Handler for go-libp2p Target Node in Go Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/libp2p/handlers-tutorial.md This function initializes a target libp2p node and configures a stream handler for the `/hello/1.0.0` protocol. It uses `SetStreamHandler` to associate an anonymous function with the protocol. This handler function logs stream creation, calls `readHelloProtocol` to process incoming data, and manages the stream's lifecycle (reset or close) based on the read operation's success. ```Go func runTargetNode() peer.AddrInfo { log.Printf("Creating target node...") targetNode := createNode() log.Printf("Target node created with ID '%s'", targetNode.ID().String()) // TO BE IMPLEMENTED: Set stream handler for the "/hello/1.0.0" protocol targetNode.SetStreamHandler("/hello/1.0.0", func(s network.Stream) { log.Printf("/hello/1.0.0 stream created") err := readHelloProtocol(s) if err != nil { s.Reset() } else { s.Close() } }) return *host.InfoFromHost(targetNode) } ``` -------------------------------- ### Open index-provider Configuration File Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Opens the index-provider configuration file in the Vim editor for manual editing. ```Shell vim ~/.index-provider/config ``` -------------------------------- ### Kubo custom routing config (JSON) Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Illustrates the structure of the `.ipfs/config` file's `Routing` object after applying the custom configuration. It shows how different routing methods (`find-peers`, `find-providers`, etc.) are mapped to specific routers (`WanDHT`, `ParallelHelper`) and defines the parameters for each router type, including the local CidContact endpoint and parallel execution logic. ```JSON { "Routing": { "Methods": { "find-peers": { "RouterName": "WanDHT" }, "find-providers": { "RouterName": "ParallelHelper" }, "get-ipns": { "RouterName": "WanDHT" }, "provide": { "RouterName": "ParallelHelper" }, "put-ipns": { "RouterName": "WanDHT" } }, "Routers": { "CidContact": { "Parameters": { "Endpoint": "http://127.0.0.1:50617" }, "Type": "reframe" }, "ParallelHelper": { "Parameters": { "Routers": [ { "IgnoreErrors": true, "RouterName": "CidContact", "Timeout": "30m" }, { "ExecuteAfter": "2s", "IgnoreErrors": true, "RouterName": "WanDHT", "Timeout": "30m" } ] }, "Type": "parallel" }, "WanDHT": { "Parameters": { "AcceleratedDHTClient": true, "Mode": "dhtserver", "PublicIPNetwork": true }, "Type": "dht" } }, "Type": "custom" } } ``` -------------------------------- ### Negotiating Security Protocol (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/libp2p/connections/index.md Illustrates the negotiation of a security protocol (like TLS or Noise) after the initial handshake. Shows attempts to negotiate TLS (rejected) and Noise (accepted) using the multistream-select mechanism. ```shell # Request: Do you understand "/tls/1.0.0"? > /tls/1.0.0 # Response: I do not + na # Request: Do you understand "/noise/1.0.0"? > /noise/1.0.0 # Response: I do + /noise/1.0.0 ``` -------------------------------- ### Defining New Curriculum Module in Menu Config (TOML) Source: https://github.com/protocol/launchpad/blob/main/templates/README.md Adds a new entry to the site's menu configuration file to define a new curriculum module. Specifies the module's display name, weight for ordering, a unique identifier, image details, section, and a short description. This makes the module appear in the site navigation. ```TOML [[curriculum]] name = "" weight = 20 identifier = "curriculum-" [curriculum.params] image = "/logos/ipfs.svg" width = 100 height = 100 section = "" description = "" ``` -------------------------------- ### Output: Data Loaded with Raw Codec (HTML) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipld/ipld-pathing/index.md Displays the expected output when retrieving data using the `raw` codec. For an HTML file, this shows the raw HTML content instead of a JSON representation. ```html �� ... IPLD - The data model of the content-addressable web ... ... ``` -------------------------------- ### Adding Curriculum Parent to Tutorial Menu (TOML) Source: https://github.com/protocol/launchpad/blob/main/templates/README.md Modifies the menu configuration for a tutorial to also link it within a specific curriculum module. This allows the same content to appear in both the tutorials and curriculum sections of the site navigation. ```TOML menu: tutorials: parent: "tutorials-ipfs" curriculum: parent: "curriculum-ipfs" ``` -------------------------------- ### Counting libp2p Node Peers (Go) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/libp2p/creating-simple-node/index.md This Go function counts the number of peers currently connected to a given libp2p node. It accesses the node's network information via `sourceNode.Network()` and returns the length of the connected peers list. The function takes a `host.Host` interface as input and returns an integer. ```Go func countSourceNodePeers(sourceNode host.Host) int { return len(sourceNode.Network().Peers()) } ``` -------------------------------- ### Find Providers for CID using IPFS Routing Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Uses the IPFS routing system (via the local Kubo node) to find providers for a given Content Identifier (CID). ```Shell ipfs routing findprovs ``` -------------------------------- ### Configure Kubo routing (CLI) Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Sets the custom routing configuration for the Kubo IPFS node using the `ipfs config` command and a JSON payload. This configures parallel routing to both the WAN DHT and a local CidContact indexer. Requires a running IPFS node and the `ipfs` CLI tool. ```Shell ipfs config Routing --json '{ "Type": "custom", "Methods": { "find-peers": { "RouterName": "WanDHT" }, "find-providers": { "RouterName": "ParallelHelper" }, "get-ipns": { "RouterName": "WanDHT" }, "provide": { "RouterName": "ParallelHelper" }, "put-ipns": { "RouterName": "WanDHT" } }, "Routers": { "CidContact": { "Parameters": { "Endpoint": "http://127.0.0.1:50617" }, "Type": "reframe" }, "ParallelHelper": { "Parameters": { "Routers": [ { "IgnoreErrors": true, "RouterName": "CidContact", "Timeout": "30m" }, { "ExecuteAfter": "2s", "IgnoreErrors": true, "RouterName": "WanDHT", "Timeout": "30m" } ] }, "Type": "parallel" }, "WanDHT": { "Parameters": { "AcceleratedDHTClient": true, "Mode": "dhtserver", "PublicIPNetwork": true }, "Type": "dht" } } }' ``` -------------------------------- ### Output: Link Loaded by Index via IPLD Path (JSON) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipld/ipld-pathing/index.md Presents the expected JSON output when retrieving a link's hash using IPLD pathing by index. The output shows the structure of the linked block, similar to retrieving it directly by its CID. ```json { "Data": { "/": { "bytes": "CAIS0s4BPCFET0CUWVBF... "} }, "Links": [] } ``` -------------------------------- ### Run Go Application Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/ipfs-api.md This Bash command executes the Go program located in the current directory. It compiles and runs the `main` package, assuming the IPFS daemon is already running in a separate terminal. ```Bash go run . ``` -------------------------------- ### Encoding and Decoding with ipfs multibase (Bash) Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/ipld/content-addressing-cids/index.md Demonstrates how to use the `ipfs multibase` command-line tool to encode and decode a string using a specific base encoding, such as `base256emoji`. Shows the commands for encoding 'test' and then decoding the resulting emoji string. ```bash # Encode "test" in base256emoji $ echo -n "test" | ipfs multibase encode -b base256emoji - 🚀😈✋🌈😈 # Decode the emoji $ echo -n "🚀😈✋🌈😈" | ipfs multibase decode - test ``` -------------------------------- ### Adding String Content to IPFS using Go Client Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/ipfs-api.md This Go function, `addFile`, shows how to add arbitrary string content as a file to IPFS using the go-ipfs-api client. It takes a *shell.Shell object and a string `text` as input. The `sh.Add` method is used with a `strings.NewReader` to process the text, returning the Content Identifier (CID) of the newly added file and any potential error. ```Go func addFile(sh *shell.Shell, text string) (string, error) { return sh.Add(strings.NewReader(text)) } ``` -------------------------------- ### Listing All Pinned Files - IPFS CLI - Shell Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/basics/index.md Lists all files currently pinned on your IPFS node, regardless of the pinning type (direct, recursive, indirect). Useful for seeing what data your node is hosting. ```Shell ipfs pin ls --type=all ``` -------------------------------- ### Downloading IPFS File (CLI) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/basics/index.md Retrieves a file or directory from the IPFS network using its Content Identifier (CID) and saves it to the current local directory. The downloaded file/directory will be named after its CID. ```Shell ipfs get ``` -------------------------------- ### List IPFS Keys Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/ipfs-api.md This Bash command lists the IPFS key pairs available on the local node. The `-l` flag provides detailed output, including the public key and the key name (e.g., 'self'). ```Bash ipfs key list -l ``` -------------------------------- ### Listing IPFS Swarm Peers (CLI) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/basics/index.md Displays a list of the IPFS peers that your node is currently directly connected to in the swarm. This command helps visualize the immediate connections of your node within the IPFS network. ```Shell ipfs swarm peers ``` -------------------------------- ### Verifying Pinned File Listing - IPFS CLI - Shell Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/basics/index.md Runs the command to list all pinned files again after adding a new pin to verify that the newly pinned file's CID appears in the list. ```Shell ipfs pin ls --type=all ``` -------------------------------- ### Adding Local File/Directory to IPFS Node (Pinning) - IPFS CLI - Shell Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/basics/index.md Adds a file or directory from your local machine to your IPFS node, effectively 'pinning' it and making it available on the network. Replace `directory/filename.extension` with the actual path to your file. ```Shell ipfs add directory/filename.extension ``` -------------------------------- ### Output: Data Field Inspected via IPLD Path (JSON) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipld/ipld-pathing/index.md Shows the expected JSON output when inspecting the `Data` field of a block using IPLD pathing. The output contains the Base64 encoded bytes of the data. ```json { "/": { "bytes": "CAIS0s4BPCFET0CUWVBF... "} } ``` -------------------------------- ### Initializing Go IPFS Client Shell Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/ipfs-api.md This Go code snippet demonstrates how to establish a connection to a running IPFS node's API using the go-ipfs-api library. It creates a new shell object by providing the node's API address, typically "localhost:5001". The returned *shell.Shell object is the primary interface for performing IPFS operations programmatically. ```Go sh := shell.NewShell("localhost:5001") ``` -------------------------------- ### Find CID in storetheindex Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/dev-tools/network-indexer/index.md Queries the local storetheindex daemon to find information about a specific Content Identifier (CID). ```Shell storetheindex find --cid ``` -------------------------------- ### Formatting IPFS CID to Base256emoji (Shell) Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/ipld/content-addressing-cids/index.md Demonstrates how to use the `ipfs cid format` command to transform a CIDv1 from its default base32 representation to the base256emoji encoding. The command specifies the CID version (-v 1) and the target base (-b base256emoji). ```Shell ipfs cid format -v 1 -b base256emoji bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi ``` -------------------------------- ### Pinning File from IPFS Network by CID - IPFS CLI - Shell Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/basics/index.md Pins a file that already exists on the IPFS network to your local node using its Content Identifier (CID). This makes the file available from your node without needing a local copy outside of IPFS. Replace `` with the actual CID of the file. ```Shell ipfs pin add ``` -------------------------------- ### Download File Using Go IPFS API Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/ipfs-api.md This Go function downloads a file from IPFS to a local path using its CID. It calls the `sh.Get` method, providing the file's CID and the desired local file path (`YourLocalPath`) as arguments. ```Go func downloadFile(sh *shell.Shell, cid string) error { return sh.Get(cid, YourLocalPath) } ``` -------------------------------- ### Examining IPFS Peer Info (CLI) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/basics/index.md Retrieves and displays information about a specific IPFS peer identified by its Peer ID (CID). This command allows you to inspect details about a node you are connected to or interested in. ```Shell ipfs id ``` -------------------------------- ### Defining UnixFS Data Structures (Protobuf) Source: https://github.com/protocol/launchpad/blob/main/content/en/curriculum/ipfs/unixfs/index.md This protobuf definition specifies the structure of the `Data`, `Metadata`, and `UnixTime` messages used by UnixFS in IPFS. It defines fields like `Type` (Raw, Directory, File, etc.), `Data` content, `filesize`, `blocksizes`, and time information, which are essential for interpreting the content of IPFS blocks. ```Protobuf message Data { enum DataType { Raw = 0; Directory = 1; File = 2; Metadata = 3; Symlink = 4; HAMTShard = 5; } required DataType Type = 1; optional bytes Data = 2; optional uint64 filesize = 3; repeated uint64 blocksizes = 4; optional uint64 hashType = 5; optional uint64 fanout = 6; optional uint32 mode = 7; optional UnixTime mtime = 8; } message Metadata { optional string MimeType = 1; } message UnixTime { required int64 Seconds = 1; optional fixed32 FractionalNanoseconds = 2; } ``` -------------------------------- ### Reading IPFS File Content (CLI) Source: https://github.com/protocol/launchpad/blob/main/content/en/tutorials/ipfs-intro/basics/index.md Outputs the raw content of a file addressed by its Content Identifier (CID) directly to the standard output. This is useful for quickly viewing the content of text-based files stored on IPFS. ```Shell ipfs cat ```