- 1. Getting Started
- 2. Instructions to build the Core Node
- 3. Instructions to run a Bazar validator Node
This project was bootstrapped with Lisk SDK, therefore, most of the transactions with the bazar blockchain can be applied using the Dashboard Plugin.
seller:order: This method sends a transaction to insert a new order from a seller. It contains some details of the product that the seller wants to publish to be available for purchase. files field is optional, it can be empty using "files:"[]. You can upload files to IPFS, and get the hash value using one of the services of Rest endpoints here. OrderId field uses a UUID unique identifier that is generated using random numbers. You can set random numbers to identify the orderId value or you can find an online UUID Generator. Keep in mind the oderId value will be requered for the nexts step.
{
"orderId":"00cb5bf9-948d-5c36-fafc-563f224ffc6f",
"productId":"28352",
"productName":"Avocado",
"productDescription":"Fruits | Lamb Hass",
"minQuantityToSell":"1",
"quantity":"100",
"price":"2",
"files":[
{
"filename":"blob",
"fileType":"IMAGE",
"fileCategory":"PRODUCT",
"hash":"Qmf7XLnDYgcPEsYoRe5NEzZSDx5vLivgJCLSpKV8Uynzk5"
}
]
seller:order (empty files):
{
"orderId":"00cb5bf9-948d-5c36-fafc-563f224ffc6f",
"productId":"28352",
"productName":"Avocado",
"productDescription":"Fruits | Lamb Hass",
"minQuantityToSell":"1",
"quantity":"100",
"price":"2",
"files":[]
}
seller:getLatestOrder: With this action, we can check the latest order transactions. It displays a list of transactions with the same value used as orderId. seller:getOrder: With this action, you can check the details of a seller's order.
{"id": "00cb5bf9-948d-5c36-fafc-563f224ffc6f"}
seller:files: Additional files can add to the seller's order. This method sends a transaction to register a single file. seller:getOrder action uses to check the new file added to the seller's order.
{
"orderId":"00cb5bf9-948d-5c36-fafc-563f224ffc6f",
"filename":"blob",
"fileType":"IMAGE",
"fileCategory":"Certificated",
"hash":"QmfJF5Dfi3h97S6jYncbf2r8BfYyLkTiqWVsxwcexV6ApT"
}
seller:transportStatus: This method sends a transaction to update the transportation status of the product. seller:getOrder action uses to check the update of location of product added to the seller's order.
{
"orderId":"00cb5bf9-948d-5c36-fafc-563f224ffc6f",
"origin":"Cartagena - Colombia",
"destiny":"Valencia - España",
"location":"Algeciras - España",
"date":1664988693,
"status":"In transit"
}
buyer:order: This method sends a transaction to register a purchase in the web platform. For the moment, the payment process uses BNB token on Binance Smarth Chain, and the receipt saves in bazar chain using this method. The transactionPayment field is the Binance Smarth Chain transaction, you can check additional details on BscScan.
{
"buyerOrderId":"7fee7c47-bc06-7288-087a-e87d4c7037ae",
"sellerOrderId":"56a75c2b-1da6-6d40-f0d3-c0341ae99827",
"status":"Accepted",
"token":" BNB",
"exchangeRate":"1 BNB : 287.00000000000006 USD",
"valueXKg":"2",
"quantity":"7",
"serviceFee":"0.7000000000000001",
"totalPayToken":"0.05121951219512195 BNB",
"totalPayInUSD":"14.7 USD",
"transacctionPayment":"0x4d0bc2b196475c5dad1053c04ba476482bffa451258f649914b320d15819e654",
"accountSeller":"0x17507dcE75457ddA6235885D0b4Fa382A5f0Afee",
"accountBuyer":"0xd8F6B47Cdf15e7708C9CBC3eFa6ACE31c5D85dbb",
"productId":"63929"
}
buyer:getLatestOrder: With this action, we can check the latest purchase order transactions. It displays a list of transactions with the same value used as orderId. buyer:getOrder: With this action, you can check the datils of a buyer's order.
{"id": "7fee7c47-bc06-7288-087a-e87d4c7037ae"}
The project contains two modules: seller and buyer. The seller module contains three assets:
The buyer module contains one asset:
The system has a plugin to expose the bazarrestapi API Rest for getting some details on-chain: forgers, connected peers, blocks and upload file to IPFS.
- Blocks
https://testnet-service.bazar.network/api/v1/blocks
- Forgers
https://testnet-service.bazar.network/api/v1/forgers
- Connected Peers
https://testnet-service.bazar.network/api/v1/peers/connected
- Account details
https://testnet-service.bazar.network/api/v1/account/93fdd84a20fc1c3bf87f13171b808bce780c1006
- Upload IPFS File POST Http method https://testnet.bazar.network/api/v1/files/new
The Body must be form-data with:
- key: file label
- value: the image object.
You will see a response like this:
{
"data": {
"hash": "QmdAD23BuaZxcx3ykksZEYmnKuVABC9d3SXweEj7UmuZQb",
"filename": "e6b2eda8b46531660d1d662067b2a2bf (1).jpg"
},
"errorMessage": null,
"errorCode": null
}
- Bazar-web. It contains the web application in ReactJS.
- Bazar-offchain. This component contains some logic to complete the registration of a user to be approved by an admin in the system as a buyer/seller.
- Bazar-auth. It contains the authentication and authorization component with Two Factor Authentication by SMS. It has some features for user management and uses a data model compatible with GDPR.
- Bazar-lambda-function. Monorepo with the component for Email notifications. Subscribe for updates and contact us used by the landing page.
- Bazar-landing-page. It contains the web site of Bazar Network.
- Bazar-smart-contract. It has the Solidity code used for Binance Smart Chain contract.
- Bazar-faucet. Custom project to send BZR token to accounts for testing.
- Bazar-validator-node. It contains the validator node configuration.
- Go to master branch.
- Clone the repository or download the zip file. You must see the bazar-core folder in your directory.
- If you are using a Linux environment execute the command to grant permissions on the files
chmod -R 777 bazar-core
- Run the command to install the dependencies:
npm install
- Start the node using
./bin/run start
- Go to Bazar-faucet
- Clone the repository or download the zip file. You must see the bazar-faucet folder in your directory.
- Edit the getClient.ts file to remove the SSL Websocket connection
wss://127.0.0.1:8080/ws to ws://127.0.0.1:8080/ws
- Edit App.tsx file to add a valid passphrase for testing purposes. You can use one of them accounts.json.
- Run the command to install the dependencies:
npm install
- Start the application using
npm start
You must have an account on the network to be registered in Bazar Testnet and identify the delegate transactions. There are some options to create an account. This guide will show you how to create a new one using the dashboard.
- Go to the Dashboard site at: testnet-dashboard.bazar.network
- Click on Generate new account button. A dialog shows up with the credentials of the account. Copy each value and store them in a safe location. Keep in mind the Base32 address will be required for the nexts step.
- Go to the Faucet site at: testnet-faucet.bazar.network
- Put the address in the input field and click on Receive 100 BZR. Token sends to account given.
Prerequisites: You must have installed Git and NodeJS 16.x and npm 8.1.0 or above.
- Go to validator Node Repository.
- Clone the repository or download the zip file. You must see the bazar-core folder in your directory.
- If you are using a Linux environment execute the command to grant permissions on the files
chmod -R 777 bazar-core
- Run the command to install the dependencies:
npm install
- Continue with the Register a Delegate section.
You must request to seed node on Bazar Testnet that a new node wants to be a delegate, and it will be validating and forging new blocks.
- Go to /config/default forlder and check on config.json file that the network.seedPeers has "3.136.64.215" on IP field.
- Check that forging.force is false from config.json file at /config/default folder.
- Start the node using
./bin/run start
- Wait until the synced process can finished and the current height has the same value of the seed node. You can check it using the dashboard: testnet-dashboard.bazar.network
- Replace the DELEGATE_NAME with a custom name using lowercase; keep in mind the passphrase of the account you have created before. It will be requested to sign the transaction. Create the delegate transaction using the command:
./bin/run transaction:create 5 0 1100000000 --asset='{"username":"DELEGATE_NAME"}'
Make sure to have enough Bazar Tokens for the transaction. If it is needed, you can use the Faucet of Bazar again. 6. Copy the transaction generated and send it to the seed node of the Bazar network. Replace the TRANSACTION label with the current one.
./bin/run transaction:send TRANSACTION
If everything is okay, you will see the message: Transaction with id: 'TRANSACTION_ID' received by node.
You can check the balance of the account and the value of dpos.delegate section for getting details of the Delegate activity on the seed node Remember that the forging.force field must set to false.
- Replace BINARY_ADDRESS with the value of the account generated before. Execute the next command:
./bin/run account:get BINARY_ADDRESS --pretty
It returns information about the account. Take a look at the depos.delegate field, which contains data you will use in the next steps. The section looks like this:
"dpos": {
"delegate": {
"username": "mango",
"pomHeights": [],
"consecutiveMissedBlocks": 0,
"lastForgedHeight": 65597,
"isBanned": false,
"totalVotesReceived": "0"
},
"sentVotes": [],
"unlocking": []
},
- Prepare data to enable the forging on your node. The next parameters are needed to set: address, encryptedPassphrase and hashOnion. It can be created using the next command:
./bin/run forging:config --count=4000 --output ./forging_config.json
The system will request the passpharse of the account created before and for a password to protect the passphrase. Save the password in a safe location. It will use in the next step. The forging_config.json file is generated in the root folder. Which contains the address, encryptedPassphrase and hashOnion values.
- Go to /config/default folder and check the forging.delegates section. Replace ADDRESS_TO_SET, ENCRYPRED_PASSPHRASE_TO_SET and HASH_ONION_ARRAY_TO_SET labels with the data from forging_config.json
"delegates": [
{
"address":"ADDRESS_TO_SET",
"encryptedPassphrase":"ENCRYPRED_PASSPHRASE_TO_SET",
"hashOnion":{ HASH_ONION_ARRAY_TO_SET }
]
- Stop the node.
- Remove the data of the node using the next command:
rm -r ~/.lisk/bazar-core
- Start the node using
./bin/run start
- Wait until the synced process can finished and the current height has the same value of the seed node. You can check it using the dashboard: testnet-dashboard.bazar.network and using
./bin/run node:info
- Replace BINARY_ADDRESS with the value of the account generated before. Execute the next command to start the forging:
./bin/run forging:enable BINARY_ADDRESS 0 0 0
The system returns a message like:
Updated forging status:
{"address":"ADDRESS","forging":true}
At this point, the validator node must be forging new blocks.
Note: The parameters sent at end of the command are regarding HEIGHT, MAXHEIGHTPREVIOUSLYFORGED and MAXHEIGHTPREVOTED. The first time when forging the values are 0 0 0. You need to check the status of the node for getting the latest value to start the forging in another opportunity:
./bin/run forging:status
You can learn more in the bazar.network.