This project contains a complete implementation of a track and trace solution with CIS-3 compliant sponsored transactions.
It has five primary components.
- A smart contract, located in
./smart-contract
- A frontend, located in
./frontend
- An indexer service, located in
./indexer
- A sponsored transaction service, located in
./sponsored-transaction-service
- This service is generic and compatible with any CIS-3 contracts.
- A server that hosts the frontend, located in
./indexer
Explanations for each component reside in README.md files inside their respective folder.
You can run the services and servers manually as explained in the READMEs or use the docker files in ./dockerfiles
.
However, the easiest option is to use docker-compose with the configuration file ./docker-compose.yml
.
For this to work, you should do the following:
- Deploy and initialize your version of the Track and Trace smart contract.
- Export your account keys from the Browser Wallet and generate a
./private-keys
folder to save the key file into it. - Set the following environment variables:
- Set the
TRACK_AND_TRACE_CONTRACT_ADDRESS
variable to the contract address of your contract instance. - Set the
TRACK_AND_TRACE_PRIVATE_KEY_FILE
variable to the path of your keys from step 2. - (Optional) Set the
TRACK_AND_TRACE_NETWORK
variable to the correct net (testnet/mainnet). Defaults to testnet. - (Optional) Set the
TRACK_AND_TRACE_NODE
to the gRPC endpoint of the node you want to use. Make sure it runs on the right net, i.e., testnet or mainnet. Defaults tohttps://grpc.testnet.concordium.com:20000
.
- Set the
- Run
docker-compose up
to build and start all the services.
e.g.
TRACK_AND_TRACE_CONTRACT_ADDRESS="<8901,0>" TRACK_AND_TRACE_PRIVATE_KEY_FILE="./private-keys/4SizPU2ipqQQza9Xa6fUkQBCDjyd1vTNUNDGbBeiRGpaJQc6qX.export" docker-compose up
You might need to run the above command twice, if the postgres database container is too slow to be set up for the first time and as a result the indexer or server throw an error because they are already trying to connect. Stopping the command and re-running the command will load the already setup postgres database container.
- Access the frontend at
http://localhost:8080
- The sponsored transaction service runs on port
8000
by default, and the postgres database runs on5432
. Both are configurable in the./docker-compose.yml
file.
- The sponsored transaction service runs on port
The indexer service saves the contract address used into the underlying PostgreSQL database.
If you want to use a different contract address than initially set up, you therefore need to delete the PostgreSQL database before running the docker-compose up
command again.
To do so, run the following command:
docker volume rm trackandtrace_postgres_data