Skip to content

The repository contains the code and configuration to run a platform for creating cryptocurrency stakes for arbitrary ERC20 tokens.

License

Notifications You must be signed in to change notification settings

SergeyIvanovDevelop/Crypto-Steam-Platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crypto Steam Platform

Crypto Steam Platform

Crypto Steam Platform · GitHub license Blockchain EVM Backend Frontend DB DevOps CICD LinkedIn Telegram

The repository contains the code and configuration to run a platform for creating cryptocurrency stakes for arbitrary ERC20 tokens.

The project is built on the Ethereum blockchain and also contains a server part.

💻 Getting Started

The project architecture is planned for its deployment through the CI/CD mechanism. In order for you to run a local copy of the entire project, follow these steps.

💿 Installation guide via CI/CD. LINUX only This is an image.

In order to be able to deploy a project, a number of prerequisites must be met:

  • You need to create a GitHub repository to which you will push code from this repository.

  • You need to create an account on DockerHub.

  • You must have a remote machine with docker, docker-compose and openssh-server installed. Ports on SSH must be opened (check this with iptables).

  • You must create secret variables in your github repository under GitHub Secrets: <YOUR_REPO_NAME> ➡️ Settings ➡️ Secrets ➡️ Actions ➡️ New repository secret. List of variables:

    • Remote machine IP address: HOST
    • The username of the remote machine, on whose behalf the interaction via ssh will take place on this machine: USERNAME
    • Password for this user: PASSWORD
    • Your DockerHub username: DOCKER_USERNAME
    • Your DockerHub username password: DOCKER_PASSWORD

Step 1

  1. Go to home directory and clone repository from github: cd ~ && git clone https://SergeyIvanovDevelop@github.com/SergeyIvanovDevelop/Crypto-Steam-Platform

Step 2

  1. Go to the directory of the downloaded repository: cd ~/Crypto-Steam-Platform

Step 3

  1. Change the origin value for the git repository to your GitHub repository: git remote set-url origin <YOUR_GITHUB_REPOSITORY>

Step 4

Create test blockchain network & deploy smart-contract

  1. Change to the solidity branch: git checkout solidity
  2. Push the code from this branch to your GitHub repository: git push -u origin solidity
  3. Change to the develop-solidity branch: git checkout develop-solidity
  4. Merging code from the solidity branch into the develop-solidity branch: git merge solidity
  5. Push the code from this branch to your GitHub repository: git push -u origin develop-solidity. This action should start the CI/CD process using GitHub Actions. As a result, a truffle develop test network will be deployed on your remote machine (via ssh). It is to it that you will need to connect using the MetaMask extension to interact with the platform.
    IMPORTANT: Make sure the contract is deployed by truffle successfull (see logs of deployment job in branch develop-solidity)!!!

Server Deployment

  1. Change to the backend branch: git checkout backend
  2. Push the code from this branch to your GitHub repository: git push -u origin backend
  3. Change to the develop-backend branch: git checkout develop-backend
  4. Merging code from the backend branch into the develop-backend branch: git merge backend
  5. Push the code from this branch to your GitHub repository: git push -u origin develop-backend. This action should start the CI/CD process using GitHub Actions. As a result, a server will be deployed on your remote machine (via ssh).

Deploying a site with nginx

  1. Change to the frontend branch: git checkout frontend
  2. Push the code from this branch to your GitHub repository: git push -u origin frontend
  3. Change to the develop-frontend branch: git checkout develop-frontend
  4. Merging code from the frontend branch into the develop-frontend branch: git merge frontend
  5. Push the code from this branch to your GitHub repository: git push -u origin develop-frontend. This action should start the CI/CD process using GitHub Actions. As a result, a nginx-server with site will be deployed on your remote machine (via ssh). To visit the site, you need to drive in the search bar of the browser (tested only in the Google Chrome browser Version 98.0.4758.102 (Official build), (64 bit)): http://<REMOTE_HOST_SSH_IP-ADDRESS>:8888/

Congratulations, you have successfully deployed the project!

✔️ Using project

In order to start using the project after its deployment, you must:

  1. Install MetaMask Wallet (Google Chrome browser extension).
  2. Import the wallet whose mnemonic is in the logs of deployment job in branch develop-solidity (where truffle created test network).
  3. Import CST (Crypto Steam Token) token for this account, which are automatically credited to this account when deploying a smart contract. The smart contract address of the CST token will also be in the logs of deployment job in branch develop-solidity (where truffle created test network). Should be 18 CST.
  4. Open a second GoogleChrome window and sign in with a different Google account than the one in the first window (or don't sign in to any account at all). Install MetaMask Wallet (Google Chrome browser extension).
  5. Create a new MetaMask wallet, import the CST token and transfer some amount of CST and ETH from the account in the first window to this account. For example, 5 units of each.
  6. Open the first window Google Chrome. Go to the site. To do this, in the browser search bar, type: http://<REMOTE_HOST_SSH_IP-ADDRESS>:8888/.
  7. Connect your MetaMask wallet to the site.
  8. Choose to manually enter the smart contract address of the token you want to pledge as collateral (in checkbox).
  9. Copy the address of the CST smart contract into the appropriate field.
  10. Enter the number of tokens you want to deposit as collateral for your stake.
  11. Click the 'Create' button. An opponent waiting window will appear.
  12. Open the second window Google Chrome. Go to the site. To do this, in the browser search bar, type: http://<REMOTE_HOST_SSH_IP-ADDRESS>:8888/.
  13. Connect your MetaMask wallet to the site.
  14. Choose to manually enter the smart contract address of the token you want to pledge as collateral (in checkbox).
  15. Copy the address of the CST smart contract into the appropriate field.
  16. Select from the list of pending games, the game created by the user of the first Google Chrome window.
  17. Enter the number of tokens equal to or greater than the number of tokens given as collateral for the bet by the first user.
  18. Click on the 'Join' button. A game window should appear, the essence of which is to guess the number guessed by the server. (The user will see the same in the first window). Whose number will be closer to the mysterious server - he won. If the network connection is interrupted during the game, then the funds frozen in the bet will be returned to the owners (even if there was only one player).
  19. After the end of the game (or disconnection), you can check the balances of users.
  20. Note: if the MetaMask wallet of the smart contract creator is connected to the site, then the administration panel will be available, with which you can start/stop this smart contract (using the pausable library).

🎬 Example using (GIF):

This animation demonstrates scenarios for using the Crypto Steam Platform.

animated

📑 Licence

Crypto Steam Platform is CC BY-NC-SA 3.0 licensed.