基于区块链的毕业设计Lottery Project – 彩票项目

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计Lottery Project – 彩票项目 是一篇很好的国外资料

Lottery Project

This project was created with solidity to develop the lottery smart contract. The application wrapper that interacts with the smart contract was developed using javascript.

High Level Concept

Contract

  • Contract called lottery
  • Contract will have a prize pool
  • Contract will have players
  • The system will have two types of actors
  • Contestants & Manager
  • Contestents will send money to the contract, pooling their money as the winning prize.
  • Participating contestants’ addresses will be stored within the contract in order to choose a winner and therefore, send the winnings to the contestants’ respective address.
  • The manager will interact with the contract to initiate lottery/raffle.

Smart Contract Requirements

  • Variables

Name | Purpose manager | Address of the person who created the contract players | Array of address of end users who have entered. I.e. sent money to the contract

  • Functions

Name | Purpose enter | Enters an end user into the lottery pickWinner | Randomly picks a winner and sends them the prize pool.

Steps Taken

  1. Use remix to create intial draft of contract and test on the javascript virtual machine.

Additional Notes

Basic Types

Name| Notes| Examples string | Sequence of chars | “Hi There!” “Chocolate” bool | Boolean value | true, false int | Integer, positive or negative. Has no decimel | 0 -10 59 uint | ‘Unsigned’ integer, positive number, no decimel | 0 1 5999 fixed/ufixed | ‘Fixed’ point number. Number with a decimel after it | 20.001 -40.323 4321 address | Has methods tied to it for sending money | 0x12cdf6ds6ad5dfa5dsf5cd6s6saf55d

Reference Types

Name | Notes | Examples fixed array | Array that contains a single type of element. Has an unchanging length | int[3] -> [1,2,3] bool[2] -> [true, false] dynamic array | Array that contains a single type of element. Can change in size over time | int[] -> [1,2,3] bool[] -> [true, false] mapping | Collection of key value pairs. Think of Javascript objects, Ruby hashes, or Python dictionary. All keys must be of the same type, and all values must be of the same type | mapping (string => string) mapping(int => bool) struct | Collection of key value pairs that can have different type | struct Car ( string make; string model; uint value;)

Message Object

  • Global variable
  • msg.data | ‘Data’ field from the call or transaction that invoked the current fucntion
  • msg.gas | Amount of gas the current function invocation has available
  • msg.sender | Address of the account that started the current function invocation
  • msg.value | Amount of ether (in wei) that was sent along with the function invocation

Msg object = (Account & Call)

  • Gloabl variable available for each sent transaction or call

|Account -> Transaction| -> Rinkeby{Contract Instance}

solidity: Common function types

  • Can only used one per function public | Anyone can call this function private | Only this contract can call this function

  • They mean the same thing view | This function returns and does not modify the contract’s data constant | This function returns and does not modify the contract’s data

pure | Function will not modify or even read the contract’s data payable | When someone call this function they might send ether along

Solidity: Modifiers

  • Use modifiers to solve repetitive code within contracts

Solidity: Validation

  • require is used for validation. Can pass in boolean expression.
    • If false, the process is exited and no changes are made to the contract.
    • If true, the code continues to execute.

Installation commands

  • npm init | initialises a npm project with package-json
  • npm install –save solc@0.4.25 | installs the solidity compiler library
  • npm install –save mocha | installs the mocha js testing library
  • npm install –save ganache-cli | installs the ethereum local testnet library
  • npm install –save web3@1.0.0-beta.26 | installs the js network interaction library
  • npm install –save truffe-hdwallet-provider@0.0.3 | installs library for interacting with hardwallets accounts. I.e. MetaMask

ethereum lottery project developed with solidity and javascript with …


高级概念

本项目是为了开发彩票智能合约而创建的。与智能合约交互的应用程序包装器是使用javascript开发的。

智能合同要求

