智能合约概述

资讯 2024-07-13 阅读:113 评论:0
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

场景:Alice的在线投票系统

背景:Alice想要创建一个去中心化的在线投票系统,让参与者可以投票给不同的候选人。这个系统将使用以太坊区块链和智能合约来实现。

background: Alice wants to create a decentralised online voting system xff0c; allows participants to vote for different candidates. The system will be implemented using the Taiwan block chain and smart contracts.

1. 智能合约概述: Alice设计了一个智能合约,名为。这个合约将处理投票的提交、计票以及结果的公布。合约中包含了状态变量来存储每位候选人的票数,以及一个投票者的白名单。

1. An overview of the Smart Contract : Alice designed a smart contract xff0c; name. The contract will deal with the submission of votes, the counting of votes and the publication of results. The contract contains a status variable to store the votes of each candidate xff0c; and a white list of voters.

2. 简单的智能合约: 合约中有一个简单的状态变量,用于记录每位候选人的票数。同时,合约提供了两个函数:用于投票,用于查询特定候选人的票数。

2. A simple smart contract : A simple state variable xff0c; for recording the votes of each candidate. xff0c; two functions xff1a; for voting xff0c; for searching the votes of a given candidate.

3. 存储合约示例: Alice部署了到以太坊区块链上。这个合约现在拥有一个以太坊地址,任何人可以通过发送交易到这个地址来与之交互。

3. Examples of storage contracts : Alice is deployed on the Etherm block chain. The contract now has an Etherm address & #xff0c; anyone can interact with it by sending a transaction to this address.

4. 区块链基础: 当Bob想要为Charlie投票时,他创建了一笔交易,调用的函数,并指定Charlie作为候选人。这笔交易被广播到以太坊网络,一旦被矿工打包进区块,Charlie的票数就会在区块链上更新。

4. The block chain base : , when Bob wants to vote for Charlie; he created a transaction & #xff0c; called function & #xff0c; and named Charlie as the candidate. The transaction was broadcast to the Ethernet xff0c; the votes of Charlie will be updated on the block chain once they are packed by the miners & #xff0c; Charlie's votes will be updated.

5. 交易/事务: Bob的投票交易是一个事务,它要么完全执行(即Charlie的票数增加),要么完全不执行(如果因为某些原因交易失败)。这保证了投票的原子性。

5. The transaction/service : Bob's voting transaction is a matter & #xff0c; it either fully implements xff08; xff0c; xff08; xff08; xff09; ff09; ff09; xff09. This ensures the atomic nature of the vote.

6. 区块: Bob的投票交易被包含在一个区块中,这个区块也包含了其他交易。一旦这个区块被添加到区块链上,Bob的投票就成为了不可篡改的历史记录的一部分。

6. Block : Bob's voting transaction is included in a block & #xff0c; this block also contains other transactions. Once the block is added to the block chain & #xff0c; Bob's vote becomes part of an undisguised historical record.

7. 以太坊虚拟机(EVM): 当Bob的交易到达网络时,EVM会执行合约中的函数。EVM确保了合约代码在一个隔离且确定性的环境中执行,不会受到外部环境的影响。

7. ETA virtual machine xff08; EVM) : xff0c; EVM will perform the functions in the contract when Bob's transaction arrives on the network. EVM ensures that the contract code is executed xff0c in an isolated and deterministic environment; it will not be affected by the external environment.

8. 存储,内存和栈: 在执行函数时,EVM会为这次调用创建一个新的内存实例。函数的参数(即Charlie的名字)会被存储在内存中,而函数的返回值(票数更新的结果)会被放入栈中。

8. Storage & #xff0c; RAM

9. 日志: 每当有人投票,合约会发出一个事件,记录投票者的地址和他们投票给的候选人。这个事件会被记录在区块链的日志中,允许任何人查询投票活动。

9. Log : Whenever someone votes xff0c; the contract sends an event xff0c; records the address of the voter and the candidate to whom they vote. This event is recorded in the log of the block chain xff0c; allows anyone to consult the voting event.

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 从 IPFS社区Meetup谈谈2020年的IPFS的发展历程

    从 IPFS社区Meetup谈谈2020年的IPFS的发展历程
    8月3日, IPFS社区Meetup 如期举办,这一次的社区Meetup由交流与演讲和闪电演示两部分组成,其实该会议主要带领我们回顾了IPFS在2020年的发展历程(包括项目进展、IPFS生态发展等),展示了IPFS及其生态。2020年对于IPFS而言是不平凡的一年,其唯一激励层Filecoin的主网即将上线,这让IPFS和Filecoin在全球范围内得到了前所未有的关注,也推动了IPFS的高速发展。接下来,我们一起走进IPFS在20...
  • 超10万人爆仓,比特币跳水,发生了什么

    超10万人爆仓,比特币跳水,发生了什么
    现货比特币ETF上市第二日,数字货币再迎来抛售。比特币一度跌破42000美元/枚,截止1月13日内跌幅超7%,报42562.1美元/枚。The current Bitcoin ETF is on the second day of the market and the digital currency is sold again. Bitcoin fell by over 7% to $4562.1 on 13 January.现货比特币ETF普遍跌6%左右。其中,DEFI跌...
  • 0.00003374个比特币等于多少人民币/美金

    0.00003374个比特币等于多少人民币/美金
    0.00003374比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00003374比特币等于2.2826 1222美元/16.5261124728人民币。比特币(BTC)美元(USDT)人民币(CNY)0.00003374克洛克-0/22216.5261124728比特币对人民币的最新汇率为:489807.72 CNY(1比特币=489807.72人民币)(1美元=7.24人民币)(0.00003374USDT=0.0002442776 CNY)。汇率更新于2024...
  • 0.00015693个比特币等于多少人民币/美金

    0.00015693个比特币等于多少人民币/美金
    0.000 15693比特币等于多少人民币?根据比特币对人民币的最新汇率,0.000 15693比特币等于10.6 1678529美元/76.86554996人民币。比特币(BTC)【比特币价格翻倍】美元(USDT)人民币(CNY)0.000/克洛克-0/5693【数字货币矿机】10.6 167852976.8655254996比特币对人民币的最新汇率为:489,807.72 CNY(1比特币= 489,807.72人民币)(1美元=7.24人民币)(0.00015693 U...
  • 0.00006694个比特币等于多少人民币/美金

    0.00006694个比特币等于多少人民币/美金
    0.00006694比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00006694比特币等于4.53424784美元/32.5436 16人民币。比特币(BTC)美元(USDT)人民币(CNY)0.000066944.53424784【比特币密码】32.82795436 16比特币对人民币的最新汇率为:490408.64 CNY(1比特币=490408.64人民币)(1美元=7.24人民币)(0.00006694USDT=0.0004846456 CNY)汇率更新时...
标签列表