- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遇到了这个 article关于避免使用solidity 的transfer()/send()
的日期为2019/9。以下是文章中的推理:
It looks like EIP 1884 is headed our way in the Istanbul hard fork. This change increases the gas cost of the SLOAD operation and therefore breaks some existing smart contracts.
Those contracts will break because their fallback functions used to consume less than 2300 gas, and they’ll now consume more. Why is 2300 gas significant? It’s the amount of gas a contract’s fallback function receives if it’s called via Solidity’s transfer() or send() methods. 1
Since its introduction, transfer() has typically been recommended by the security community because it helps guard against reentrancy attacks. This guidance made sense under the assumption that gas costs wouldn’t change, but that assumption turned out to be incorrect. We now recommend that transfer() and send() be avoided.
在remix
中,有一条关于下面代码的警告信息:
(bool success, ) = recipient.call{value:_amount, gas: _gas}("");
警告:
Low level calls: Use of "call": should be avoided whenever possible. It can lead to unexpected behavior if return value is not handled properly. Please use Direct Calls via specifying the called contract's interface. more
我不是执行智能合约和安全性的 gas 成本方面的专家。因此,我发布了这篇文章,希望能对它提出想法和意见。
最佳答案
从 Consensys 文章中,他们说使用 .call() 而不是 .transfer() 和 .send()。唯一的争论是这三个现在都发送了比 2300 更多的气体。从而使重入成为可能。
由此得出的另一个结论是,不管以上所有情况,使用 checks-effects-interactions pattern 很重要。防止重入攻击。
关于ethereum - 避免使用solidity的transfer()/send()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64230863/
我想知道大括号在那种情况下是什么意思? uint64 configCount = s_configCount; { s_hotVars.latestConfigDigest = c
我正在运行一个独立的单用户 v5 节点实体服务器。当我以该单个用户身份登录时,我能够在一个不存在的容器中创建一个文档,并且服务器会为我创建该容器。 例如 POST https://my.server:
我想覆盖以下继承函数: function _setBaseURI(string memory baseURI) public override(ERC721Full, ERC721Metadata
我定义了一个映射类型的状态变量,例如映射(uint256 => uint256[])。我想将其公开,以便我可以从契约(Contract)外部访问它。但是,编译器报告错误 TypeError: Wron
我正在处理 Solidity 智能合约,并且正在导入 openzeppelin-solidity 库和 chainlink 库。 两者都有 SafeMath 库;我正在用 Python 加载所有 .s
我在以下示例中遇到了 Solidity Documentation 并且在我的项目中有类似的代码并想设置 default value如果键不是从调用者传递过来的,则到 key 参数 pragma so
据我所知,有两种方法可以获得某个地址的余额。 address firstAddress; "firstAddress.balance"这将获得地址“firstAddress”的余额。 address
我正在使用 solidity 构建一个 NFT 智能合约,并且我试图在部署合约时将 Array of Structs 传递到构造函数中。但是我收到以下错误。 TypeError: Cannot rea
免费的 Everscale Solidity。如何与负责 职能部门合作?如何正确等待回调并从sdk查看合约执行结果? 例如,我有契约(Contract)(没有任何用处)。如何在我的应用程序中以正确的方
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 3 年前。 Improve
我最近在很多代码中注意到人们将硬编码的配置(如端口号等)值放在类/方法的深处,使其难以找到,也无法配置。 这是否违反了 SOLID 原则?如果不是,我是否可以向我的团队成员引用另一个“原则”来说明为什
Solidity 最近的变化将回退函数格式从只是 function() 更改为 fallback(),这对于初学者来说非常好理解发生了什么,但是我有一个问题,关于编译器在我实现时给我的建议后备。 例如
如果我有类似的东西 class square : figure {} class triangle : figure {} 这是否意味着我永远不应该使用正方形和三角形类而只能引用图形? 永远不要这样做
我正在尝试将字节可靠地转换为 uint256。这是坚固的代码, // SPDX-License-Identifier: MIT pragma solidity 0.8.13; contract Sam
我想在 SolidJS 中动态设置 JSX 标签名称。我来自 React it is fairly simple to do : /* Working ReactJS Code: */ export
我正在尝试将字节可靠地转换为 uint256。这是坚固的代码, // SPDX-License-Identifier: MIT pragma solidity 0.8.13; contract Sam
我想在 SolidJS 中动态设置 JSX 标签名称。我来自 React it is fairly simple to do : /* Working ReactJS Code: */ export
我正在继续开发 ASP.NET 应用程序(基于 Web 表单),其中以前的开发人员没有遵循良好的面向对象设计原则,即 SOLID (http://www.remondo.net/solid-princ
我创建了 ERC20 代币,我想将我的代币转移到另一个地址。 我的元掩码中有两个帐户。(帐户 A/B) 我的 ERC20 代码在这里(我在账户 A 中部署并保存了代币) pragma solidity
struct Test { uint ui; string s; } function test(Test t) public { emit Log(t.ui, t.s); } 我对 AB
我是一名优秀的程序员,十分优秀!