合同

  • 称为彩票的合同
  • 合同将有一个奖品池
  • 合同将有玩家
  • 系统将有两种类型的参与者
  • 参赛者和经理将把钱汇到合同中,作为中奖。
  • 参赛选手的地址将存储在合同中,以便选择获胜者,并将奖金发送到参赛者各自的地址。
  • 经理将与合同互动,发起抽奖活动。
  • 变量

所采取的步骤

  • 函数

名称|目的经理|创建合同参与者的地址|输入的最终用户的地址数组。一、 e.把钱送到合同中

  • 使用remix创建初始合同草案,并在javascript虚拟机上进行测试。全局变量消息数据|调用当前函数的调用或事务的“数据”字段味精煤气|当前函数调用可用的气体量邮件发件人|启动当前函数调用的帐户的地址消息值|乙醚量(inwei)随函数调用一起发送的

Name | Purpose enter |将最终用户输入抽奖机|随机挑选一个中奖者并将其发送到奖池。

附加说明

  1. Gloabl变量可用于每个发送的事务或调用

基本类型

参考类型

名称|注释|示例字符串|字符序列|“你好!”巧克力“bool |布尔值|真,假int |整数,正或负。没有十进制| 0-10 59 uint | Unsigned’整数,正数,没有十进制| 0 1 5999固定/固定|点号。后面带小数点的数字| 20.001-40.323 4321 address |具有与之相关的用于发送货币的方法| 0x12cdf6ds6ad5dfa5dsf5cd6s6saf55d

消息对象

Name | Notes | Examples fixed array |包含单一类型元素的数组。具有长度不变的| int[3]->[1,2,3]bool[2]->[true,false]动态数组|数组,该数组包含单一类型的元素。可以随时间改变大小| int[]->[1,2,3]bool[]->[true,false]映射|键值对集合。想想Javascript对象、Ruby哈希或Python字典。所有键的类型必须相同,所有值的类型必须相同| mapping(string=>string)mapping(int=>bool)struct |可以具有不同类型| struct Car(string make;string model;uint value;)的键值对的集合;Rinkeby{Contract Instance}

稳定度:常用函数类型

  • 每个函数只能使用一个public |任何人都可以将此函数称为private |只有此约定可以调用此函数
  • 它们表示相同的事物视图|此函数返回且不修改合同的数据常量|此函数返回且不修改合同的数据
  • 使用修饰符解决合同中的重复代码
  • 要求用于验证。可以传入布尔表达式。如果为false,则退出该过程,并且不对合同进行任何更改。如果为true,代码将继续执行。
  • 如果为false,则退出该过程,并且不会对合同进行任何更改。

每个函数只能使用一个public函数|任何人都可以调用这个private函数|只有这个Contract可以调用这个函数

  • 如果为真,代码将继续执行。

它们的意思是一样的视图|这个函数返回并且不修改Contract的数据常量|这个函数返回并且不修改Contract的数据

稳定度:修饰符

  • npm init |使用包json初始化npm项目
  • npm install–save溶液@0.4.25|安装solidity编译器库

pure | Function will not modify or even read the contract’s data payable | When someone call this function they might send ether along

稳定度:验证

  • npm install–save mocha |安装mocha js测试库

安装命令

  • npm install–save ganache cli |安装以太坊eth本地testnet库

Installation commands

  • npm init | initialises a npm project with package-json
  • npm install –save solc@0.4.25 | installs the solidity compiler library
  • npm install –save mocha | installs the mocha js testing library
  • npm install –save ganache-cli | installs the ethereum local testnet library
  • npm install –save web3@1.0.0-beta.26 | installs the js network interaction library
  • npm install –save truffe-hdwallet-provider@0.0.3 | installs library for interacting with hardwallets accounts. I.e. MetaMask

ethereum lottery project developed with solidity and javascript with …

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

www.interchains.cc

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

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

提供最优质的资源集合

立即查看 了解详情