Skip to content

Latest commit

 

History

History
66 lines (42 loc) · 1.49 KB

README.md

File metadata and controls

66 lines (42 loc) · 1.49 KB

Blockchain API

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a Hardhat Ignition module that deploys that contract.

Try running some of the following tasks:

Requirements

  • Docker
  • Node

Demo Setup

All the components have been dockerized, so to run the API for testing purposes you simply have to run the following command:

docker-compose up -d

This will start all the required services, and you will be able to observe the logs of the test-runner container to validate the unit test results.

The API will also be operational on localhost:3000, and you can access the swagger documentation on localhost:3000/docs and experiment with the endpoints.

Cleaning up

Simply run docker compose down --volumes to clear all the containers associated with the service.

Development Setup

  1. Install the packages needed to run the API
npm install
  1. Setup and run the blockchain node
  docker-compose up -d blockchain-node
  1. Deploy the smart contract onto the blockchain node

    npx hardhat run scripts/deploy.js --network localhost

    The response should be:

    GUEDHS deployed to: "<CONTRACT_ADDRESS>"
  2. Rename the sample.env file to .env

    4.1. Copy the contract address to the .env file and paste to the CONTRACT_ADDRESS variable

  3. Run the WebAPI locally

  npm start
  1. Access the swagger
localhost:3000/docs