Blockapps BA

BlockApps logo

Supply Chain Demo App 一个供应链区块链应用

This demo app uses STRATO blockchain platform and Smart Contracts to demonstrate a solution for a basic 2-party Supply Chain Workflow. 两方供应链的工作流,下面是 供应链区块链APP 的流程图和时序。应用程序栈和产品架构。

Alt text
Alt text
Alt text
Alt text

Pre Requisites 准备好 STRATO,DAPP上车

Node v7.2 or more recent.

This application requires a BlockApps STRATO node. Follow the instruction in the STRATO getting started guide to install a local instance.

安装完成 Docker,并启动 Strato-Single 实例:

aojiedeMacBook-Air:~ Aojax$ cd WorkSpace/strato-getting-started/
aojiedeMacBook-Air:strato-getting-started Aojax$ ls
README.md		STRATO-Architecture.png	VERSION			genesis-block.json	strato.sh
SMD.png			STRATOArc.png		docker-compose.yml	ssl
aojiedeMacBook-Air:strato-getting-started Aojax$ ./strato.sh --single
____  __           __   ___
/ __ )/ /___  _____/ /__/   |  ____  ____  _____
/ __  / / __ \/ ___/ //_/ /| | / __ \/ __ \/ ___/
/ /_/ / / /_/ / /__/ ,< / ___ |/ /_/ / /_/ (__  )
/_____/_/\____/\___/_/|_/_/  |_/ .___/ .___/____/
/_/   /_/
*** Common Config ***
NODE_HOST: localhost
ssl: false
sslCertFileType: crt
NODE_NAME: localhost
BLOC_URL: http://localhost/bloc/v2.2
BLOC_DOC_URL: http://localhost/docs/?url=/bloc/v2.2/swagger.json
STRATO_URL: http://localhost/strato-api/eth/v1.2
STRATO_DOC_URL: http://localhost/docs/?url=/strato-api/eth/v1.2/swagger.json
CIRRUS_URL: http://localhost/cirrus/search
APEX_URL: http://localhost/apex-api
authBasic: true
uiPassword: not set (using default)
STRATO_GS_MODE: 0
SMD_MODE: enterprise
EXT_STORAGE_S3_BUCKET: not set
EXT_STORAGE_S3_ACCESS_KEY_ID: not set
EXT_STORAGE_S3_SECRET_ACCESS_KEY: not set
Running single node with lazy mining
*** Single-node Config ***
SINGLE_MODE: true
*** Genesis Block ***
Genesis block is not set (using default)
Using the existing docker-compose.yml (to download the most recent stable version - remove the file and restart the script)
WARNING: The addBootnodes variable is not set. Defaulting to a blank string.
WARNING: The backupblocks variable is not set. Defaulting to a blank string.
WARNING: The blockTime variable is not set. Defaulting to a blank string.
WARNING: The bootnode variable is not set. Defaulting to a blank string.
WARNING: The debugFail variable is not set. Defaulting to a blank string.
WARNING: The evmDebugMode variable is not set. Defaulting to a blank string.
WARNING: The evmTraceMode variable is not set. Defaulting to a blank string.
WARNING: The genesis variable is not set. Defaulting to a blank string.
WARNING: The genesisBlock variable is not set. Defaulting to a blank string.
WARNING: The lazyBlocks variable is not set. Defaulting to a blank string.
WARNING: The minBlockDifficulty variable is not set. Defaulting to a blank string.
WARNING: The miningAlgorithm variable is not set. Defaulting to a blank string.
WARNING: The miningThreads variable is not set. Defaulting to a blank string.
WARNING: The networkID variable is not set. Defaulting to a blank string.
WARNING: The numMinPeers variable is not set. Defaulting to a blank string.
WARNING: The redisBDBNumber variable is not set. Defaulting to a blank string.
WARNING: The statsEnable variable is not set. Defaulting to a blank string.
WARNING: The statsFlush variable is not set. Defaulting to a blank string.
WARNING: The statsHost variable is not set. Defaulting to a blank string.
WARNING: The statsPort variable is not set. Defaulting to a blank string.
WARNING: The statsPrefix variable is not set. Defaulting to a blank string.
WARNING: The statsSuffix variable is not set. Defaulting to a blank string.
WARNING: The useSyncMode variable is not set. Defaulting to a blank string.
WARNING: The azureAD variable is not set. Defaulting to a blank string.
WARNING: The azureADClientID variable is not set. Defaulting to a blank string.
WARNING: The azureADClientSecret variable is not set. Defaulting to a blank string.
WARNING: The azureADTenantID variable is not set. Defaulting to a blank string.
WARNING: The loglevel variable is not set. Defaulting to a blank string.
WARNING: The stateDiffTopic variable is not set. Defaulting to a blank string.
1strato_docs_1 is up-to-date
strato_zookeeper_1 is up-to-date
strato_redis_1 is up-to-date
strato_kafka_1 is up-to-date
strato_postgres_1 is up-to-date
strato_strato_1 is up-to-date
strato_postgrest_1 is up-to-date
strato_bloc_1 is up-to-date
strato_cirrus_1 is up-to-date
strato_apex_1 is up-to-date
strato_dappstore_1 is up-to-date
strato_smd_1 is up-to-date
strato_nginx_1 is up-to-date
aojiedeMacBook-Air:strato-getting-started Aojax$

