send(),trassing()等呼叫是否会隐式降低合同余额?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在实现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.