Error: evm: execution reverted

안녕하세요. klaytn ide에서 test 할 때는 잘 돌아가는데 caver로 넘어와서 실행하면 Error: evm: execution reverted 나오는데 어디가 문제인지 모르겠습니다. smart-contract는 truffle 이용해서 배포했습니다.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract TransferFee{
    event TransferToContract(address buyer, address indexed owner, uint indexed product_id, uint indexed date, uint reservationId);
    event TransferToOwner(address buyer, address indexed owner, uint indexed product_id);

    struct ReservationInfo {
        address owner;
        address buyer;
        uint product_id;
        uint date;
        uint price;
    }

    mapping (uint => ReservationInfo) public ReservationMapping;

    uint private id = 0;

    receive() external payable {
    }

    /// @dev : 예약자가 contract로 송금하는 함수
    function transferToContract(address owner, uint product_id, uint date) public payable {
        require(owner > address(0), "This is not a valid address");
        require(msg.sender.balance >= msg.value, "There is not enough klay in the account");
        require(msg.value > 0, "You cannot send 0 klay");

        uint reservationId = id;

        payable(address(this)).transfer(msg.value);
        ReservationMapping[id] = ReservationInfo(owner, msg.sender, product_id, date, msg.value);
        id += 1;

        emit TransferToContract(msg.sender, owner, product_id, date, reservationId);
    }

    /// @dev : contract에서 집주인에게 송금하는 함수
    function transferToOwner(uint reservationId) public payable {
        require(ReservationMapping[reservationId].price <= address(this).balance, "There is no money to transfer to the contract.");

        uint fee = ReservationMapping[reservationId].price;
        address owner = ReservationMapping[reservationId].owner;
        address buyer = ReservationMapping[reservationId].buyer;
        uint product_id = ReservationMapping[reservationId].product_id;

        payable(owner).transfer(fee);
        delete ReservationMapping[reservationId];

        emit TransferToOwner(buyer, owner, product_id);
    }

    function getBalanceOfContract() public view returns (uint) {
        return address(this).balance;
    }
}

Error: evm: execution reverted
{
“blockHash”: “0x8889daa0e654654428fc04d51c2793cf81d699ea7486a3f4ea988682350acd9d”,
“blockNumber”: 94474128,
“contractAddress”: null,
“from”: “0xae47d48c2ac7c5e2d3ba7f2a1bed4bdacd7cfd77”,
“gas”: “0x7a1200”,
“gasPrice”: “0x3a35294400”,
“gasUsed”: 32884,
“input”: “0x95f847fd000000000000000000000000b6468698d1a89283198f2e4cfacd0698cb2f195f00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000fcb0a0”,
“logs”: ,
“logsBloom”: “0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000”,
“nonce”: “0x20”,
“senderTxHash”: “0x0c09b6a03ee6db649322acfb6169ceb2bbba7cb042038bbf9e91dedd82690381”,
“signatures”: [
{
“V”: “0x7f5”,
“R”: “0xaf57f7bbf207acdb319e455f2fb71aed2cba63a690a5658b1b3eefec6f3d1e89”,
“S”: “0x251e2b2d5551352e5e3229c0b6ac9c26bf6d6b358157a844f42cadcb13f9da38”
}
],
“status”: false,
“to”: “0x8d9fb5fe65661e10dbef9907ad9179dc98690370”,
“transactionHash”: “0x0c09b6a03ee6db649322acfb6169ceb2bbba7cb042038bbf9e91dedd82690381”,
“transactionIndex”: 3,
“txError”: “0x9”,
“type”: “TxTypeSmartContractExecution”,
“typeInt”: 48,
“value”: “0xad78ebc5ac6200000”
}

안녕하세요

evm reverted의 원인을 분석하기 위해서는 debug API를 사용해야 합니다.
혹은 아래와 같이 Scope에서 failure의 원인을 조회할 수도 있습니다.

참고 부탁드립니다.

1개의 좋아요

안녕하세요. 답변 감사합니다. 확인해볼게요!