This page will provide a high level overview of the components and structure of the Dark Forest codebase.
This page is not official in any way and is subject to change as the game evolves.
-
Dark Forest has a lot of moving parts, but at its core, it is a blockchain-based application, commonly referred as a dapp.
A dapp has its backend code running on a decentralized peer-to-peer network (blockchain). Contrast this with an app where the backend code is running on centralized servers. A dapp can have frontend code and user interfaces written in any language (just like an app) to make calls to its backend
-
Dark Forest has a backend that contains the code that enforces the game constraints and rules. This code is divided into files called smart contracts, and it runs on a blockchain.
-
Players interact with these contracts via a frontend called the client. This client shows a visual representation of the state of the Dark Forest universe and serves as the connection between players and the smart contracts on the blockchain.
-
To create a round of Dark Forest, you need to do 3 things:
- (optional) Customize the smart contracts and client to your liking.
- Deploy the smart contracts to a blockchain.
- Deploy the client to a frontend hosting service like Netlify.
-
Let's dive deeper into each component of the code base.
- https://hardhat.org/getting-started/
- Hardhat is a development environment to compile, deploy, test, and debug your smart contracts.
- Hardhat simulates a local blockchain and deploys your contracts to this chain for development purposes.
- There are many cool features in Hardhat, including the ability to manually mine blocks, speed up blockchain time, and easily deploy contracts to public chains.
- Hardhat also lets you define custom tasks that relate to deploying and interacting with smart contracts.
For example, the
deploy:contracts
task deploys the Dark Forest contracts and thegame:createPlanets
task adds any custom planets to the universe. - Additionally, Hardhat has a variety of additional plugins that add features such as unit tests and types for smart contracts.
- When running tasks for the local network, use
hardhat:dev
. - When running tasks for xDai, use
hardhat:prod
.