问题描述
我有一系列合作者,我想根据他们的百分比在他们之间分配以太币,
我尝试使用 _to.call.value
方法,所有应该接收以太的地址都有可支付的构造函数,旁注我测试了发送以太合约和接收以太合约,它们工作正常将在下面发布:
contract ReciveEther {
function() external payable {}
function getBalance() public view returns (uint){
return address(this).balance;
}
function getAddress() public view returns (address){
return address(this);
}
}
现在我正在尝试做但由于某种原因它不起作用(我包括代码的相关部分):
function sendViaCallWValue(address payable _to,uint money) public payable {
(bool sent,bytes memory data) = _to.call.value(money)("");
require(sent,"faild to send Ether");
}
function payBill(uint billId,uint amt) public payable returns(uint times){
uint amountTaken ;
uint percentagePbs ;
uint share;
uint x = 0;
for(uint i=0; i <= nextBillId; i++){
if(Bills[i].id == billId){
for(uint c=0; c <= nextCollabId; c++){
if(Collabs[c].songId == Bills[i].songId){
percentagePbs = Collabs[c].percentage * 100;
share = amt * percentagePbs / 10000;
amountTaken = amountTaken + share;
address payable addr = Collabs[c].ArtistAddress;
sendViaCallWValue(addr,share);
}
}
}
现在,例如,当我以 50 以太币的价值部署合约时,我没有收到任何错误,并且该值会从地址余额中扣除,但由于某些奇怪的原因,接收方没有收到他们应该收到的以太币收到,他们实际上没有收到任何东西。 请记住,我已将 receiveEther 合约部署到我想发送到的地址之前
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)