为什么我不能通过智能合约将 1 个以太币发送到另一个账户?

why can't I send 1 ether to another account via smartcontract?

我正在使用 Solidity 构建合约并将其部署到以太坊私有网络 Ropsten。有一种 payRequest 方法可以将 1 个以太币转移到另一个帐户。我已成功部署联系人和 运行 方法。 (我设置收件人地址和1为金额)

我可以在 Etherscan 中查看交易哈希,其状态为成功。但是响应中的success是错误的。

交易中的值为0。收款人地址也没有收到这笔转账。我做错了什么?

// SPDX-License-Identifier: MIT
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

contract Leger {
    struct TransferRequest {
        string title;
        uint256 amount;
        string bsb;
        string accountName;
        string accountNumber;
    }

    event PaymentReceive(address from, uint256 amount);
    event TransactionBytes(bytes transactionBytes);
    event RequestPaid(address receiver, uint256 amount);

    function payRequest(address payable _recipient, uint256 _amount) public {
        
        (bool success, bytes memory transactionBytes) = _recipient.call{value:_amount}('');
        
        emit TransactionBytes(transactionBytes);
        
        emit RequestPaid(msg.sender, _amount);
    }

    receive() external payable {
        emit PaymentReceive(msg.sender, msg.value);
    }

}

您的功能不是付费的,请使用:

function payRequest(address payable _recipient, uint256 _amount)payable public {
        
        (bool success, bytes memory transactionBytes) = _recipient.call{value:_amount}('');
        
        emit TransactionBytes(transactionBytes);
        
        emit RequestPaid(msg.sender, _amount);
    }

我看不到以太币来自哪个帐户。 您不在合同中声明您的变量(例如在最佳实践中完成的事件之前)。

为了完全透明,你的合同对我来说似乎很奇怪或不完整。