send(),trassing()等呼叫是否会隐式降低合同余额?

发布于 2025-02-11 11:53:41 字数 342 浏览 0 评论 0原文

L1: require(sender != address(0), "ERC20: transfer from the zero address");
L2: require(recipient != address(0), "ERC20: transfer to the zero address");
L3: _balances[sender] = _balances[sender].sub(amount);
L4: _balances[recipient] = _balances[recipient].add(amount);

L3线是否强制性减少合同余额? 另外,如果没有完成,这不会导致类似的双重支出问题?

L1: require(sender != address(0), "ERC20: transfer from the zero address");
L2: require(recipient != address(0), "ERC20: transfer to the zero address");
L3: _balances[sender] = _balances[sender].sub(amount);
L4: _balances[recipient] = _balances[recipient].add(amount);

Is line L3 compulsory to reduce the contract balance?
Also if the same is not done will that not lead to a similar issue of double spending?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝颜夕 2025-02-18 11:53:42

在实现ERC20令牌时,最好使用诸如OpenZepplin之类的库,那么您就无需实现send/transfer

但是,如果您不想使用库,那么您是一个人,所以是的,您需要L3(和L4)来跟踪令牌余额。

While implementing the ERC20 Token you'd better off using a library like OpenZepplin, then you don't need to implement send/transfer at all.

However, if you don't want to use the library, then you're on your own, so yes you need the line L3 (and L4) to keep track of the token balance.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文