For Governance, please refer to this branch governance_integration.
For Substrate Storage Migration, please refer to this branch Substrate Storage Migration.
This substrate based pallet scans 2D barcode of the product which is tied to a Blockchain system.
Follow the Rust setup instructions before using the included Makefile to build the Node Template.
This project uses a Makefile to document helpful commands and make it easier to execute
them. Get started by running these make
targets:
make init
- Run the init script to configure the Rust toolchain for WebAssembly compilation.make run
- Build and launch this project in development mode.
The init script and Makefile both specify the version of the Rust nightly compiler that this project depends on.
The make run
command will perform an initial build. Use the following command to build the node
without launching it:
make build
Once the project has been built, the following command can be used to explore all parameters and subcommands:
./target/release/node-template -h
The make 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
If you want to avoid creating empty blocks and allow only when a new transaction arrives, you can run below command.
./target/release/node-template --dev --instant-sealing
-
After executing
make run
, Use this link to open the Polkadot JS Apps UIhttps://polkadot.js.org/apps/#/explorer?rpc=ws://127.0.0.1:9944
-
Open Extrinsics and fill following inputs to add the product in storage.
-
Click on
Submit Transaction
and product will be added. -
Open terminal and execute below curl request to verify barcode
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "barcode_scanner_is_valid_barcode", "params": ["0x5c0d1176a568c1f92944340dbfed9e9c530ebca703c85910e7164cb7d1c9e47b"]}' http://localhost:9933/
You will get below response.
{"jsonrpc":"2.0","result":true,"id":1}
Run make benchmark
command and execute
./target/release/node-template benchmark --chain=dev --execution=wasm --wasm-execution=compiled --pallet=pallet_barcode_scanner --extrinsic='*' --steps=50 --repeat=20 --heap-pages=4096 --template=./frame-weight-template.hbs --output=./pallets/barcode-scanner/src/weights.rs