Search code examples
blockchainsubstratepolkadot

how to use --staging flag in substrate framework?


If i try to run the below command:

./target/release/node-template build-spec --chain staging > stagingSpec.json

facing the below error:

Error: Input("Error opening spec file: No such file or directory (os error 2)")

Is there any guide how to use that staging flag??


Solution

  • Here are the rustdocs for the command, and it's implementation in the node template - this looks for specific from your chain specification file based on what you pass that is configued. In the template at the time of writing, the template only has dev and "everything else" mode:

        fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
            Ok(match id {
                "dev" => Box::new(chain_spec::development_config()?),
                "" | "local" => Box::new(chain_spec::local_testnet_config()?),
                path =>
                    Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
            })
        }
    

    Thus you would need to specify another in/node/src/chainspec.rs and configure the /node/src/commnad.rs to use the correct one when called.