### Install SourceHub Precompiled Binary Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/sourcehub/getting-started/1-readme.md Instructions to download and install the precompiled SourceHub binary using `wget` and move it to `/usr/bin` for system-wide access. ```bash cd $HOME wget https://github.com/sourcenetwork/sourcehub/releases/download/v0.2.0/sourcehubd chmod +x sourcehubd sudo mv sourcehubd /usr/bin ``` -------------------------------- ### Install SourceHub from Source Code Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/sourcehub/getting-started/1-readme.md Steps to clone the SourceHub repository, checkout a specific version, compile, and install the binary from source code. Requires Go toolchain 1.22+. ```bash cd $HOME git clone https://github.com/sourcenetwork/sourcehub cd sourcehub git checkout v0.2.0 make install export PATH=$PATH:$GOBIN ``` -------------------------------- ### Install DefraDB from source Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Instructions to clone the DefraDB repository, navigate into it, and compile the executable using the Go toolchain's `make install` command. This builds the `defradb` binary. ```bash git clone git@github.com:sourcenetwork/defradb.git cd defradb make install ``` -------------------------------- ### Getting Started with Source Network Development Source: https://github.com/sourcenetwork/docs.source.network/blob/master/README.md These commands install the required dependencies and launch a local development server for the Source Network website. Changes made to the code are typically reflected live without the need to restart the server. ```Shell $ npm install $ npm run start ``` -------------------------------- ### Start a DefraDB node Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Executes the `defradb start` command to initialize and run a local DefraDB node. This command starts the database server, making it ready to accept connections and queries. ```bash defradb start ``` -------------------------------- ### Build DefraDB from Source Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/deployment-guide.md Executes the Make command to build a local DefraDB setup with default configurations, assuming Go and Make are installed. ```Shell make ``` -------------------------------- ### Start DefraDB Node with Default Configuration Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Use this command to start a DefraDB node with its default configuration. When starting for the first time, a key pair is generated and stored in the node's root directory. ```bash defradb start ``` -------------------------------- ### Start DefraDB with TLS and Custom Certificate Paths Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Starts the DefraDB HTTP API with TLS enabled, specifying custom paths for the public and private key files. Use this if your keys are not in the default `~/.defradb/certs/` location. ```bash defradb start --tls --pubkeypath ~/path-to-pubkey.key --privkeypath ~/path-to-privkey.crt ``` -------------------------------- ### Start DefraDB Manually Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/deployment-guide.md Executes the DefraDB binary to start the database with the Badger store backend. This command runs DefraDB as a single statically built binary with no third-party dependencies. ```Shell defradb start --store badger ``` -------------------------------- ### Display DefraDB keyring help options Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Provides a comprehensive list of available commands and options for managing DefraDB's keyring. This is useful for understanding key management functionalities and their usage. ```bash defradb keyring --help ``` -------------------------------- ### Start DefraDB Node for Replicator Target Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md This command starts a DefraDB node configured to act as a target for active replication. It specifies a custom root directory, client API URL, and P2P listening address, but intentionally omits initial peers as replication will be configured manually. ```bash defradb start --rootdir ~/.defradb-nodeB --url localhost:9182 --p2paddr /ip4/0.0.0.0/tcp/9172 ``` -------------------------------- ### Start DefraDB Node with Custom Configuration and Pubsub Peers Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md This command demonstrates how to start a DefraDB node with a custom root directory, client API URL, P2P listening address, and an initial list of pubsub peers. The `--peers` flag accepts a comma-separated list of peer multiaddresses for passive data synchronization. ```bash defradb start --rootdir ~/.defradb-nodeB --url localhost:9182 --p2paddr /ip4/127.0.0.1/tcp/9172 --peers /ip4/127.0.0.1/tcp/9171/p2p/12D3KooWNXm3dmrwCYSxGoRUyZstaKYiHPdt8uZH5vgVaEJyzU8B ``` -------------------------------- ### Start DefraDB with Self-Signed TLS Certificates Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Starts the DefraDB HTTP API with TLS enabled, using self-signed certificates located in the default `~/.defradb/certs/` directory. Keys should be named `server.key` (public) and `server.crt` (private). ```bash defradb start --tls ``` -------------------------------- ### Example: Get all P2P replicators Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_client_p2p_replicator_getall.md Example command to retrieve all active P2P replicators configured in the defradb data synchronization system. ```Shell defradb client p2p replicator getall ``` -------------------------------- ### Add DefraDB to system PATH Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Command to append the directory containing the `defradb` executable to the system's PATH environment variable. This allows `defradb` to be run from any directory in the terminal. ```bash export PATH=$PATH:$(go env GOPATH)/bin ``` -------------------------------- ### Generate DefraDB keyring keys Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Command to generate new private keys for the DefraDB keyring. This is typically used on the initial startup if keys are not found, providing essential `peer-key`, `encryption-key`, and `node-identity-key`. ```bash defradb keyring generate ``` -------------------------------- ### Install Orbisd Binary from Release Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/orbis/getting-started/1-install.md This snippet demonstrates how to download a pre-compiled `orbisd` binary from the official GitHub releases page using `wget`, make it executable, and move it to a system-wide path. Ensure `wget` is installed on your system. ```bash cd $HOME wget https://github.com/sourcenetwork/orbis-go/releases/download/v0.2.3/orbisd chmod +x orbisd sudo mv orbisd /usr/bin ``` -------------------------------- ### Example JSON output for latest document commits Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md This JSON object represents an example response structure when querying for the latest document commits in DefraDB. It shows the `cid`, `delta` (update payload), `height`, and `links` to parent commits. ```json { "data": { "latestCommits": [ { "cid": "bafybeifhtfs6vgu7cwbhkojneh7gghwwinh5xzmf7nqkqqdebw5rqino7u", "delta": "pGNhZ2UYH2RuYW1lY0JvYmZwb2ludHMYWmh2ZXJpZmllZPU=", "height": 1, "links": [ { "cid": "bafybeiet6foxcipesjurdqi4zpsgsiok5znqgw4oa5poef6qtiby5hlpzy", "name": "age" }, { "cid": "bafybeielahxy3r3ulykwoi5qalvkluojta4jlg6eyxvt7lbon3yd6ignby", "name": "name" }, { "cid": "bafybeia3tkpz52s3nx4uqadbm7t5tir6gagkvjkgipmxs2xcyzlkf4y4dm", "name": "points" }, { "cid": "bafybeia4off4javopmxcdyvr6fgb5clo7m5bblxic5sqr2vd52s6khyksm", "name": "verified" } ] } ] } } ``` -------------------------------- ### Verify local DefraDB connection Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Uses the `defradb client collection describe` command to verify that the local DefraDB node is running and accessible. This command attempts to connect and retrieve information about existing collections. ```bash defradb client collection describe ``` -------------------------------- ### Get Peer Information for Specific DefraDB Node URL Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Use this command to retrieve the peer information for a DefraDB node listening on a specific URL. This information, typically in JSON format, is necessary when configuring active replication to that node. ```bash defradb client p2p info --url localhost:9182 ``` -------------------------------- ### Export DefraDB Data to Pretty-Printed JSON Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Backs up the current data state of DefraDB to a specified JSON file, with the content formatted for readability. This is useful for inspection or manual editing. ```bash defradb client backup export --pretty path/to/backup.json ``` -------------------------------- ### Install SourceHub and Orbis: Build from Source Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/sourcehub/networks/testnet-1/overview.md This snippet provides the commands to install SourceHub and Orbis daemons by building them from the Source Network's source code. It involves cloning the repository, checking out a specific version, compiling the chain components, and verifying the installation by checking the Orbis Daemon version. ```bash git clone [repo] git checkout [specific version tag] make build [this does all compilation necessary for the chain] run orbis d version [to test if the installation works] ``` -------------------------------- ### Import Data into DefraDB from JSON Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Restores DefraDB data from a previously exported JSON file. This command can be used to seed a new database or transition data between versions. ```bash defradb client backup import path/to/backup.json ``` -------------------------------- ### Download and Install Precompiled SourceHub Binary Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/sourcehub/networks/testnet-1/join.md Instructions to download a precompiled `sourcehubd` binary from the SourceHub GitHub releases, make it executable, and move it to a system-wide executable path. ```bash cd $HOME wget https://github.com/sourcenetwork/sourcehub/releases/download/v0.2.0/sourcehubd chmod +x sourcehubd sudo mv /usr/bin ``` -------------------------------- ### Compile SourceHub Binary from Source Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/sourcehub/networks/testnet-1/join.md Steps to clone the SourceHub repository, checkout a specific version, compile the binary using `make install`, and add it to the system's PATH. This method requires a local installation of the Go toolchain (minimum version 1.21). ```bash cd $HOME git clone https://github.com/sourcenetwork/sourcehub cd sourcehub git checkout v0.2.0 make install export PATH=$PATH:$GOBIN ``` -------------------------------- ### Expose DefraDB Ports Externally Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Configures DefraDB to bind its P2P network and HTTP API to external interfaces (0.0.0.0) instead of localhost, making them accessible from outside the local machine. ```bash defradb start --p2paddr /ip4/0.0.0.0/tcp/9171 --url 0.0.0.0:9181 ``` -------------------------------- ### Import external keys into DefraDB keyring Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Allows importing existing private keys into the DefraDB keyring. The command requires a name for the key and its hexadecimal representation, facilitating the use of pre-existing cryptographic material. ```bash defradb keyring import ``` -------------------------------- ### Apply DefraDB Schema Migration Up with CLI Examples Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_client_schema_migration_up.md Demonstrates how to apply a schema migration to a DefraDB collection using the `defradb client schema migration up` command, showing examples for migrating from a string, a file, and stdin. ```Shell defradb client schema migration up --collection 2 '[{"name": "Bob"}]' ``` ```Shell defradb client schema migration up --collection 2 -f documents.json ``` ```Shell cat documents.json | defradb client schema migration up --collection 2 - ``` -------------------------------- ### Export DefraDB Data to JSON Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Backs up the current data state of DefraDB to a specified JSON file. This command exports the data without pretty-printing. ```bash defradb client backup export path/to/backup.json ``` -------------------------------- ### Create a new document in DefraDB Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Submits a GraphQL-like mutation request to create a new document of the `User` type in DefraDB. The input includes values for `age`, `verified`, `points`, and `name`. The command returns the unique `_docID` for the newly created document. ```bash defradb client query ' mutation { create_User(input: {age: 31, verified: true, points: 90, name: "Bob"}) { _docID } } ' ``` -------------------------------- ### Manage SourceHub SystemD Service Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/sourcehub/networks/testnet-1/join.md Commands to reload the SystemD daemon, restart the journal, enable the `sourcehubd` service to start automatically on boot, and immediately start the service. Includes a command to follow the service logs for real-time monitoring. ```bash # Restart SystemD systemctl daemon-reload systemctl restart systemd-journald # Start the SourceHub service systemctl enable sourcehubd.service systemctl start sourcehubd.service ``` -------------------------------- ### Deploy Local Secret Ring with Docker Compose Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/orbis/getting-started/2-create.md Instructions to clone the Orbis repository and run the Docker Compose file to initialize 3 Orbis nodes, the Zanzi authorization service, and bootstrap the peer-to-peer network. This setup requires Docker and Docker Compose to be installed locally. Note: This demo setup uses deterministic private keys and is not suitable for production. ```bash cd $HOME git clone https://github.com/sourcenetwork/orbis-go cd orbis-go docker-compose -f demo/zanzi/compose.yaml up ``` -------------------------------- ### Set DefraDB Replicator for Collection to Target Peer Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md This command configures a DefraDB node to actively push changes from a specified collection (e.g., 'Article') to a target peer. The target peer's information, obtained previously, is provided as a JSON string. ```bash defradb client p2p replicator set -c Article ``` -------------------------------- ### Describe Created Policy using Orbisd Client Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/orbis/getting-started/3-policy.md This command allows confirming the successful creation of a policy by retrieving its details from the `Zanzi` service using the returned policy ID. ```bash orbisd client policy describe ``` -------------------------------- ### Add Schema to DefraDB Node on Specific URL Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Similar to adding a schema, this command explicitly targets a DefraDB node running on a non-default URL to add a schema definition. This is crucial when managing multiple nodes or configuring a replicator target. ```bash defradb client schema add --url localhost:9182 ' type Article { content: String published: Boolean } ' ``` -------------------------------- ### Generate DefraDB Keyring Keys with Examples Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_keyring_generate.md Illustrates practical examples of using `defradb keyring generate`. Examples include generating default keys, skipping encryption or peer key generation, and specifying the system keyring backend. The `DEFRA_KEYRING_SECRET` environment variable or a secret file is required to unlock the keyring. ```Shell defradb keyring generate ``` ```Shell defradb keyring generate --no-encryption ``` ```Shell defradb keyring generate --no-peer-key ``` ```Shell defradb keyring generate --keyring-backend system ``` -------------------------------- ### Clone DefraDB Repository Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/deployment-guide.md Downloads the DefraDB source code to the local machine from its GitHub repository. ```Shell git clone https://github.com/sourcenetwork/defradb ``` -------------------------------- ### Pull Orbis Docker Image Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/orbis/getting-started/1-install.md This command pulls the pre-existing Orbis Docker image from the GitHub Container Registry. This is the quickest way to get a containerized version of Orbis without needing to build it locally. ```bash docker pull ghcr.io/sourcenetwork/orbis:0.2.3 ``` -------------------------------- ### defradb client collection describe Usage Examples Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_client_collection_describe.md Provides practical examples for using the `defradb client collection describe` command to view collection details. Examples include listing all collections, filtering by name, schema root ID, and version ID, demonstrating how to target specific collection information. ```Shell defradb client collection describe deffradb client collection describe --name User deffradb client collection describe --schema bae123 deffradb client collection describe --version bae123 ``` -------------------------------- ### Subscribe to Multiple Collection Updates via Pubsub Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md You can subscribe to updates for multiple collections simultaneously by providing a comma-separated list of their collection IDs. This command streamlines the process of setting up passive synchronization for several data sets. ```bash defradb client p2p collection add --url localhost:9182 ,, ``` -------------------------------- ### Allow Specific Origin for DefraDB CORS Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Configures DefraDB to allow Cross-Origin Resource Sharing (CORS) requests from a specific domain. Replace `https://yourdomain.com` with the actual allowed origin. ```bash defradb start --allowed-origins=https://yourdomain.com ``` -------------------------------- ### CLI: DefraDB Create Index Command Examples Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_client_index_create.md Illustrates practical usage of the `defradb client index create` command. Examples include creating a basic index, a named index, and a unique index with custom field ordering (ascending/descending) on DefraDB collections. ```CLI defradb client index create --collection Users --fields name ``` ```CLI defradb client index create --collection Users --fields name --name UsersByName ``` ```CLI defradb client index create --collection Users --fields name:ASC,age:DESC --unique ``` -------------------------------- ### CLI: defradb client schema describe usage examples Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_client_schema_describe.md Illustrates various command-line examples for using `defradb client schema describe` to view schema descriptions. Examples include viewing all schemas, and filtering by schema name, root ID, or version ID. ```CLI defradb client schema describe ``` ```CLI defradb client schema describe --name User ``` ```CLI defradb client schema describe --root bae123 ``` ```CLI defradb client schema describe --version bae123 ``` -------------------------------- ### defradb client view add Command Example Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_client_view_add.md Example of adding a new database view using the `defradb client view add` command. This demonstrates how to provide a GraphQL query, an SDL schema, and a JSON lens configuration as arguments. ```Shell defradb client view add 'Foo { name, ...}' 'type Foo { ... }' '{"lenses": [...' ``` -------------------------------- ### Start DefraDB Node with Default P2P Settings Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/peer-to-peer.md Starts a DefraDB node, initializing a libp2p host with a unique Peer ID and exposing HTTP and GraphQL APIs. This command shows the default addresses and Peer ID generated upon startup. ```bash $ defradb start ... Jan 2 10:15:49.124 INF cli Starting DefraDB Jan 2 10:15:49.161 INF net Created LibP2P host PeerId=12D3KooWEFCQ1iGMobsmNTPXb758kJkFc7XieQyGKpsuMxeDktz4 Address=[/ip4/127.0.0.1/tcp/9171] Jan 2 10:15:49.162 INF net Starting internal broadcaster for pubsub network Jan 2 10:15:49.163 INF node Providing HTTP API at http://127.0.0.1:9181 PlaygroundEnabled=false Jan 2 10:15:49.163 INF node Providing GraphQL endpoint at http://127.0.0.1:9181/api/v0/graphql ``` -------------------------------- ### Rust Implementation of DefraDB Lens Module Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/schema-migration.md Provides a Rust example demonstrating the implementation of a DefraDB Lens module, including the `alloc`, `set_param`, and `transform` functions, and how to interact with the `next` host function for data migration between schema versions. ```Rust #[link(wasm_import_module = "lens")] extern "C" { fn next() -> *mut u8; } #[derive(Deserialize, Clone)] pub struct Parameters { pub src: String, pub dst: String, } static PARAMETERS: RwLock> = RwLock::new(None); #[no_mangle] pub extern fn alloc(size: usize) -> *mut u8 { lens_sdk::alloc(size) } #[no_mangle] pub extern fn set_param(ptr: *mut u8) -> *mut u8 { match try_set_param(ptr) { Ok(_) => lens_sdk::nil_ptr(), Err(e) => lens_sdk::to_mem(lens_sdk::ERROR_TYPE_ID, &e.to_string().as_bytes()) } } fn try_set_param(ptr: *mut u8) -> Result<(), Box> { let parameter = lens_sdk::try_from_mem::(ptr)?; let mut dst = PARAMETERS.write()?; *dst = Some(parameter); Ok(()) } #[no_mangle] pub extern fn transform() -> *mut u8 { match try_transform() { Ok(o) => match o { Some(result_json) => lens_sdk::to_mem(lens_sdk::JSON_TYPE_ID, &result_json), None => lens_sdk::nil_ptr(), EndOfStream => lens_sdk::to_mem(lens_sdk::EOS_TYPE_ID, &[]), }, Err(e) => lens_sdk::to_mem(lens_sdk::ERROR_TYPE_ID, &e.to_string().as_bytes()) } } fn try_transform() -> Result>, Box> { let ptr = unsafe { next() }; let mut input = match lens_sdk::try_from_mem::>(ptr)? { Some(v) => v, ``` -------------------------------- ### Set Go Flags for Playground Build Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/deployment-guide.md Sets the GOFLAGS environment variable to include 'playground' build tags, instructing the Go compiler to embed the playground directly into the binary. ```Shell GOFLAGS=\"-tags=playground\" ``` -------------------------------- ### DefraDB Start Command Specific Options Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_start.md A comprehensive list of options specific to the `defradb start` command. These options control aspects like CORS, development features, transaction retries, encryption, P2P networking, TLS, and datastore configuration. ```APIDOC --allowed-origins stringArray List of origins to allow for CORS requests --development Enables a set of features that make development easier but should not be enabled in production: - allows purging of all persisted data - generates temporary node identity if keyring is disabled -h, --help help for start --max-txn-retries int Specify the maximum number of retries per transaction (default 5) --no-encryption Skip generating an encryption key. Encryption at rest will be disabled. WARNING: This cannot be undone. --no-p2p Disable the peer-to-peer network synchronization system --p2paddr strings Listen addresses for the p2p network (formatted as a libp2p MultiAddr) (default [/ip4/127.0.0.1/tcp/9171]) --peers stringArray List of peers to connect to --privkeypath string Path to the private key for tls --pubkeypath string Path to the public key for tls --store string Specify the datastore to use (supported: badger, memory) (default "badger") --valuelogfilesize int Specify the datastore value log file size (in bytes). In memory size will be 2*valuelogfilesize (default 1073741824) ``` -------------------------------- ### DefraDB Start Command Syntax Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_start.md The basic command-line syntax for initiating a DefraDB node. Flags are used to customize the node's behavior. ```Shell defradb start [flags] ``` -------------------------------- ### Simple Explain Request for Author Query Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/explain-systems.md This GraphQL example demonstrates a Simple Explain request applied to an `Author` query. The `@explain` directive is used to trigger the explanation mode, which returns only the syntactic and structural information of the Plan Graph, its nodes, and their attributes, without executing the query. ```graphql query @explain { Author { name age } } ``` -------------------------------- ### Compile DefraDB Playground Dependencies Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/deployment-guide.md Compiles the playground separately using Make, which produces a bundle file in a folder named 'dist'. ```Shell make deps:playground ``` -------------------------------- ### Build Orbisd from Source with Go Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/orbis/getting-started/1-install.md This snippet outlines the process of cloning the Orbis-go repository, checking out a specific version, compiling the `orbisd` binary using `make`, and then copying it to your Go binary path (`$GOBIN`). It also adds `$GOBIN` to your system's PATH. Requires Go toolchain version 1.21 or higher. ```bash cd $HOME git clone https://github.com/sourcenetwork/orbis-go cd orbis-go git checkout v0.2.3 make build cp ./build/orbisd $GOBIN/orbisd export PATH=$PATH:$GOBIN ``` -------------------------------- ### DefraDB Inherited Command Options Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_start.md Options inherited from parent DefraDB commands that apply globally. These settings manage keyring backend, logging format, level, output, and the root directory for persistent data. ```APIDOC --keyring-backend string Keyring backend to use. Options are file or system (default "file") --keyring-namespace string Service name to use when using the system backend (default "defradb") --keyring-path string Path to store encrypted keys when using the file backend (default "keys") --log-format string Log format to use. Options are text or json (default "text") --log-level string Log level to use. Options are debug, info, error, fatal (default "info") --log-output string Log output path. Options are stderr or stdout. (default "stderr") --log-overrides string Logger config overrides. Format ,=,...;,... --log-source Include source location in logs --log-stacktrace Include stacktrace in error and fatal logs --no-keyring Disable the keyring and generate ephemeral keys --no-log-color Disable colored log output --rootdir string Directory for persistent data (default: $HOME/.defradb) --secret-file string Path to the file containing secrets (default ".env") --source-hub-address string The SourceHub address authorized by the client to make SourceHub transactions on behalf of the actor --url string URL of HTTP endpoint to listen on or connect to (default "127.0.0.1:9181") ``` -------------------------------- ### Get Help for DefraDB Keyring Commands Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_keyring.md Command to display comprehensive help information and available options specifically for the `defradb keyring` subcommand. This is useful for discovering all functionalities and parameters. ```CLI defradb keyring --help ``` -------------------------------- ### Upload Policy to Zanzi Service using Orbisd Client Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/orbis/getting-started/3-policy.md This command uploads the defined `orbis-policy.yaml` file to the `Zanzi` authorization service. It returns a policy ID upon successful creation. ```shell orbisd client policy create -f orbis-policy.yaml ``` -------------------------------- ### defradb client view refresh examples Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_client_view_refresh.md Examples demonstrating how to refresh all views, or specific views by name, schema root ID, or version ID using the `defradb client view refresh` command. ```CLI defradb client view refresh deffradb client view refresh --name UserView deffradb client view refresh --schema bae123 deffradb client view refresh --version bae123 ``` -------------------------------- ### defradb client collection docIDs Command Syntax and Examples Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_client_collection_docIDs.md Displays the basic command-line syntax for listing document IDs. Examples include listing all docIDs for a 'User' collection and listing docIDs with a specific identity: `defradb client collection docIDs --name User` and `defradb client collection docIDs -i 028d53f37a19afb9a0dbc5b4be30c65731479ee8cfa0c9bc8f8bf198cc3c075f --name User`. ```shell defradb client collection docIDs [-i --identity] [flags] ``` -------------------------------- ### Build DefraDB Docker Image Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/deployment-guide.md Builds a Docker image for DefraDB using the specified containerfile located in the 'tools' directory. The period at the end sets the build context to the current directory. ```Shell docker build -t defra -f tools/defradb.containerfile . ``` -------------------------------- ### Configure DefraDB Schema Migration with Lens WASM Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/schema-migration.md This command-line example demonstrates how to set up a schema migration in DefraDB using the `defradb client schema migration set` command. It requires specifying the source and destination schema IDs, along with a JSON configuration string. The configuration defines the path to the compiled Lens WASM binary and the `src` and `dst` arguments for the migration logic. ```GraphQL defradb client schema migration set ' { "lenses": [ { "path": , "arguments": { "src": "emailAddress", "dst": "email" } } ] } ' ``` -------------------------------- ### Build Orbis Docker Image from Source Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/orbis/getting-started/1-install.md This snippet provides instructions to clone the Orbis-go repository, check out a specific version, and then build a custom Docker image from the source code. Replace `` with your desired image tag. ```bash cd $HOME git clone https://github.com/sourcenetwork/orbis-go cd orbis-go git checkout v0.2.3 docker build -t . ``` -------------------------------- ### Defradb CLI: Reverse Schema Migration Down Examples Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_client_schema_migration_down.md Demonstrates how to reverse a schema migration for a DefraDB collection using the `defradb client schema migration down` command, showing examples for providing documents directly, from a file, or via standard input. ```Shell defradb client schema migration down --collection 2 '[{"name": "Bob"}]' ``` ```Shell defradb client schema migration down --collection 2 -f documents.json ``` ```Shell cat documents.json | defradb client schema migration down --collection 2 - ``` -------------------------------- ### Specify Custom DefraDB Root Directory Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/deployment-guide.md Starts DefraDB while specifying a custom root directory for its configuration and data files, overriding the default location. ```Shell defradb --rootdir start ``` -------------------------------- ### Specify DefraDB In-Memory Storage Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/deployment-guide.md This flag is used with the `defradb start` command to enable in-memory storage, which is B-Tree based and ideal for testing. It does not interact with the file system. ```CLI --store memory ``` -------------------------------- ### Verify Account Balance with sourcehubd CLI Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/sourcehub/getting-started/2-account.md This command allows you to verify that your account exists and has been successfully loaded with tokens, typically from a network faucet. It queries the bank module to display the current balances for the specified wallet name or address. ```bash sourcehubd query bank balances ``` -------------------------------- ### Expected response for document creation Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Illustrates the typical JSON response received after successfully executing a `create_User` mutation. The response includes the `_docID`, which is the unique identifier for the newly created document. ```json { "data": { "create_User": [ { "_docID": "bae-91171025-ed21-50e3-b0dc-e31bccdfa1ab" } ] } } ``` -------------------------------- ### Initialize SourceHub Node Configuration Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/sourcehub/networks/testnet-1/join.md Commands to initialize the node with a unique moniker and the specified chain ID, download the genesis file for Testnet 1, and update key configurations in `app.toml` and `config.toml` for minimum gas prices, persistent peers, and timeout settings. ```bash # You must specify your own moniker, which is a label for your node sourcehubd init --chain-id sourcehub-testnet1 # Download the Genesis cd $HOME wget https://raw.githubusercontent.com/sourcenetwork/networks/testnet/testnet1/genesis.json mv genesis.json $HOME/.sourcehub/config/genesis.json # Update your configuration cd $HOME/.sourcehub/config sed -i 's/minimum-gas-prices = ""/minimum-gas-prices = "0.001uopen"/' app.toml sed -i 's/persistent_peers = ""/persistent_peers = "2da42ce7b32cb76c3a86db2eadfab8508ee41815@54.158.208.103:26656"/' config.toml # Update timeouts sed -i 's/timeout_propose = "3s"/timeout_propose = "500ms"/' config.toml sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/' config.toml ``` -------------------------------- ### Generate New Wallet Keypair with sourcehubd CLI Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/sourcehub/getting-started/2-account.md This command generates a new random private key and associates it with the provided wallet name. It outputs the public key, address, and a crucial mnemonic phrase that must be backed up securely to prevent loss of access. ```bash sourcehubd keys add ``` -------------------------------- ### View DefraDB Node Peer Information Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md This command allows you to retrieve the unique PeerID and connection details for your DefraDB node. The PeerID is derived from the node's public key and enables other nodes to connect to it. ```bash defradb client p2p info ``` -------------------------------- ### Import Existing Wallet Keypair from Mnemonic using sourcehubd CLI Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/sourcehub/getting-started/2-account.md Use this command with the `--recover` option to import an existing keypair into your wallet. After execution, the CLI will prompt you to input your existing mnemonic phrase, allowing you to restore access to your account. ```bash sourcehubd keys add --recover ``` -------------------------------- ### Query all user documents in DefraDB Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md This snippet demonstrates how to query all documents of the 'User' collection in DefraDB using the `defradb client query` command. It retrieves the `_docID`, `age`, `name`, and `points` fields for all users. ```bash defradb client query ' query { User { _docID age name points } } ' ``` -------------------------------- ### Configure sourcehubd CLI Client for Network Access Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/sourcehub/getting-started/2-account.md These commands update the `sourcehubd` CLI client's configuration to specify the correct blockchain network. You must set both the `chain-id` to identify the network and the `rpc-address` to connect to a specific RPC node for sending transactions and queries. ```bash sourcehubd config set client chain-id sourcehubd config set client node ``` -------------------------------- ### Allow Localhost Origin for DefraDB CORS Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Configures DefraDB to allow Cross-Origin Resource Sharing (CORS) requests from a local frontend application running on a specific port. Replace `3000` with your application's port. ```bash defradb start --allowed-origins=http://localhost:3000 ``` -------------------------------- ### GraphQL @index Directive: Unique Index Creation Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/secondary-index.md Example illustrating the creation of a unique index on a field using the `@index` directive with the `unique: true` parameter. This ensures that no two documents will have the same value for the 'name' field. ```gql type User { name: String @index(unique: true) } ``` -------------------------------- ### GraphQL @index Directive: Relationship Index for Uniqueness Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/secondary-index.md Example showing how to create a unique index on a relationship field. This ensures that a 'User' can only be associated with one 'Address' document, enforcing a one-to-one or one-to-many unique constraint on the relationship. ```gql type User { name: String age: Int address: Address @primary @index(unique: true) } type Address { user: User city: String street: String } ``` -------------------------------- ### GraphQL @index Directive: Field Level Usage Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/secondary-index.md Example demonstrating how to apply the `@index` directive directly to a field definition within a GraphQL type. This creates an index on the 'name' field of the 'User' type with a descending direction. ```gql type User { name: String @index(direction: DESC) } ``` -------------------------------- ### Configure and Create Source Network Validator Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/sourcehub/networks/testnet-1/join.md First, this snippet creates a JSON configuration file for the validator, specifying the public key, stake amount, moniker, and optional details like website, security contact, and commission rates. Subsequently, it submits a transaction to register the validator on the network using the generated configuration and the previously created keypair. ```bash # Create Validator info json config # Update the moniker, website, security, and details cd $HOME echo "{ \"pubkey\": $(sourcehubd comet show-validator), \"amount\": \"1stake\", \"moniker\": \"\", \"website\": \"validator's (optional) website\", \"security\": \"validator's (optional) security contact email\", \"details\": \"validator's (optional) details\", \"commission-rate\": \"0\", \"commission-max-rate\": \"0\", \"commission-max-change-rate\": \"0\", \"min-self-delegation\": \"1\" }" > validator.json # Create validator transaction sourcehubd tx staking create-validator validator.json --from= --fees 1000uopen -y ``` -------------------------------- ### CLI: DefraDB Create Index Command Syntax Reference Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_client_index_create.md Presents the complete command-line syntax for `defradb client index create`, outlining all possible arguments and flags. This snippet serves as a quick reference for constructing valid index creation commands. ```CLI defradb client index create -c --collection --fields [-n --name ] [--unique] [flags] ``` -------------------------------- ### Add Schema to DefraDB Node Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md This command adds a new schema definition to a DefraDB node, defining the structure for a new document type, such as 'Article'. Schemas are essential for structuring data within collections and are required before adding documents. ```bash defradb client schema add ' type Article { content: String published: Boolean } ' ``` -------------------------------- ### GraphQL @index Directive: Schema Level Usage Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/secondary-index.md Example showing how to apply the `@index` directive at the schema (type) level. This creates an index on the 'name' field of the 'User' type with the default ascending direction, specified via the 'includes' argument. ```gql type User @index(includes: {field: "name"}) { name: String age: Int } ``` -------------------------------- ### Subscribe to Single Collection Updates via Pubsub Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md This command allows a DefraDB node to subscribe to updates for a specific collection by using its unique collection ID as the pubsub topic. This enables passive synchronization of documents within that collection between connected nodes. ```bash defradb client p2p collection add --url localhost:9182 bafkreibpnvkvjqvg4skzlijka5xe63zeu74ivcjwd76q7yi65jdhwqhske ``` -------------------------------- ### Obtain latest document commits by DocID in DefraDB Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md This snippet queries the latest commit in the MerkleDAG for a specific document identified by its `docID`. It retrieves the commit's `cid`, `delta`, `height`, and linked commits, illustrating DefraDB's versioning capabilities. ```bash defradb client query ' query { latestCommits(docID: "bae-91171025-ed21-50e3-b0dc-e31bccdfa1ab") { cid delta height links { cid name } } } ' ``` -------------------------------- ### Filter user documents by points in DefraDB Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md This snippet shows how to filter 'User' documents based on the 'points' field. It retrieves users whose 'points' value is Greater Than or Equal to (`_ge`) 50, demonstrating basic filtering capabilities in DefraDB queries. ```bash defradb client query ' query { User(filter: {points: {_ge: 50}}) { _docID age name points } } ' ``` -------------------------------- ### GraphQL @index Directive: Composite Index Creation Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/secondary-index.md Example demonstrating how to create a composite index on multiple fields ('name' and 'age') using the `@index` directive's `includes` parameter. This allows for efficient queries across combined field values. ```gql type User @index(includes: [{field: "name"}, {field: "age"}]) { name: String age: Int } ``` -------------------------------- ### Build Orbis Binary from Source Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/orbis/networks/testnet/join.md This snippet outlines the process to compile the `orbisd` binary from its source code. It involves cloning the Git repository, checking out a specific version, building the project using `make`, and then copying the compiled binary to a location included in the system's PATH. A local Go toolchain (v1.21+) is required. ```bash cd $HOME git clone https://github.com/sourcenetwork/orbis-go cd orbis-go git checkout v0.2.3 make build cp ./build/orbisd $GOBIN/orbisd export PATH=$PATH:$GOBIN ``` -------------------------------- ### Add a new schema type to DefraDB Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md Defines and adds a new data schema, `User`, to DefraDB using a GraphQL-like syntax. This schema specifies fields like `name` (String), `age` (Int), `verified` (Boolean), and `points` (Float) for documents of this type. ```bash defradb client schema add ' type User { name: String age: Int verified: Boolean points: Float } ' ``` -------------------------------- ### Define SourceHub SystemD Service Unit Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/sourcehub/networks/testnet-1/join.md Provides the configuration for a SystemD service unit file (`sourcehubd.service`) to manage the SourceHub node. This unit ensures the service starts after network online, specifies the user and execution path, and sets resource limits. Users must customize the `` and `` placeholders. ```systemd [Unit] Description=SourceHub service After=network-online.target [Service] User= ExecStart=//sourcehubd start --x-crisis-skip-assert-invariants Restart=no LimitNOFILE=4096 [Install] WantedBy=multi-user.target ``` -------------------------------- ### Example JSON Document for Hierarchical Indexing Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/guides/secondary-index.md This JSON document illustrates a nested structure, where the 'iPhone' value is represented with its complete path ['user', 'device', 'model']. This path-aware representation is crucial for DefraDB's JSON indexing system, which traverses and indexes all leaf nodes. ```json { "user": { "device": { "model": "iPhone" } } } ``` -------------------------------- ### Obtain specific document commit by CID in DefraDB Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/getting-started.md This snippet demonstrates how to retrieve a specific document commit using its Content Identifier (`cid`). It returns the commit's `cid`, `delta`, `height`, and linked commits, similar to querying for the latest commit but targeting a specific version. ```bash defradb client query ' query { commits(cid: "bafybeifhtfs6vgu7cwbhkojneh7gghwwinh5xzmf7nqkqqdebw5rqino7u") { cid delta height links { cid name } } } ' ``` -------------------------------- ### defradb client p2p replicator set Command Syntax Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_client_p2p_replicator_set.md Provides the general command-line syntax for setting up a p2p replicator in Defradb, including optional collection specification, peer identifier, and flags. ```APIDOC Command: defradb client p2p replicator set Syntax: defradb client p2p replicator set [-c, --collection] [flags] ``` -------------------------------- ### defradb client collection get Specific Options Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_client_collection_get.md Lists the command-specific options for `defradb client collection get`, including flags for help and showing deleted documents. ```APIDOC -h, --help help for get --show-deleted Show deleted documents ``` -------------------------------- ### Get Public Document Fields with defradb CLI Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_client_collection_get.md Demonstrates how to retrieve document fields from a collection using the `defradb client collection get` command with the collection name and document ID. ```CLI defradb client collection get --name User bae-123 ``` -------------------------------- ### defradb keyring list Command Options Source: https://github.com/sourcenetwork/docs.source.network/blob/master/docs/defradb/references/cli/defradb_keyring_list.md Details the available command-line options for `defradb keyring list`, including both direct options and those inherited from parent commands, along with their types and descriptions. ```APIDOC Options: -h, --help: help for list Options inherited from parent commands: --keyring-backend string: Keyring backend to use. Options are file or system (default "file") --keyring-namespace string: Service name to use when using the system backend (default "defradb") --keyring-path string: Path to store encrypted keys when using the file backend (default "keys") --log-format string: Log format to use. Options are text or json (default "text") --log-level string: Log level to use. Options are debug, info, error, fatal (default "info") --log-output string: Log output path. Options are stderr or stdout. (default "stderr") --log-overrides string: Logger config overrides. Format ,=,...;,... --log-source: Include source location in logs --log-stacktrace: Include stacktrace in error and fatal logs --no-keyring: Disable the keyring and generate ephemeral keys --no-log-color: Disable colored log output --rootdir string: Directory for persistent data (default: $HOME/.defradb) --secret-file string: Path to the file containing secrets (default ".env") --source-hub-address string: The SourceHub address authorized by the client to make SourceHub transactions on behalf of the actor --url string: URL of HTTP endpoint to listen on or connect to (default "127.0.0.1:9181") ```