Shipment Tracking Application is a REST APIs based application that lets you track shipping orders in a transparent and public way. It relais on EVM comptabile blockchain to leave traceability of the actions carried out on the order.
disclaimer: This code does merely have a teaching purpose.
You can add different networks by configuring hardhat.config. By default RSK testnet network is configured.
You can to create an .env
file or export the following enviarment variables:
.env
example:
#RSK TESTNET
CONTRACT_ADDRESS=0x0123456ABC
RSKTESTNET_RPC_URL='https://public-node.testnet.rsk.co'
PRIVATE_KEY='abcdef'
bash
example
export CONTRACT_ADDRESS=0x0123456ABC
export RSKTESTNET_RPC_URL='https://public-node.testnet.rsk.co'
export PRIVATE_KEY='abcdef'
You will get the contract address after the contract deployment.
To deploy to testnet:
npx hardhat run scripts/contract-deploy.js --network rsktestnet
You have to update the contract address environment variable with the address gotten.
npx hardhat run app/server.js --network rsktestnet
To run all (integration, unit and contract) the tests
npx hardhat test
curl --location --request POST 'http://localhost:3000/delivery' \
--header 'Content-Type: application/json' \
--data-raw ' { "code": "code1", "distributorId": "distributor 1", "receptorId": "receptor 1"}'
curl --location --request PUT 'http://localhost:3000/delivery/code1/deliver' \
--data-raw ''
curl --location --request PUT 'http://localhost:3000/delivery/code1/cancel' \
--data-raw ''
- REST APIs could be set to wait until n configurable confirmations. Default confirmation is 0.