当前位置: 首页 > news >正文

信息展示网站怎么做能够让网站流量大

信息展示网站,怎么做能够让网站流量大,php手机网站怎么做,建设游戏网站目的及其定位1.提款模式提款模式确保不会造成安全威胁的直接转接呼叫。 以下合约显示了使用转账调用发送以太币的不安全方式。pragma solidity ^0.5.0;contract Test {address payable public richest;uint public mostSent;constructor() public payable {richest msg.sender;mostSent m…

1.提款模式

提款模式确保不会造成安全威胁的直接转接呼叫。 以下合约显示了使用转账调用发送以太币的不安全方式。

pragma solidity ^0.5.0;contract Test {address payable public richest;uint public mostSent;constructor() public payable {richest = msg.sender;mostSent = msg.value;}function becomeRichest() public payable returns (bool) {if (msg.value > mostSent) {// Insecure practicerichest.transfer(msg.value);richest = msg.sender;mostSent = msg.value;return true;} else {return false;}}
}

通过使最富有的合约成为后备功能失败的合约,可以使上述合约处于不可用状态。 当后备函数失败时,becomeRichest()函数也会失败,合约将永远卡住。 为了缓解这个问题,我们可以使用 Withdrawal Pattern。

在提款模式中,我们会在每次转账前重置待处理金额。 它将确保只有调用者合约失败。

pragma solidity ^0.5.0;contract Test {address public richest;uint public mostSent;mapping (address => uint) pendingWithdrawals;constructor() public payable {richest = msg.sender;mostSent = msg.value;}function becomeRichest() public payable returns (bool) {if (msg.value > mostSent) {pendingWithdrawals[richest] += msg.value;richest = msg.sender;mostSent = msg.value;return true;} else {return false;}}function withdraw() public {uint amount = pendingWithdrawals[msg.sender];pendingWithdrawals[msg.sender] = 0;msg.sender.transfer(amount);}
}

2.限制访问

限制访问合同是一种常见做法。 默认情况下,合约状态是只读的,除非将其指定为公共状态。

我们可以限制谁可以修改合约的状态或使用修饰符调用合约的函数。 我们将创建并使用多个修饰符,如下所述 −

  • onlyBy − 一旦用于函数,则只有提到的调用者可以调用该函数。

  • onlyAfter − 一旦用于函数,则可以在一定时间段后调用该函数。

  • costs − 一旦用于函数,则仅当提供特定值时调用者才能调用该函数。

示例

pragma solidity ^0.5.0;contract Test {address public owner = msg.sender;uint public creationTime = now;modifier onlyBy(address _account) {require(msg.sender == _account,"Sender not authorized.");_;}function changeOwner(address _newOwner) public onlyBy(owner) {owner = _newOwner;}modifier onlyAfter(uint _time) {require(now >= _time,"Function called too early.");_;}function disown() public onlyBy(owner) onlyAfter(creationTime + 6 weeks) {delete owner;}modifier costs(uint _amount) {require(msg.value >= _amount,"Not enough Ether provided.");_;if (msg.value > _amount)msg.sender.transfer(msg.value - _amount);}function forceOwnerChange(address _newOwner) public payable costs(200 ether) {owner = _newOwner;if (uint(owner) & 0 == 1) return;        }
}
http://www.dtcms.com/a/422577.html

相关文章:

  • Linux 系统 IO 编程入门:从文件操作到硬件设备访问
  • 以CodeBuddy Code为砚,Prompt为丹青,勾勒编程星河
  • 房产网站模板程序wordpress去版权
  • OpenCV 摄像头参数控制详解
  • Kimi-Audio:Kimi开源的通用音频基础模型,支持语音识别、音频理解等多种任务
  • 阿里开源视频修复方法Vivid-VR:以独特策略与架构革新,引领生成视频修复高质量可控新时代。
  • 独立开发在线客服系统手记:实现对 PostgreSQL 的支持,以及与 MySQL 的对比
  • 【项目】Vision Master OpenCV 3.0 版本(预)发行说明
  • 官方网站是什么意思网站备案 godaddy
  • 温州网站运营长沙网页制作模板
  • 前端埋点(打点)方案
  • pako处理 urlencode(gzcompress(json_encode($res))) php的加密方式web解析
  • 深入理解 SSE:服务器发送事件及其在前后端中的实践
  • Web典型路由结构之Next.js (App Router, v13+) )(文件系统驱动的路由:File-based Routing)声明式路由:文件即路由
  • 【设计模式】解释器模式
  • 【前端知识】iframe 使用详细说明
  • 推荐一款集成AI功能的数据库管理工具
  • Flask 入门:轻量级 Python Web 框架的快速上手
  • 每日前端宝藏库 | tinykeys ✨
  • 第7章:TS快速入门和前端项目初始化
  • 合肥 做网站的深圳办公室装修设计公司
  • Android实现RecyclerView粘性头部效果,模拟微信账单列表的月份标题平移
  • 建三江建设局网站网站建设自我评价怎么写比较好
  • 华为Fit4手表:个性化表盘,让生活更有温度
  • Spring Boot - 从PF4J到SBP:深入解析Java插件化架构的演进与实践
  • 河南做网站企起做平面什么网站的素材不侵权
  • 哪个网站做ppt模板赚钱手机棋牌游戏平台
  • 鸿蒙app开发中 拿到json文件数据进行动画的播放
  • 第三章 鸽巢原理
  • 智慧政务——解读57页清华大学:DeepSeek政务场景应用与解决方案【附全文阅读】