我正在将一个合约部署到以太坊EVM环境中,并使用
Ropsten
测试网络。它将1个以太发送到另一个帐户,该帐户是从方法参与者传递的。
部署后,我设置了目标帐户的地址
0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2
何时呼叫
transfer
方法但我看到以下错误:
transact to Leger.transfer errored: VM error: revert.
The transaction has been reverted to the initial state.
Reason provided by the contract: "Transfer failed.".
Debug the transaction to get more information.
我的账户有99个以太币,为什么我会出现以上错误?
// SPDX-License-Identifier: MIT
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;
contract Leger {
address payable owner;
constructor(){
owner = msg.sender;
}
function transfer(address payable _recipient) public payable {
bool success = _recipient.send(1);
require(success, "Transfer failed.");
}
function getBalance() public view returns (uint256) {
return owner.balance;
}
}