基于区块链的毕业设计Ethereum Roullette – 以太坊轮盘赌

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计Ethereum Roullette – 以太坊轮盘赌 是一篇很好的国外资料

Ethereum Roullette

Dependencies

  • Solidity
  • Remix IDE
  • Javascript
  • Node.js (Express, Mysql2, Sequelize)
  • Truffle
  • Metamask

Metamask

  • Add Metamask as an extension to the browser
  • Create and account
  • Connect account with Remix
  • Link tokens using: Find a more detailed instructions here

Instructions and Configuration

Server (Back End)

  • Once cloned the repository, ‘server/app/config/db.config.js’ should look like this:
  module.exports = {     HOST: "sql5.freemysqlhosting.net",     USER: "sql5408535",     PASSWORD: "CNFq9khMkW",     DB: "sql5408535",     dialect: "mysql",     pool: {       max: 5,       min: 0,       acquire: 30000,       idle: 10000     }   }; 

this will run the server on a hosted server.

  • navigate to ‘client’ directory cd client In the project directory, you can run the backend server:

Project setup

npm install Runs package.json to install all the dependecies.

Run

node server.js 

Runs the app in the development mode. Open http://localhost:8080 to view it in the browser. The page will show you the message {“message”:”Welcome to Rou application by Lette.”}

Deploy contract

Locally

if you have truffle install, follow these steps.

  • Make sure you have truffle installed, follow these steos
  • on the src folder,
  • install dependecies:
npm install 
  • Compile the contract:
  truffle compile 
  • Migrate the contract:
  truffle migrate 
  • Navegate to: ‘client/src/contracts’
  • Open Roulette.json
  • Copy the ABI and Contract Address
  • Navigate to ‘client/src/config.js’
  • Paste respectivelly

REMIX

DEPLOY CONTRACT ON REMIX

  • Copy contract ‘contracts/Roulette.sol’
  • Open Remix
  • Paste and Deploy contract on Remix, follow these steps
  • Copy ABI and Contract Address
  • Navigate to ‘client/src/config.js’ on project
  • Paste respectivelly

Bot (Back End)

Steps to deploy the bot

  • Make sure you are in a new terminal window
  • Navigate to ‘bot’ directory From source folder run:

cd bot

  • On the directory, run: npm install
  • Create .env file and copy contents of .env.example file into it
  • Configure .env variables
  • RPC_URL is the network where the contract was deployed
  • PRIVATE_KEY is the private key from your Metamask Account for the casino (should be different from the player’s account)
  • ACCOUNT is the account from metamask the cassino will use
  • On ‘bot/index.js’ update abi and contract address (copy these from ‘client/src/config.js’)
  • Run command npm run start

How does the bot work?

  1. Casino will deploy the contract
  2. A contract address will be deployed (we can copy that address directly into the front end). The contract address will always be the same. This is the address needed for players to join the game.
  3. After deploying contract the Casino must deposit money using the deposit money function (recommended amount is 1 ether)
  4. Contract can deposit any amount of money to contract at any time

After the contract is deployed:

  1. Commitment Hash is called
  2. Casino deposits 1 ether
  3. Player will join contract by switching account addresses
  4. Player will deposit their bet amount
  5. Player can now place their bet
  • Player can remove or see their current bets on the table

Testing (Back End)

Steps for testing the contract;

  1. Begin by installing truffle and a text editor, we used Atom.
  2. After installing both systems, the user would have to import roullette.sol into the contracts folder and roulettetest.js into the test folder.
  3. To begin the testing process, one must run the testrpc client from the terminal, which starts the server to connect the contract to the testing file.
  4. Open a new terminal window and run truffle develop to deploy the contract and then use the command test to see all the available tests written in the javascript file.
  5. There should be 6 available test files to view.

Client (Front End)

  • Make sure you are in a new terminal window
  • Navigate to ‘client’ directory From source folder run:

cd client

In the project directory, you can run the front-end server:

Project setup

npm install 

Runs package.json to install all the dependecies.

Run

npm start 

Note: The user should be in the directory dapp/client to run npm start

Runs the app in the development mode.
Open http://localhost:8081 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.


依赖项

元掩码

  • Truffle
  • 元掩码
  • 添加元掩码作为浏览器的扩展
  • 创建和帐户
  • 使用混音连接帐户
  • 链接令牌使用:克隆存储库后,在此处查找更详细的说明

指令和配置

  • ,“server/app/config/db.config.js”应该是这样的:
  • 导航到项目目录中的“client”目录cd client,您可以运行后端服务器:
  • 确保安装了truffle,请遵循src文件夹中的以下步骤,
  • 安装依赖项:

服务器(后端)

