### Install Pop CLI from GitHub Repo Source: https://github.com/r0gue-io/pop-cli/blob/main/README.md Installs the Pop CLI tool directly from its GitHub repository using Cargo. This is useful for installing development versions or specific branches. ```shell cargo install --locked --git https://github.com/r0gue-io/pop-cli ``` -------------------------------- ### Install Pop CLI from GitHub Repo Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-cli/README.md Installs the Pop CLI tool directly from its GitHub repository using Cargo. This is useful for installing development versions or specific branches. ```shell cargo install --locked --git https://github.com/r0gue-io/pop-cli ``` -------------------------------- ### Test Smart Contract with Rust Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-contracts/README.md Provides examples for testing smart contracts, including unit and end-to-end (e2e) testing. It utilizes `test_project` for unit tests and `test_e2e_smart_contract` for e2e tests, requiring paths to the contract and the contracts node binary. ```rust use pop_common::test_project; use pop_contracts::test_e2e_smart_contract; use std::path::Path; let contract_path = Path::new("./"); let contracts_node_path = Path::new("./path-to-contracts-node-binary"); //unit testing test_project(Some(contract_path)); //e2e testing test_e2e_smart_contract(Some(contract_path), Some(contracts_node_path)); ``` -------------------------------- ### Install Pop CLI using Cargo Source: https://github.com/r0gue-io/pop-cli/blob/main/README.md Installs the Pop CLI tool using the Rust package manager, Cargo. Requires Rust 1.81 or later. This command ensures the latest stable version is installed. ```shell cargo install --force --locked pop-cli ``` -------------------------------- ### Install Pop CLI using Cargo Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-cli/README.md Installs the Pop CLI tool using the Rust package manager, Cargo. Requires Rust 1.81 or later. This command ensures the latest stable version is installed. ```shell cargo install --force --locked pop-cli ``` -------------------------------- ### Install CLI with Telemetry Disabled Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-telemetry/README.md Demonstrates how to install the pop-cli using Cargo, explicitly disabling default features and enabling specific ones to exclude telemetry collection. ```bash cargo install --locked --no-default-features --features contract,parachain --git "https://github.com/r0gue-io/pop-cli" ``` -------------------------------- ### Run Pop CLI Contract Integration Tests Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-cli/README.md Executes the integration tests specifically related to Smart Contracts within the Pop CLI project. These tests often involve more complex setups and interactions. ```shell cargo test --test contract ``` -------------------------------- ### Run Pop CLI Contract Integration Tests Source: https://github.com/r0gue-io/pop-cli/blob/main/README.md Executes the integration tests specifically related to Smart Contracts within the Pop CLI project. These tests often involve more complex setups and interactions. ```shell cargo test --test contract ``` -------------------------------- ### Deploy and Instantiate Smart Contract with Rust Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-contracts/README.md Details the process of deploying and instantiating a smart contract. It involves setting up deployment options, estimating gas via a dry run, and then executing the instantiation. Requires specifying contract path, constructor, arguments, value, and node URL. ```rust use pop_contracts::{ dry_run_gas_estimate_instantiate, instantiate_smart_contract, set_up_deployment, UpOpts}; use std::path::PathBuf; use tokio_test; use url::Url; tokio_test::block_on(async { let contract_path = PathBuf::from("./"); // prepare extrinsic for deployment let up_opts = UpOpts { path: Some(contract_path), constructor: "new".to_string(), args: ["false".to_string()].to_vec(), value: "1000".to_string(), gas_limit: None, proof_size: None, url: Url::parse("ws://localhost:9944").unwrap(), suri: "//Alice".to_string(), salt: None, }; let instantiate_exec = set_up_deployment(up_opts).await.unwrap(); // If you don't know the `gas_limit` and `proof_size`, you can perform a dry run to estimate the gas amount before instatianting the Smart Contract. let weight = dry_run_gas_estimate_instantiate(&instantiate_exec).await.unwrap(); let contract_address = instantiate_smart_contract(instantiate_exec, weight).await.unwrap(); }); ``` -------------------------------- ### Build Smart Contract with Rust Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-contracts/README.md Shows how to build an existing smart contract project. The `build_smart_contract` function supports building in release or debug mode and allows specifying verbosity levels. ```rust use pop_contracts::build_smart_contract; use std::path::Path; pub use contract_build::Verbosity; let contract_path = Path::new("./"); let build_release = true; // `true` for release mode, `false` for debug mode. let result = build_smart_contract(Some(&contract_path), build_release, Verbosity::Default); ``` -------------------------------- ### Build Pop CLI with All Features Source: https://github.com/r0gue-io/pop-cli/blob/main/README.md Builds the Pop CLI project with all available features enabled. This command compiles the entire project for full functionality, including all optional components. ```shell cargo build --all-features ``` -------------------------------- ### Build Pop CLI with All Features Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-cli/README.md Builds the Pop CLI project with all available features enabled. This command compiles the entire project for full functionality, including all optional components. ```shell cargo build --all-features ``` -------------------------------- ### Run Parachain with Zombienet Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-parachains/README.md Launches a parachain network using Zombienet, a tool for testing and running Substrate-based networks. This involves configuring Zombienet with cache locations, network configuration files, and optionally specifying versions for relay chains and system parachains. It also includes logic to download missing binaries. ```rust use pop_parachains::up::Zombienet; use std::path::Path; use tokio_test; tokio_test::block_on(async { let cache = Path::new("./cache"); // The cache location, used for caching binaries. let network_config = Path::new("network.toml").try_into().unwrap(); // The configuration file to be used to launch a network. let relay_chain_version = None; // Latest let relay_chain_runtime_version = None; // Latest let system_parachain_version = None; // Latest let system_parachain_runtime_version = None; // Latest let parachains = None; // The parachain(s) specified. let mut zombienet = Zombienet::new( &cache, network_config, relay_chain_version, relay_chain_runtime_version, system_parachain_version, system_parachain_runtime_version, parachains, ).await.unwrap(); zombienet.spawn().await; //To download the missing binaries before starting the network: let release = true; // Whether the binary should be built using the release profile. let status = {}; // Mechanism to observe status updates let verbose = false; // Whether verbose output is required let missing = zombienet.binaries(); for binary in missing { binary.source(release, &status, verbose).await; } }) ``` -------------------------------- ### Call Deployed Smart Contract with Rust Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-contracts/README.md Demonstrates how to call a deployed and instantiated smart contract. It covers both read-only calls (dry run) and state-changing calls, requiring contract address, message name, arguments, and node connection details. ```rust use pop_contracts::{call_smart_contract, dry_run_call, dry_run_gas_estimate_call, set_up_call,CallOpts}; use std::path::PathBuf; use tokio_test; use url::Url; tokio_test::block_on(async { // prepare extrinsic for call let contract_path = PathBuf::from("./"); let get_call_opts = CallOpts { path: Some(contract_path.clone()), contract: "5CLPm1CeUvJhZ8GCDZCR7nWZ2m3XXe4X5MtAQK69zEjut36A".to_string(), message: "get".to_string(), args: [].to_vec(), value: "1000".to_string(), gas_limit: None, proof_size: None, url: Url::parse("ws://localhost:9944").unwrap(), suri: "//Alice".to_string(), execute: false }; let get_call_exec = set_up_call(get_call_opts).await.unwrap(); // For operations that only require reading from the blockchain state, it does not require to submit an extrinsic. let call_dry_run_result = dry_run_call(&get_call_exec).await.unwrap(); // For operations that change a storage value, thus altering the blockchain state, requires to submit an extrinsic. let flip_call_opts = CallOpts { path: Some(contract_path), contract: "5CLPm1CeUvJhZ8GCDZCR7nWZ2m3XXe4X5MtAQK69zEjut36A".to_string(), message: "flip".to_string(), args: [].to_vec(), value: "1000".to_string(), gas_limit: None, proof_size: None, url: Url::parse("ws://localhost:9944").unwrap(), suri: "//Alice".to_string(), execute: true }; let flip_call_exec = set_up_call(flip_call_opts).await.unwrap(); let url = Url::parse("ws://localhost:9944").unwrap(); // If you don't know the `gas_limit` and `proof_size`, you can perform a dry run to estimate the gas amount before calling the Smart Contract. // let weight = dry_run_gas_estimate_call(&flip_call_exec).await.unwrap(); // let call_result = call_smart_contract(flip_call_exec, weight).await.unwrap(); }); ``` -------------------------------- ### Generate Smart Contract with Rust Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-contracts/README.md Demonstrates how to create a new smart contract using the `create_smart_contract` function from the `pop_contracts` crate. This function takes the contract name, path, and contract type as arguments. ```rust use pop_contracts::{create_smart_contract, Contract}; use std::path::Path; let contract_path = Path::new("./"); create_smart_contract("my_contract", &contract_path, &Contract::Standard); ``` -------------------------------- ### Create Pallet Template with Configuration Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-parachains/README.md Demonstrates how to create a pallet template using the `create_pallet_template` function. It includes defining a configuration object with various boolean and vector properties for the pallet. ```Rust let pallet_config = PalletConfig { pallet_advanced_mode: true, pallet_default_config: true, pallet_common_types: Vec::new(), pallet_storage: Vec::new(), pallet_genesis: false, pallet_custom_origin: false, }; create_pallet_template(PathBuf::from(path), pallet_config); ``` -------------------------------- ### Build Pop CLI for Smart Contracts Source: https://github.com/r0gue-io/pop-cli/blob/main/README.md Builds the Pop CLI project specifically for Smart Contract functionality, disabling default features and enabling only the 'contract' feature. This creates a build optimized for smart contract development tasks. ```shell cargo build --no-default-features --features contract ``` -------------------------------- ### Run Pop CLI Unit Tests Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-cli/README.md Executes only the unit tests for the Pop CLI project. This is a quick way to verify core logic without the overhead of integration tests. ```shell cargo test --lib ``` -------------------------------- ### Build Parachain Project Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-parachains/README.md Builds a parachain project from its source directory. This function compiles the parachain, optionally targeting a specific package and build profile (e.g., Release). It can also include specific Cargo features like 'runtime-benchmarks'. The output is the path to the compiled binary. ```rust use pop_common::Profile; use pop_parachains::build_parachain; use std::path::Path; let path = Path::new("./"); let package = None; // The optional package to be built. let binary_path = build_parachain(&path, package, &Profile::Release, None, vec![]).unwrap(); ``` ```rust let binary_path = build_parachain(&path, package, &Profile::Release, None, vec!["runtime-benchmarks"]).unwrap(); ``` -------------------------------- ### Run All Pop CLI Tests Source: https://github.com/r0gue-io/pop-cli/blob/main/README.md Executes all tests for the Pop CLI project, including both unit tests and all integration tests. This provides a comprehensive check of the tool's stability and functionality. ```shell cargo test ``` -------------------------------- ### Build Pop CLI for Smart Contracts Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-cli/README.md Builds the Pop CLI project specifically for Smart Contract functionality, disabling default features and enabling only the 'contract' feature. This creates a build optimized for smart contract development tasks. ```shell cargo build --no-default-features --features contract ``` -------------------------------- ### Run All Pop CLI Tests Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-cli/README.md Executes all tests for the Pop CLI project, including both unit tests and all integration tests. This provides a comprehensive check of the tool's stability and functionality. ```shell cargo test ``` -------------------------------- ### Generate New Parachain Template Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-parachains/README.md Instantiates a new parachain project from a template directory. This function requires the destination path, an optional Git tag version, and a configuration object specifying the parachain's symbol, decimals, and initial endowment. ```rust use pop_parachains::{instantiate_template_dir, Config, Parachain}; use std::path::Path; let destination_path = Path::new("./"); let tag_version = None; // Latest let config = Config { symbol: "UNIT".to_string(), decimals: 12, initial_endowment: "1u64 << 60".to_string() }; let tag = instantiate_template_dir(&Parachain::Standard, &destination_path, tag_version, config); ``` -------------------------------- ### Run Pop CLI Unit Tests Source: https://github.com/r0gue-io/pop-cli/blob/main/README.md Executes only the unit tests for the Pop CLI project. This is a quick way to verify core logic without the overhead of integration tests. ```shell cargo test --lib ``` -------------------------------- ### Upload Smart Contract Only with Rust Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-contracts/README.md Explains how to upload a smart contract's code to the blockchain without immediate instantiation. This involves preparing upload options, optionally performing a dry run for code hashing, and then executing the upload. ```rust use pop_contracts::{ dry_run_upload, set_up_upload, upload_smart_contract, UpOpts}; use std::path::PathBuf; use tokio_test; use url::Url; tokio_test::block_on(async { // prepare extrinsic for deployment let contract_path = PathBuf::from("./"); let up_opts = UpOpts { path: Some(contract_path), constructor: "new".to_string(), args: ["false".to_string()].to_vec(), value: "1000".to_string(), gas_limit: None, proof_size: None, url: Url::parse("ws://localhost:9944").unwrap(), suri: "//Alice".to_string(), salt: None, }; let upload_exec = set_up_upload(up_opts).await.unwrap(); // to perform only a dry-run let hash_code = dry_run_upload(&upload_exec).await.unwrap(); // to upload the smart contract let code_hash = upload_smart_contract(&upload_exec).await.unwrap(); }); ``` -------------------------------- ### Generate New Pallet Template Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-parachains/README.md Creates a new pallet project from a template. This function requires a destination path and a configuration object for the pallet, including author information, a description, and a flag indicating if the pallet is part of a larger workspace. ```rust use pop_parachains::{create_pallet_template, TemplatePalletConfig}; use std::path::PathBuf; let path = "./"; let pallet_config = TemplatePalletConfig { authors: "R0GUE".to_string(), description: "Template pallet".to_string(), pallet_in_workspace: false, }; ``` -------------------------------- ### Execute Smart Contract Call with Weight Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-contracts/README.md This Rust snippet demonstrates how to estimate the gas weight for a smart contract execution and then use that weight to perform the actual call. It uses `dry_run_gas_estimate_call` and `call_smart_contract` functions, handling potential errors with `.unwrap()`. ```Rust let weight_limit = dry_run_gas_estimate_call(&flip_call_exec).await.unwrap(); // Use this weight to execute the call. let call_result = call_smart_contract(flip_call_exec, weight_limit, &url).await.unwrap(); ``` -------------------------------- ### Build Pop CLI for Parachain Functionality Source: https://github.com/r0gue-io/pop-cli/blob/main/README.md Builds the Pop CLI project specifically for Parachain functionality, disabling default features and enabling only the 'parachain' feature. This creates a leaner build focused on specific capabilities. ```shell cargo build --no-default-features --features parachain ``` -------------------------------- ### Build Pop CLI for Parachain Functionality Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-cli/README.md Builds the Pop CLI project specifically for Parachain functionality, disabling default features and enabling only the 'parachain' feature. This creates a leaner build focused on specific capabilities. ```shell cargo build --no-default-features --features parachain ``` -------------------------------- ### Run Pop CLI Parachain Integration Tests Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-cli/README.md Executes the integration tests specifically related to Parachains within the Pop CLI project. These tests are designed to verify the tool's functionality in a parachain context. ```shell cargo test --test parachain ``` -------------------------------- ### Run Pop CLI Parachain Integration Tests Source: https://github.com/r0gue-io/pop-cli/blob/main/README.md Executes the integration tests specifically related to Parachains within the Pop CLI project. These tests are designed to verify the tool's functionality in a parachain context. ```shell cargo test --test parachain ``` -------------------------------- ### Generate Raw Chain Spec, WASM, and Genesis State Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-parachains/README.md Generates a raw chain specification file and exports necessary runtime artifacts. This process involves building the parachain, generating a plain chain spec, then creating a raw chain spec, and finally exporting the WebAssembly runtime and genesis state files. ```rust use pop_common::Profile; use pop_parachains::{build_parachain, export_wasm_file, generate_plain_chain_spec, generate_raw_chain_spec, generate_genesis_state_file}; use std::path::Path; let path = Path::new("./"); // Location of the parachain project. let package = None; // The optional package to be built. // The path to the node binary executable. let binary_path = build_parachain(&path, package, &Profile::Release, None, vec![]).unwrap();; // Generate a plain chain specification file of a parachain let plain_chain_spec_path = path.join("plain-parachain-chainspec.json"); generate_plain_chain_spec(&binary_path, &plain_chain_spec_path, true, "dev"); // Generate a raw chain specification file of a parachain let chain_spec = generate_raw_chain_spec(&binary_path, &plain_chain_spec_path, "raw-parachain-chainspec.json").unwrap(); // Export the WebAssembly runtime for the parachain. let wasm_file = export_wasm_file(&binary_path, &chain_spec, "para-2000-wasm").unwrap(); // Generate the parachain genesis state. let genesis_state_file = generate_genesis_state_file(&binary_path, &chain_spec, "para-2000-genesis-state").unwrap(); ``` -------------------------------- ### Generate and Customize Chain Specification Source: https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-parachains/README.md Generates a plain chain specification file for a parachain and allows for customization. After generating the base spec, you can modify parameters like Para ID, relay chain, chain type, and protocol ID before saving the updated specification to a file. ```rust use pop_common::Profile; use pop_parachains::{build_parachain, export_wasm_file, generate_plain_chain_spec, generate_raw_chain_spec, generate_genesis_state_file, ChainSpec}; use std::path::Path; let path = Path::new("./"); // Location of the parachain project. let package = None; // The optional package to be built. // The path to the node binary executable. let binary_path = build_parachain(&path, package, &Profile::Release, None, vec![]).unwrap();; // Generate a plain chain specification file of a parachain let plain_chain_spec_path = path.join("plain-parachain-chainspec.json"); generate_plain_chain_spec(&binary_path, &plain_chain_spec_path, true, "dev"); // Customize your chain specification let mut chain_spec = ChainSpec::from(&plain_chain_spec_path).unwrap(); chain_spec.replace_para_id(2002); chain_spec.replace_relay_chain("paseo-local"); chain_spec.replace_chain_type("Development"); chain_spec.replace_protocol_id("my-protocol"); // Writes the chain specification to a file chain_spec.to_file(&plain_chain_spec_path).unwrap(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.