Skip to content

zkcream/zkcream-api-server

Repository files navigation

zkCREAM api server

server test

This is the server that provides the backend API for zkCREAM.

Requirements

  • Nodejs ^14.x
  • yarn

Build docker

Requirements

  • docker
  • docker-compose
  1. Submobule update
git clone https://github.com/zkcream/zkcream-api-server.git && \
cd zkcream-api-server && \
git submodule update --init
  1. Build Docker
./scripts/buildDev.sh
./scripts/start.sh
  1. Then, you can http request to the endpoint, for example:
curl http://localhost:3000/foo

# response
// {msg:"foo"}

Build local

Requirements

  • ubuntu distro
  1. Submodule update
git clone https://github.com/zkcream/zkcream-api-server.git && \
cd zkcream-api-server && \
git submodule update --init
  1. Build zkcream
cd zkcream # inside of submodule
yarn
yarn build
  1. Build rapidsnark

    Install libraries based on rapidsnark's repo

sudo apt install build-essential
sudo apt-get install libgmp-dev
sudo apt-get install libsodium-dev
sudo apt-get install nasm
  1. Compile rapidsnark
cd rapidsnark
npm install
git submodule init
git submodule update
npx task createFieldSources
npx task buildProver
  1. Build and run api server
cd ../ # project's top directory
yarn
yarn build
yarn start:redis
yarn start # running at port 3000

Then access {HOST}:{PORT} http://localhost:3000 for a test environment. You can change the hostname and port number customising the config file.

Test

  1. You need to run ganache and ipfs node and finally migrate the contracts by typing
cd zkcream

# if you haven't built yet, run:
# yarn
# yarn build

yarn workspace @cream/contracts ganache
yarn start:ipfs
yarn workspace @cream/contracts migrate
  1. Then, after running redis, you can run test command as follows:
cd ../ # project's top directory 
yarn start:redis
yarn test