项目设置

  • 编译契约:
  module.exports = {     HOST: "sql5.freemysqlhosting.net",     USER: "sql5408535",     PASSWORD: "CNFq9khMkW",     DB: "sql5408535",     dialect: "mysql",     pool: {       max: 5,       min: 0,       acquire: 30000,       idle: 10000     }   }; 

这将在托管服务器上运行服务器

  • 将契约迁移:

运行

npm install运行package.json来安装所有依赖项

部署契约

node server.js 

以开发模式运行应用程序。打开http://localhost:8080在浏览器中查看。页面将向您显示消息{“message”:“Welcome to Rou application by Lette.”}

本地

混合

如果您安装了truffle,请按照以下步骤操作

  • Navegate to:’client/src/contracts’
  • 打开Roulette.json
  • 复制ABI和契约地址
npm install 
  • 导航到’client/src/config.js’
  truffle compile 
  • 分别粘贴
  truffle migrate 
  • 复制契约’contracts/Roulette.sol’
  • 打开混音
  • 在混音上粘贴和部署合同,按照以下步骤操作
  • 复制ABI和合同地址
  • 导航到project上的’client/src/config.js’

Bot(后端)

在混音中部署契约

  • 分别粘贴
  • 确保您处于新的终端窗口
  • 从目录上的源文件夹run:
  • 导航到’bot’目录,运行:npm install创建.env文件并将.env.example文件的内容复制到其中配置.env变量ACCOUNT是cassino将在’bot/index.js’更新abi和合同地址(从’client/src/config.js’复制这些内容)上使用的元掩码中的帐户。
  • 运行命令npm Run start
  • 赌场将部署合同

部署Bot的步骤工作

测试(后端)

客户端(前端)

项目设置

