API and events server for Influence. A grand strategy game set in an asteroid belt and built on Ethereum.
This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0). Commercial use is not permitted without a separate license from Unstoppable Games, Inc.
For the avoidance of doubt: The licensor considers non-commercial use under this license to include deployments or uses that collect funds solely to recover the reasonable costs of operating, maintaining, or administering the software, provided that such use is not primarily intended for or directed toward commercial advantage or monetary compensation, and that no profit is distributed to operators, contributors, or participants.
- Run scripts in
./bin/starknet-setupto migrate asteroids and crewmates to components from snapshots. - Manually retrieve and process events since the snapshot block time on L1.
- Setup retriever for Starknet.
- Re-process all events.
- Install local node modules:
npm install - Ensure a local mongo instance is running.
- (Optionally) ensure a local redis instance is running.
- Initialize your .env file:
echo "API_SERVER=1 CLIENT_URL=http://localhost:3000 BRIDGE_CLIENT_URL=http://localhost:4000 IMAGES_SERVER=1 IMAGES_SERVER_URL=http://localhost:3001 MONGO_URL=mongodb://localhost:27017/influence #REDIS_URL= CLOUDINARY_URL= NODE_ENV=development JWT_SECRET= ETHEREUM_PROVIDER=http://localhost:8545 CONTRACT_PLANETS= CONTRACT_ASTEROID_TOKEN= CONTRACT_ASTEROID_FEATURES= CONTRACT_ASTEROID_SCANS= CONTRACT_ASTEROID_SALE= CONTRACT_ASTEROID_NAMES= CONTRACT_ARVAD_CREW_SALE= CONTRACT_CREW_TOKEN= CONTRACT_CREW_FEATURES= CONTRACT_CREW_NAMES= " > .env - Adjust or fill in any missing .env variables as needed.
REDIS_URLis optional (uncomment if you plan to use it)JWT_SECRETcan be any random stringCONTRACT_*values should have been output at the end of theseedChainscript in the contracts project.
- Install Homebrew (https://brew.sh)
- Install mongodb tools
brew tap mongodb/brewthenbrew install [email protected] - Download this seed data for local development. Unzip the file into
./data - Run
NODE_ENV=development node ./bin/seedData.jsto reset the database - Run
npm run watchto start
- Run
node ./bin/updateCommon.jswith thefindStuckmethod uncommented. - Grab the output and run
truffle test ./test/lib/TestScansMock.jswith the output in the contracts project. - Get the output from #2 and run
node ./bin/updateCommon.jswithupdateDatabasemethod uncommented.
Notes:
- The
compose.yamlfile in the project expects a Docker network namedwebfor the communication across containers (your mongo, redis, elasticsearch instances, optionally your own Starknet node if you want to run indexers, or a reverse-proxy e.g. Caddy). To create it, rundocker network create web. - By default the application port (3001) is only exposed to the
webDocker network and not to the host machine. Un-comment the port configuration incompose.yamlif needed. - The
compose.yamlfile includes the setup of redis and elasticsearch instances; the mongo instance is not included; initialisation of these services is not included.
- Download source
- Initialize your
.envfile -NODE_ENV=development - Build the image from local source:
docker compose build - Start the container(s) (sample commands in compose.yaml)
- Download source
- Build the image from local source:
docker compose -f compose.unittest.yaml build - Start the container to run unit tests:
docker compose -f compose.unittest.yaml up
- Download
compose.yamlandcompose.prerelease.yamlorcompose.prod.yaml - Initialize your
.envfile with theNODE_ENVthat matches the image (prereleaseorproduction); if running against a local redis instance, setREDIS_DISABLE_TLS=1 - Start the containers (sample commands in
compose.prerelease.yamlandcompose.prod.yaml)
- influence-server: the main service, running the API server
- four indexer services under the
--indexer flag, designed to run continuously and index the onchain events- influence-indexer
- influence-ethereumeventretriever
- influence-starkneteventretriever
- influence-eventprocessor
- two auditor services designed to be scheduled in order to catch missed events or reorgs
- influence-eventauditor - run every 10 minutes
- influence-agreementauditor - run daily
- influence-tools: a maintenance image running
nodeas the default command used to execute initialization scripts