-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Welcome to the WiVTech Supply Chain wiki!
This project is a blockchain-based supply chain application build with Substrate. The goal is to provide people with capability to track and trace unique assets: where they originated and what path they made.
Our application consists of two parts: blockchain node (based on Substrate framework) and web application.
We also have created experimental smart contract in Ink!
language.
This piece of Software can be used per se (with our or with alternative UI): by installing it in closed network or, potentially, by integrating it as "parachain" into Polkadot. Being based on Substrate, the Node component inherits all benefits of it, including possibility of fork-less upgrade. In case of becoming a parachain, the node will also gain all security benefits of Polkadot's "relay chain".
Back-end application logic is implemented as a "pallet" and not as a smart-contract — pallets are better integrated with Substrate, statically compiled, have the lowest performance overhead and, in general, are more secure. Even given that there exist ERC-721 token implementations for Substrate, smart contracts seems to be a sub-optimal solution with complicated initialization, overflexibility and poor performance comparing to Substrate runtime modules a.k.a. pallets.
Update (Feb 3, 2021): Now, we have experimental smart contract too. Scroll to the very end of this page to find steps for it.
Application itself is a NodeJS server connected to the blockchain node, MySQL database and IPFS node. By connecting to the server over HTTPS a user can interact with the blockchain node over convenient web-based user interface. IPFS node is used for storing miscellaneous non-critical resources. Since, all data putted on-chain is replicated to all connected nodes, such resources would clutter on-chain space. That's why we store them in IPFS and record their hashes on-chain in order to be able verify them afterwards. Important data like users, their roles and assets themselves is stored on-chain.
For the first milestone, we have implemented the following features.
Users management:
- sign-up procedure: choice of handle, password and "buyer" or "supplier" role
- seed phrases which can be generated automatically or chosen manually in case of account recovery
- sign-in by password
Assets management:
- creation of unique assets, which have a serial number, description and some image attached
- assets approval by users with Admin role
- assets transfer between users
Please, watch this screen-cast to understand better what is implemented and how to use it yourself:
Let's prepare our environment. Install make
, docker
and docker-compose
.
Refer to this instruction about how to get docker
with docker-compose
:
For using Makefile
, install make
with this command:
brew install make
Recent versions of Fedora have podman
in default repositories, which is drop-in replacement of it.
dnf install -y podman make
curl -o /usr/local/bin/podman-compose https://raw.githubusercontent.com/containers/podman-compose/devel/podman_compose.py
chmod +x /usr/local/bin/podman-compose
ln -s /usr/bin/podman-compose -s /usr/local/bin/docker-compose
ln -s /usr/bin/podman -s /usr/local/bin/docker
Now, clone the application repo:
git clone https://github.com/wivtech/supply-chain
cd supply-chain
Here, you can find stack.yml
file which can be used with docker-compose
, docker stack
or podman-compose
.
You don't need to use it yourself, but you can tweak it in case you want to create custom set-up.
All necessary operations are provided by Makefile
.
First, initialize storage folders and pull Docker images:
make init
This automatically downloads the blockchain node, MySQL database and IPFS node.
Then, run Docker containers with:
make start
After 5-10 seconds the web application will be ready.
Open localhost:3000
in your favourite browser :)
One limitation of current implementation is that in order to submit any transaction, a user has to sign-up as one of "well-known" accounts. So, during sign-up procedure use one of those seed phrases to have some active balance in your new account:
username: Alice
secret seed: bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice
account: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
username: Bob
secret seed: bottom drive obey lake curtain smoke basket hold race lonely fit walk//Bob
account: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty
username: Admin
secret seed: bottom drive obey lake curtain smoke basket hold race lonely fit walk//Admin
account: 5Cqg641taJcn16MmReBn3uA8ENfY6ZgXKqwEaLACRXC9Z8Ne
Admin is the super user enabled to approve the new assets.
An asset cannot be transferred when the approval is pending.
Update (Feb 3, 2021): If you want to try our experimental smart contract, then follow these steps:
- Clone the smart contract repo and compile it:
git clone https://github.com/wivtech/supply-chain-ink
cd supply-chain-ink
cargo install cargo-contract --vers 0.8.0 --force --locked
cargo +nightly contract build
After this, you'll find wivsupplychain.wasm
, metadata.json
and combined wivsupplychain.contract
in target
subfolder.
- Start Canvas node with Docker:
docker run -p 9944:9944 wivt/supply-chain:canvas
Open this User Interface in a browser (Chrome is preferred):
https://ipfs.io/ipns/dotapps.io/
Switch to Local Node
in the side panel under Development
section.
- Click-through
Developer / Contracts / Upload WASM
.
Deploy wivsupplychain.contract
and you will have access to all the functions available.
- (Extra) You also may have success with this UI:
https://paritytech.github.io/canvas-ui/#/upload