Please make sure that ports 80, 3030, and 3031 are publicly accessible. If you are using AWS or Azure, you may need to allow traffic on these ports by changing the firewall settings.

Once you have a functional STRATO node, you can clone this project and deploy it to the STRATO instance using the instructions below. 搞定 STRATO,下面就一步一步来发布这个供应链区块链应用。

Dependencies 安装依赖环境

Install the dependencies

npm i

Install the UI dependencies

cd ui
npm i

Deploying on Localhost 本地发布

Uploading the smart contracts required by the demo app

一、上传一个 DAPP智能合约

If you are deploying using STRATO on localhost (Linux and Mac users only): Run the following from the project root:

npm run deploy

Windows users should run

set "SERVER=localhost" & npm run deploy-windows

Launching the API

From the project root (Linux, Mac and Windows):

npm run start

Launching the UI

If you are deploying using STRATO on localhost (Linux and Mac users only):

cd ui
npm run start

On Windows:

cd ui
set "REACT_APP_API_URL=http://localhost:3031" & set "PORT=3030" & npm run start-windows

Deploying on a remote server (AWS, azure etc)

Create a config file under ./server/config with the naming convention <server-name>.config.yaml. You are free to chose the server-name.

Copy the content of localhost.config.yaml to a new file <server-name>.config.yaml, located at ./server/config. ou are free to chose the server-name.

Configfure <server-name>.config.yaml as follows:

apiDebug: true
password: '1234'
timeout: 600000
libPath: ./server/lib
contractsPath: ./contracts/
dataFilename: ./server/dapp/dapp.presets.yaml
deployFilename: ./server/config/<server-name>.deploy.yaml
# WARNING - extra strict syntax
# DO NOT change the nodes order
# node 0 is the default url for all single node api calls
nodes:
- id: 0
explorerUrl: 'http://<your-ip-or-dns>:9000'
stratoUrl: 'http://<your-ip-or-dns>/strato-api'
blocUrl: 'http://<your-ip-or-dns>/bloc/v2.2'
searchUrl: 'http://<your-ip-or-dns>/cirrus'

Replace with the name of your config file (excluding config.yaml) and <your-ip-or-dns> with the IP or the DNS name of your remote server and then run the following from the project root:

SERVER=<server-name> npm run deploy

On Windows:

set "SERVER=<local-ip>" & npm run deploy-windows

Here can be 127.0.0.1 or the local network ip.

Launching the API

From the project root (Linux, Mac and Windows):

npm run start

Launching the UI

cd ui
API_URL="http://<your-ip-or-dns>:3031" npm run start

On Windows:

cd ui
set "REACT_APP_API_URL=http://<your-ip-or-dns>:3031" & set "PORT=3030" & npm run start-windows

where <your-ip-or-dns> is the IP or DNS name of the remote machine. Eg:

set "REACT_APP_API_URL=http://some.remote.cloudapp.provider.com:3031" & set "PORT=3030" & npm run start-windows

Testing 测试一下,R U OK?

npm run test

On Windows:

set "SERVER=<server-name>" & npm run test-windows

Using the BlockApps Supply Chain Demo App 来吧,供应链 DAPP 走起!

Open the app in the browser.

By default, application is running at http://localhost:3030/

Logins for the app

The app comes pre loaded with four different users: Buyer1Buyer2Supplier1Supplier2. All these users have the same password: 1234.

Bidding Flow Guide

  • Buyer Logs in 
  • Buyer creates a project for suppliers to bid on 
  • Supplier logs in 
  • Supplier makes a bid on the earlier project 
  • Buyer accepts early supplier bid 

Note: After the buyer accepts the bid, 20 dollars from the buyer’s account is taken and held by the smart contract but is still not disbursed until the product is accepted

  • Supplier marks that the product is shipped 
  • Buyer confirms that they recieved the product 

0 条评论

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注