BSC部署合约Gas费过高原因及支付拆分替代方案咨询
BSC合约Gas费过高原因及支付拆分替代方案咨询
我已在BSC(币安智能链)上部署了如下合约,恳请各位指导该合约Gas费过高的原因,若有支付拆分的替代方案,也请不吝赐教。
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract BNBTest { // Function to distribute BNB to multiple recipients function multisend(uint256[] memory amounts, address payable[] memory receivers) public payable { require(amounts.length == receivers.length, "Arrays must be of equal length"); require(receivers.length > 0, "No receivers provided"); require(receivers.length <= 2, "Maximum of 2 receivers allowed"); uint256 totalAmount = amounts[0] + amounts[1]; require(msg.value >= totalAmount, "Insufficient funds sent"); receivers[0].transfer(amounts[0]); receivers[1].transfer(amounts[1]); } }
内容的提问来源于stack exchange,提问作者user919573
相关产品推荐
相关产品推荐

