select guest account
send ether to owner
//logs
//send 1 ether to hotel
revert
The transaction has been reverted to the initial state.
Reason provided by the contract: "Not enought Ether provided.".
Debug the transaction to get more information.
transact to HotelRoom.(receive) pending ...
//send 2 ether to hotel
[vm] from: 0xAb8...35cb2to: HotelRoom.(receive) 0xd91...39138value: 2000000000000000000 weidata: 0xlogs: 1hash: 0xfec...dc117
transact to HotelRoom.(receive) pending ...
//send 2 ether to hotel again
[vm] from: 0xAb8...35cb2to: HotelRoom.(receive) 0xd91...39138value: 2000000000000000000 weidata: 0xlogs: 0hash: 0x5fa...6ed65
transact to HotelRoom.(receive) errored: VM error: revert.
revert
The transaction has been reverted to the initial state.
Reason provided by the contract: "Currently Occupied".
Debug the transaction to get more information.
-----------------------
//HotelRoom.sol
pragma solidity ^0.6.0;
contract HotelRoom {
enum Statuses {Vacant, Occupied}
Statuses currentStatus;
event Occupy(address _occupant, uint _value);
address payable public owner;
constructor() public {
owner = msg.sender;
currentStatus = Statuses.Vacant;
}
modifier onlyWhileVacant {
require(currentStatus == Statuses.Vacant, "Currently Occupied");
_;
}
modifier costs(uint _amount){
require(msg.value >= _amount, "Not enought Ether provided.");
_;
}
receive() external payable onlyWhileVacant costs(2 ether){
currentStatus = Statuses.Occupied;
owner.transfer(msg.value);
emit Occupy(msg.sender, msg.value);
}
}
reference:
No comments:
Post a Comment