# 为检查的返回值 **Published by:** [web3zoom](https://paragraph.com/@web3zoom/) **Published on:** 2025-11-16 **URL:** https://paragraph.com/@web3zoom/TOdojsSYcDUbL473oD2H ## Content 描述: 低级调用函数call, delegatecall, static call 以及send 出现异常时,交易不会回滚(revert), 而是通过返回值的方式调用点传递状态信息。在这些低级调用发生错误时,如未检查其返回值或错误状态而执行后续关键逻辑,将会产生不可预期的安全问题。send 2300 gas限制, 执行失败后无法回滚, 不推荐使用;transfer 2300 gas限制, 执行失败后可回滚, 简单场景;call 无gas限制, 执行失败后无法回滚, 复杂场景;漏洞代码:// SPDX-License-Identifier: MIT pragma solidity ^0.8.30; contract BadLottery{ address public winner; uint256 public winAmount; bool public paidOut = false; function sendToWinner() public { require(!paidOut); payable (msg.sender).send(address(this).balance); } } 解决方案:对低级调用的状态进行检查(对send返回值进行检查)转账使用transfer 而非send ## Publication Information - [web3zoom](https://paragraph.com/@web3zoom/): Publication homepage - [All Posts](https://paragraph.com/@web3zoom/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@web3zoom): Subscribe to updates - [Twitter](https://twitter.com/primer2011): Follow on Twitter