运行,续集)
  • Truffle
  • 元掩码
  • 添加元掩码作为浏览器的扩展
  • 创建和帐户
  • 使用混音连接帐户
  • 链接令牌使用:克隆存储库后,在此处查找更详细的说明
  • ,“server/app/config/db.config.js”应该是这样的:
  • 导航到项目目录中的“client”目录cd client,您可以运行后端服务器:
  • 确保安装了truffle,请遵循src文件夹中的以下步骤,
  • 安装依赖项:
  • 编译契约:
  • 将契约迁移:
  • Navegate to:’client/src/contracts’
  • 打开Roulette.json
  • 复制ABI和契约地址
  • 导航到’client/src/config.js’
  • 分别粘贴
  • 复制契约’contracts/Roulette.sol’
  • 打开混音
  • 在混音上粘贴和部署合同,按照以下步骤操作
  • 复制ABI和合同地址
  • 导航到project上的’client/src/config.js’
  • 分别粘贴
  • 确保您处于新的终端窗口
  • 从目录上的源文件夹run:
  • 导航到’bot’目录,运行:npm install创建.env文件并将.env.example文件的内容复制到其中配置.env变量ACCOUNT是cassino将在’bot/index.js’更新abi和合同地址(从’client/src/config.js’复制这些内容)上使用的元掩码中的帐户。
  • 运行命令npm Run start
  • 赌场将部署合同
  • 将部署合同地址(我们可以将该地址直接复制到前端)。合同地址将始终相同。这是玩家加入游戏所需的地址
  • 部署合约后,赌场必须使用存款功能存款(建议金额为1以太)
  • 合约可以在任何时间将任何金额的钱存入合约
  • 承诺哈希被称为
  • 赌场存款1以太
  • 玩家将通过切换帐户地址加入合约
  • 玩家将存入他们的下注金额
  • 玩家现在可以下注
  • 玩家可以移除或在表上查看他们当前的下注
  • 首先安装truffle和文本编辑器,我们使用Atom
  • 安装两个系统后,用户必须将roullette.sol导入contracts文件夹,将roulettetest.js导入test文件夹
  • 要开始测试过程,必须从终端运行testrpc客户机,这将启动服务器将契约连接到测试文件
  • 打开一个新的终端窗口,运行truffle develope部署契约,然后使用命令test查看javascript文件中编写的所有可用测试
  • 应该有6个可用的测试文件可供查看
  • 确保您在新的终端窗口中
  • 从源文件夹导航到“客户端”目录运行:
  • 测试(后端)

    • 将部署合同地址(我们可以将该地址直接复制到前端)。合同地址将始终相同。这是玩家加入游戏所需的地址
    • 部署合约后,赌场必须使用存款功能存款(建议金额为1以太)

    cd bot

    • 合约可以在任何时间将任何金额的钱存入合约
    • 承诺哈希被称为
    • 赌场存款1以太
    • 玩家将通过切换帐户地址加入合约
    • 玩家将存入他们的下注金额
    • 玩家现在可以下注
    • 玩家可以移除或在表上查看他们当前的下注
    • 首先安装truffle和文本编辑器,我们使用Atom

    客户端(前端)

    1. 安装两个系统后,用户必须将roullette.sol导入contracts文件夹,将roulettetest.js导入test文件夹
    2. 要开始测试过程,必须从终端运行testrpc客户机,这将启动服务器将契约连接到测试文件
    3. 打开一个新的终端窗口,运行truffle develope部署契约,然后使用命令test查看javascript文件中编写的所有可用测试
    4. 应该有6个可用的测试文件可供查看

    项目设置

    1. 确保您在新的终端窗口中
    2. 从源文件夹导航到“客户端”目录运行:
    3. Player will join contract by switching account addresses
    4. Player will deposit their bet amount
    5. Player can now place their bet
    • Player can remove or see their current bets on the table

    运行,续集)
  • Truffle
  • 元掩码
  • 添加元掩码作为浏览器的扩展
  • 创建和帐户
  • 使用混音连接帐户
  • 链接令牌使用:克隆存储库后,在此处查找更详细的说明
  • ,“server/app/config/db.config.js”应该是这样的:
  • 导航到项目目录中的“client”目录cd client,您可以运行后端服务器:
  • 确保安装了truffle,请遵循src文件夹中的以下步骤,
  • 安装依赖项:
  • 编译契约:
  • 将契约迁移:
  • Navegate to:’client/src/contracts’
  • 打开Roulette.json
  • 复制ABI和契约地址
  • 导航到’client/src/config.js’
  • 分别粘贴
  • 复制契约’contracts/Roulette.sol’
  • 打开混音
  • 在混音上粘贴和部署合同,按照以下步骤操作
  • 复制ABI和合同地址
  • 导航到project上的’client/src/config.js’
  • 分别粘贴
  • 确保您处于新的终端窗口
  • 从目录上的源文件夹run:
  • 导航到’bot’目录,运行:npm install创建.env文件并将.env.example文件的内容复制到其中配置.env变量ACCOUNT是cassino将在’bot/index.js’更新abi和合同地址(从’client/src/config.js’复制这些内容)上使用的元掩码中的帐户。
  • 运行命令npm Run start
  • 赌场将部署合同
  • 将部署合同地址(我们可以将该地址直接复制到前端)。合同地址将始终相同。这是玩家加入游戏所需的地址
  • 部署合约后,赌场必须使用存款功能存款(建议金额为1以太)
  • 合约可以在任何时间将任何金额的钱存入合约
  • 承诺哈希被称为
  • 赌场存款1以太
  • 玩家将通过切换帐户地址加入合约
  • 玩家将存入他们的下注金额
  • 玩家现在可以下注
  • 玩家可以移除或在表上查看他们当前的下注
  • 首先安装truffle和文本编辑器,我们使用Atom
  • 安装两个系统后,用户必须将roullette.sol导入contracts文件夹,将roulettetest.js导入test文件夹
  • 要开始测试过程,必须从终端运行testrpc客户机,这将启动服务器将契约连接到测试文件
  • 打开一个新的终端窗口,运行truffle develope部署契约,然后使用命令test查看javascript文件中编写的所有可用测试
  • 应该有6个可用的测试文件可供查看
  • 确保您在新的终端窗口中
  • 从源文件夹导航到“客户端”目录运行:
  • 契约测试步骤

    1. Begin by installing truffle and a text editor, we used Atom.
    2. After installing both systems, the user would have to import roullette.sol into the contracts folder and roulettetest.js into the test folder.
    3. To begin the testing process, one must run the testrpc client from the terminal, which starts the server to connect the contract to the testing file.
    4. Open a new terminal window and run truffle develop to deploy the contract and then use the command test to see all the available tests written in the javascript file.
    5. There should be 6 available test files to view.

    Client (Front End)

    • Make sure you are in a new terminal window
    • Navigate to ‘client’ directory From source folder run:

    运行package.json来安装所有依赖项

    注意:用户应在dapp/client目录下运行npm start

    Project setup

    npm install 

    以开发模式运行应用程序。
    打开http://localhost:8081在浏览器中查看

    Run

    npm start 

    如果您进行编辑,页面将重新加载。
    您还将在控制台中看到任何lint错误

    Runs the app in the development mode.
    Open http://localhost:8081 to view it in the browser.

    The page will reload if you make edits.
    You will also see any lint errors in the console.

    部分转自网络,侵权联系删除区块链源码网

    www.interchains.cc

    https://www.interchains.cc/22106.html

    区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
    区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计Ethereum Roullette – 以太坊轮盘赌

    提供最优质的资源集合

    立即查看 了解详情