1659138900
A fresh FRAME-based Substrate node, ready for h@cking 🚀
Follow the steps below to get started with the Node Template, or get it up and running right from your browser in just a few clicks using the Substrate Playground 🛠️
Install nix and optionally direnv and lorri for a fully plug and play experience for setting up the development environment. To get all the correct dependencies activate direnv direnv allow
and lorri lorri shell
.
First, complete the basic Rust setup instructions.
Use Rust’s native cargo
command to build and launch the template node:
cargo run --release -- --dev --tmp
The cargo run
command will perform an initial build. Use the following command to build the node without launching it:
cargo build --release
Once the project has been built, the following command can be used to explore all parameters and subcommands:
./target/release/node-template -h
The provided cargo run
command will launch a temporary node and its state will be discarded after you terminate the process. After the project has been built, there are other ways to launch the node.
This command will start the single-node development chain with persistent state:
./target/release/node-template --dev
Purge the development chain’s state:
./target/release/node-template purge-chain --dev
Start the development chain with detailed logging:
RUST_BACKTRACE=1 ./target/release/node-template -ldebug --dev
Once the node template is running locally, you can connect it with Polkadot-JS Apps front-end to interact with your chain. Click here connecting the Apps to your local node template.
If you want to see the multi-node consensus algorithm in action, refer to our Start a Private Network tutorial.
A Substrate project such as this consists of a number of components that are spread across a few directories.
A blockchain node is an application that allows users to participate in a blockchain network. Substrate-based blockchain nodes expose a number of capabilities:
libp2p
networking stack to allow the nodes in the network to communicate with one another.There are several files in the node
directory – take special note of the following:
chain_spec.rs
: A chain specification is a source code file that defines a Substrate chain’s initial (genesis) state. Chain specifications are useful for development and testing, and critical when architecting the launch of a production chain. Take note of the development_config
and testnet_genesis
functions, which are used to define the genesis state for the local development chain configuration. These functions identify some well-known accounts and use them to configure the blockchain’s initial state.service.rs
: This file defines the node implementation. Take note of the libraries that this file imports and the names of the functions it invokes. In particular, there are references to consensus-related topics, such as the longest chain rule, the Aura block authoring mechanism and the GRANDPA finality gadget.After the node has been built, refer to the embedded documentation to learn more about the capabilities and configuration parameters that it exposes:
./target/release/node-template --help
In Substrate, the terms “runtime” and “state transition function” are analogous – they refer to the core logic of the blockchain that is responsible for validating blocks and executing the state changes they define. The Substrate project in this repository uses the FRAME framework to construct a blockchain runtime. FRAME allows runtime developers to declare domain-specific logic in modules called “pallets”. At the heart of FRAME is a helpful macro language that makes it easy to create pallets and flexibly compose them to create blockchains that can address a variety of needs.
Review the FRAME runtime implementation included in this template and note the following:
impl $PALLET_NAME::Config for Runtime
.construct_runtime!
macro, which is part of the core FRAME Support library.The runtime in this project is constructed using many FRAME pallets that ship with the core Substrate repository and a template pallet that is defined in the pallets
directory.
A FRAME pallet is compromised of a number of blockchain primitives:
Config
configuration interface is used to define the types and parameters upon which a FRAME pallet depends.First, install Docker and Docker Compose.
Then run the following command to start a single node development chain.
./scripts/docker_run.sh
This command will firstly compile your code, and then start a local development network. You can also replace the default command (cargo build --release && ./target/release/node-template --dev --ws-external
) by appending your own. A few useful ones are as follow.
# Run Substrate node without re-compiling
./scripts/docker_run.sh ./target/release/node-template --dev --ws-external
# Purge the local dev chain
./scripts/docker_run.sh ./target/release/node-template purge-chain --dev
# Check whether the code is compilable
./scripts/docker_run.sh cargo check
Author: vjgaur
Source code: https://github.com/vjgaur/proof-of-work-in-substrate
License:
1644426120
A fresh FRAME-based Substrate node, ready for hacking :rocket:
Follow the steps below to get started with the Node Template, or get it up and running right from your browser in just a few clicks using the Substrate Playground :hammer_and_wrench:
Install nix and optionally direnv and lorri for a fully plug and play experience for setting up the development environment. To get all the correct dependencies activate direnv direnv allow
and lorri lorri shell
.
First, complete the basic Rust setup instructions.
Use Rust's native cargo
command to build and launch the template node:
cargo run --release -- --dev --tmp
The cargo run
command will perform an initial build. Use the following command to build the node without launching it:
cargo build --release
Once the project has been built, the following command can be used to explore all parameters and subcommands:
./target/release/node-template -h
The provided cargo run
command will launch a temporary node and its state will be discarded after you terminate the process. After the project has been built, there are other ways to launch the node.
This command will start the single-node development chain with non-persistent state:
./target/release/node-template --dev
Purge the development chain's state:
./target/release/node-template purge-chain --dev
Start the development chain with detailed logging:
RUST_BACKTRACE=1 ./target/release/node-template -ldebug --dev
Development chain means that the state of our chain will be in a tmp folder while the nodes are running. Also, alice account will be authority and sudo account as declared in the genesis state. At the same time the following accounts will be pre-funded:
- Alice
- Bob
- Alice//stash
- Bob//stash
In case of being interested in maintaining the chain' state between runs a base path must be added so the db can be stored in the provided folder instead of a temporal one. We could use this folder to store different chain databases, as a different folder will be created per different chain that is ran. The following commands shows how to use a newly created folder as our db base path.
// Create a folder to use as the db base path
$ mkdir my-chain-state
// Use of that folder to store the chain state
$ ./target/release/node-template --dev --base-path ./my-chain-state/
// Check the folder structure created inside the base path after running the chain
$ ls ./my-chain-state
chains
$ ls ./my-chain-state/chains/
dev
$ ls ./my-chain-state/chains/dev
db keystore network
Once the node template is running locally, you can connect it with Polkadot-JS Apps front-end to interact with your chain. Click here connecting the Apps to your local node template.
If you want to see the multi-node consensus algorithm in action, refer to our Start a Private Network tutorial.
A Substrate project such as this consists of a number of components that are spread across a few directories.
A blockchain node is an application that allows users to participate in a blockchain network. Substrate-based blockchain nodes expose a number of capabilities:
libp2p
networking stack to allow the nodes in the network to communicate with one another.There are several files in the node
directory - take special note of the following:
chain_spec.rs
: A chain specification is a source code file that defines a Substrate chain's initial (genesis) state. Chain specifications are useful for development and testing, and critical when architecting the launch of a production chain. Take note of the development_config
and testnet_genesis
functions, which are used to define the genesis state for the local development chain configuration. These functions identify some well-known accounts and use them to configure the blockchain's initial state.service.rs
: This file defines the node implementation. Take note of the libraries that this file imports and the names of the functions it invokes. In particular, there are references to consensus-related topics, such as the longest chain rule, the Aura block authoring mechanism and the GRANDPA finality gadget.After the node has been built, refer to the embedded documentation to learn more about the capabilities and configuration parameters that it exposes:
./target/release/node-template --help
In Substrate, the terms "runtime" and "state transition function" are analogous - they refer to the core logic of the blockchain that is responsible for validating blocks and executing the state changes they define. The Substrate project in this repository uses the FRAME framework to construct a blockchain runtime. FRAME allows runtime developers to declare domain-specific logic in modules called "pallets". At the heart of FRAME is a helpful macro language that makes it easy to create pallets and flexibly compose them to create blockchains that can address a variety of needs.
Review the FRAME runtime implementation included in this template and note the following:
impl $PALLET_NAME::Config for Runtime
.construct_runtime!
macro, which is part of the core FRAME Support library.The runtime in this project is constructed using many FRAME pallets that ship with the core Substrate repository and a template pallet that is defined in the pallets
directory.
A FRAME pallet is compromised of a number of blockchain primitives:
Config
configuration interface is used to define the types and parameters upon which a FRAME pallet depends.First, install Docker and Docker Compose.
Then run the following command to start a single node development chain.
./scripts/docker_run.sh
This command will firstly compile your code, and then start a local development network. You can also replace the default command (cargo build --release && ./target/release/node-template --dev --ws-external
) by appending your own. A few useful ones are as follow.
# Run Substrate node without re-compiling
./scripts/docker_run.sh ./target/release/node-template --dev --ws-external
# Purge the local dev chain
./scripts/docker_run.sh ./target/release/node-template purge-chain --dev
# Check whether the code is compilable
./scripts/docker_run.sh cargo check
Download Details:
Author: substrate-developer-hub
Source Code: https://github.com/substrate-developer-hub/substrate-node-template
License: Unlicense License
#rust #blockchain #substrate #docker #node #hacking #developer
1643176207
Serde
*Serde is a framework for serializing and deserializing Rust data structures efficiently and generically.*
You may be looking for:
#[derive(Serialize, Deserialize)]
Click to show Cargo.toml. Run this code in the playground.
[dependencies]
# The core APIs, including the Serialize and Deserialize traits. Always
# required when using Serde. The "derive" feature is only required when
# using #[derive(Serialize, Deserialize)] to make Serde work with structs
# and enums defined in your crate.
serde = { version = "1.0", features = ["derive"] }
# Each data format lives in its own crate; the sample code below uses JSON
# but you may be using a different one.
serde_json = "1.0"
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
struct Point {
x: i32,
y: i32,
}
fn main() {
let point = Point { x: 1, y: 2 };
// Convert the Point to a JSON string.
let serialized = serde_json::to_string(&point).unwrap();
// Prints serialized = {"x":1,"y":2}
println!("serialized = {}", serialized);
// Convert the JSON string back to a Point.
let deserialized: Point = serde_json::from_str(&serialized).unwrap();
// Prints deserialized = Point { x: 1, y: 2 }
println!("deserialized = {:?}", deserialized);
}
Serde is one of the most widely used Rust libraries so any place that Rustaceans congregate will be able to help you out. For chat, consider trying the #rust-questions or #rust-beginners channels of the unofficial community Discord (invite: https://discord.gg/rust-lang-community), the #rust-usage or #beginners channels of the official Rust Project Discord (invite: https://discord.gg/rust-lang), or the #general stream in Zulip. For asynchronous, consider the [rust] tag on StackOverflow, the /r/rust subreddit which has a pinned weekly easy questions post, or the Rust Discourse forum. It's acceptable to file a support issue in this repo but they tend not to get as many eyes as any of the above and may get closed without a response after some time.
Download Details:
Author: serde-rs
Source Code: https://github.com/serde-rs/serde
License: View license
1659138900
A fresh FRAME-based Substrate node, ready for h@cking 🚀
Follow the steps below to get started with the Node Template, or get it up and running right from your browser in just a few clicks using the Substrate Playground 🛠️
Install nix and optionally direnv and lorri for a fully plug and play experience for setting up the development environment. To get all the correct dependencies activate direnv direnv allow
and lorri lorri shell
.
First, complete the basic Rust setup instructions.
Use Rust’s native cargo
command to build and launch the template node:
cargo run --release -- --dev --tmp
The cargo run
command will perform an initial build. Use the following command to build the node without launching it:
cargo build --release
Once the project has been built, the following command can be used to explore all parameters and subcommands:
./target/release/node-template -h
The provided cargo run
command will launch a temporary node and its state will be discarded after you terminate the process. After the project has been built, there are other ways to launch the node.
This command will start the single-node development chain with persistent state:
./target/release/node-template --dev
Purge the development chain’s state:
./target/release/node-template purge-chain --dev
Start the development chain with detailed logging:
RUST_BACKTRACE=1 ./target/release/node-template -ldebug --dev
Once the node template is running locally, you can connect it with Polkadot-JS Apps front-end to interact with your chain. Click here connecting the Apps to your local node template.
If you want to see the multi-node consensus algorithm in action, refer to our Start a Private Network tutorial.
A Substrate project such as this consists of a number of components that are spread across a few directories.
A blockchain node is an application that allows users to participate in a blockchain network. Substrate-based blockchain nodes expose a number of capabilities:
libp2p
networking stack to allow the nodes in the network to communicate with one another.There are several files in the node
directory – take special note of the following:
chain_spec.rs
: A chain specification is a source code file that defines a Substrate chain’s initial (genesis) state. Chain specifications are useful for development and testing, and critical when architecting the launch of a production chain. Take note of the development_config
and testnet_genesis
functions, which are used to define the genesis state for the local development chain configuration. These functions identify some well-known accounts and use them to configure the blockchain’s initial state.service.rs
: This file defines the node implementation. Take note of the libraries that this file imports and the names of the functions it invokes. In particular, there are references to consensus-related topics, such as the longest chain rule, the Aura block authoring mechanism and the GRANDPA finality gadget.After the node has been built, refer to the embedded documentation to learn more about the capabilities and configuration parameters that it exposes:
./target/release/node-template --help
In Substrate, the terms “runtime” and “state transition function” are analogous – they refer to the core logic of the blockchain that is responsible for validating blocks and executing the state changes they define. The Substrate project in this repository uses the FRAME framework to construct a blockchain runtime. FRAME allows runtime developers to declare domain-specific logic in modules called “pallets”. At the heart of FRAME is a helpful macro language that makes it easy to create pallets and flexibly compose them to create blockchains that can address a variety of needs.
Review the FRAME runtime implementation included in this template and note the following:
impl $PALLET_NAME::Config for Runtime
.construct_runtime!
macro, which is part of the core FRAME Support library.The runtime in this project is constructed using many FRAME pallets that ship with the core Substrate repository and a template pallet that is defined in the pallets
directory.
A FRAME pallet is compromised of a number of blockchain primitives:
Config
configuration interface is used to define the types and parameters upon which a FRAME pallet depends.First, install Docker and Docker Compose.
Then run the following command to start a single node development chain.
./scripts/docker_run.sh
This command will firstly compile your code, and then start a local development network. You can also replace the default command (cargo build --release && ./target/release/node-template --dev --ws-external
) by appending your own. A few useful ones are as follow.
# Run Substrate node without re-compiling
./scripts/docker_run.sh ./target/release/node-template --dev --ws-external
# Purge the local dev chain
./scripts/docker_run.sh ./target/release/node-template purge-chain --dev
# Check whether the code is compilable
./scripts/docker_run.sh cargo check
Author: vjgaur
Source code: https://github.com/vjgaur/proof-of-work-in-substrate
License:
1605177692
In this video, I will be showing you what a templating engine is by showing you 3 different templating engines the ones we will look at it is pug, mustache and ejs.
#node js tutorial #node js templating #node js templates #nodejs for beginners #mustache templating #mustache.js
1644247749
a p2p solution for hosting files with Dat protocol (...more)
datdot code is currently located in pallets/datdot
.
the template node uses instant-seal consensus, and a minimal runtime.
to build the datdot dev runtime, run:
cargo build -p datdot-runtime
to build the test node, run:
cargo build -p datdot-node
add the --release
flag to either of those commands to create a release build - debug and release builds will be located in ./target/release
or ./target/debug
respectively.
If you are having trouble building with the commands above, you can try this recipe (shared by @erangell)
git clone https://github.com/playproject-io/datdot-substrate.git
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs/ -sSf | sh
rustup toolchain install nightly-2020-08-14
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
rustup default nightly-2020-08-14
rustup update
rustup update nightly-2020-08-14
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-08-14
cargo +nightly-2020-08-14 check
cargo build -p datdot-node --release
You can aggregate the custom types of any pallets in datdot-node/pallets
by running: node datdot-node/runtime/aggregate_types.js
This will produce a types.json
file.
Performing this requires each pallet defined in aggregate_types.js
have their own types.json file premade.
currently, executing ./target/release/datdot-node --dev
(or ./target/debug/datdot-node --dev
if you didn't use a --release
flag) runs a dev node. You can interact with this node by using the Polkadot.js Apps UI - selecting "local node" as your endpoint in the settings page should connect you to your node; however, until you specify the additional types in the developer tab, all functionality of the Apps UI will remain disabled.
Optionally, additionally running with --execution Native
(case sensitive) will allow you to see more verbose logging from parts of the runtime using native::info!(...)
calls.
NOTE: due to the nature of the instantseal consensus used in this node implementation, there is no concept of finality.
Datdot is built using Substrate - Original Readme:
Substrate
Substrate is a next-generation framework for blockchain innovation.
Simply go to substrate.dev and follow the getting started instructions.
Please follow the contributions guidelines as outlined in docs/CONTRIBUTING.adoc
. In all communications and contributions, this project follows the Contributor Covenant Code of Conduct.
Download Details:
Author: playproject-io
Source Code: https://github.com/playproject-io/datdot-node-rust
License: GPL-3.0 License