ETH Price: $2,100.38 (+3.20%)

Transaction Decoder

Block:
18775434 at Dec-13-2023 06:21:47 AM +UTC
Transaction Fee:
0.00562304337592986 ETH $11.81
Gas Used:
149,418 Gas / 37.63297177 Gwei

Emitted Events:

110 PurchaseContract.PurchaseMade( from=[Sender] 0x0cdc07c7172307bb709c3aeb4fbb8724c0ccc098, to=0x1aa5e77363c1aeda255d434513e23abf789b7c0d, listHash=2E28FF7E01833BF6068F970BEF90A806EC417051B18470625138DBA2EACB90B9 )

Account State Difference:

  Address   Before After State Difference Code
0x0cDc07c7...4C0CCC098
0.139222623742510314 Eth
Nonce: 169
0.118599580366580454 Eth
Nonce: 170
0.02062304337592986
0x1AA5E773...f789b7c0d 0.201214021601878385 Eth0.215914021601878385 Eth0.0147
4.076219024017804547 Eth4.076293733017804547 Eth0.000074709
0xBc962E2e...aE2a8085F 1.5905331191402618 Eth1.5908331191402618 Eth0.0003

Execution Trace

ETH 0.015 PurchaseContract.buy( ethsId=E6D554133AC9C9EDDBF7F6FD34824F8ED9D2408F29A1002FC042956AF51B5326, listId=5D9901AE725D6B52E9DAAF27B45B4160ED89FF17E9D0EF6E6CF7B5BF6A62AB10, listAddress=0x1AA5E77363c1AeDa255d434513e23aBf789b7c0d, price=15000000000000000 )
  • ETH 0.0147 0x1aa5e77363c1aeda255d434513e23abf789b7c0d.CALL( )
    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.0;
    
    contract PurchaseContract {
        address public owner;
        uint256 public feePercentage = 2;
    
        struct Purchase {
            bytes32 ethsId;
            bytes32 listId;
            address listAddress;
            uint256 price;
            bool isPurchased;
        }
    
        mapping(bytes32 => Purchase) public purchases;
    
        event PurchaseMade(address from, address to, bytes32 listHash);
        event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);
    
        constructor() {
            owner = msg.sender;
        }
    
        modifier onlyOwner() {
            require(msg.sender == owner, "Only owner can call this function.");
            _;
        }
    
        function setFeePercentage(uint256 newFee) public onlyOwner {
            feePercentage = newFee;
        }
    
        function buy(bytes32 ethsId, bytes32 listId, address listAddress, uint256 price) public payable {
            bytes32 purchaseHash = keccak256(abi.encodePacked(ethsId, listId));
            require(!purchases[purchaseHash].isPurchased, "This item is already purchased.");
            require(msg.value == price, "Incorrect price.");
    
            purchases[purchaseHash] = Purchase(ethsId, listId, listAddress, price, true);
    
            uint256 fee = (price * feePercentage) / 100;
            uint256 amountToSend = price - fee;
    
            payable(listAddress).transfer(amountToSend);
            // The fee remains in the contract
    
            emit PurchaseMade(msg.sender, listAddress, purchaseHash);
        }
    
        function withdraw(uint256 amount) public onlyOwner {
            uint256 balance = address(this).balance;
            require(amount > 0, "Amount must be greater than 0");
            require(balance >= amount, "Insufficient funds in contract");
    
            payable(owner).transfer(amount);
        }
    
        function transferOwnership(address newOwner) public onlyOwner {
            require(newOwner != address(0), "New owner cannot be the zero address");
            emit OwnershipTransferred(owner, newOwner);
            owner = newOwner;
        }
    
        
    }