false
false

Contract Address Details
contract

0x95f0C147109ca7b18882bbD7Dbc636F103D27cD5

Contract Name
MarketEvents
Creator
0xd12e15–9a46f9 at 0x0b46d9–7323f6
Balance
0 xDai ( )
Tokens
Fetching tokens...
Transactions
618 Transactions
Transfers
600 Transfers
Gas Used
84,495,175
Last Balance Update
28346214
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
MarketEvents




Optimization enabled
true
Compiler version
v0.8.7+commit.e28d00a7




Optimization runs
9999
EVM Version
default




Verified at
2021-10-01T12:25:19.830517Z

Constructor Arguments

0000000000000000000000008e7fc9c67cf2bc5d001682d17355dc5c7f41e4c1

Arg [0] (address) : <a href=/xdai/mainnet/address/0x8e7fc9c67cf2bc5d001682d17355dc5c7f41e4c1>0x8e7fc9c67cf2bc5d001682d17355dc5c7f41e4c1</a>

              

Contract source code

Sol2uml
new
//SPDX-License-Identifier: MIT

pragma solidity ^0.8.6;

interface IERC721{
    function transferFrom(address from, address to, uint tokenID) external;
}

contract MarketEvents{
  
    event Sale(
        uint indexed id,
        address indexed buyer
    );

    event Listed(
        uint indexed id,
        uint indexed price,
        address indexed seller
    );

    event Unlisted(
        uint indexed id
    );
  
    struct Listing{
        address owner;       // who owns the listed artifact
        uint256 buyoutPrice; // price of the artifact in xdai
    }
    mapping(uint256 => Listing) public listings; // all listings 
    IERC721 immutable DFTokens; 
        
    constructor(address tokensAddress){
        DFTokens = IERC721(tokensAddress);  
    }

    // sendValue from openZeppelin Address library https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol
    function sendValue(address payable recipient, uint amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");
        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    function list(uint256 tokenID, uint256 price) external  {
        
        listings[tokenID] = Listing({
            owner: msg.sender,
            buyoutPrice: price
        });

        DFTokens.transferFrom(msg.sender, address(this), tokenID);
        emit Listed(tokenID,price,msg.sender);
    }

    // buying function. User input is the price they pay
    function buy(uint256 tokenID) external payable  {
        Listing memory oldListing = listings[tokenID];
        delete listings[tokenID];
        require (msg.value == oldListing.buyoutPrice, "wrong value");
        DFTokens.transferFrom(address(this), msg.sender, tokenID);
        sendValue(payable(oldListing.owner), oldListing.buyoutPrice);
        emit Sale(tokenID,msg.sender);
    }
    
    // Unlist a token you listed
    // Useful if you want your tokens back
    function unlist (uint256 id) external {
        address holder = listings[id].owner;
        require(msg.sender == holder);
        delete listings[id];
        DFTokens.transferFrom(address(this), holder, id);
        emit Unlisted(id);
    }

}

        

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"tokensAddress","internalType":"address"}]},{"type":"event","name":"Listed","inputs":[{"type":"uint256","name":"id","internalType":"uint256","indexed":true},{"type":"uint256","name":"price","internalType":"uint256","indexed":true},{"type":"address","name":"seller","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Sale","inputs":[{"type":"uint256","name":"id","internalType":"uint256","indexed":true},{"type":"address","name":"buyer","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Unlisted","inputs":[{"type":"uint256","name":"id","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"payable","outputs":[],"name":"buy","inputs":[{"type":"uint256","name":"tokenID","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"list","inputs":[{"type":"uint256","name":"tokenID","internalType":"uint256"},{"type":"uint256","name":"price","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"buyoutPrice","internalType":"uint256"}],"name":"listings","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unlist","inputs":[{"type":"uint256","name":"id","internalType":"uint256"}]}]
              

Contract Creation Code

0x60a060405234801561001057600080fd5b506040516107d43803806107d483398101604081905261002f91610044565b60601b6001600160601b031916608052610074565b60006020828403121561005657600080fd5b81516001600160a01b038116811461006d57600080fd5b9392505050565b60805160601c6107346100a0600039600081816101c00152818161030c01526104b001526107346000f3fe60806040526004361061003f5760003560e01c806350fd736714610044578063bf5a4dd314610066578063d96a094a14610086578063de74e57b14610099575b600080fd5b34801561005057600080fd5b5061006461005f3660046106dc565b610116565b005b34801561007257600080fd5b506100646100813660046106c3565b61024f565b6100646100943660046106c3565b610397565b3480156100a557600080fd5b506100e66100b43660046106c3565b6000602081905290815260409020805460019091015473ffffffffffffffffffffffffffffffffffffffff9091169082565b6040805173ffffffffffffffffffffffffffffffffffffffff909316835260208301919091520160405180910390f35b60408051808201825233808252602080830185815260008781529182905290849020925183547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff918216178455905160019093019290925591517f23b872dd0000000000000000000000000000000000000000000000000000000081526004810192909252306024830152604482018490527f000000000000000000000000000000000000000000000000000000000000000016906323b872dd90606401600060405180830381600087803b15801561020457600080fd5b505af1158015610218573d6000803e3d6000fd5b505060405133925083915084907fb4e5606a376800f822ae7ce93010dddb4ebd38ca6db1bdbc2d0a1de90c9079e490600090a45050565b60008181526020819052604090205473ffffffffffffffffffffffffffffffffffffffff1633811461028057600080fd5b60008281526020819052604080822080547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560010191909155517f23b872dd00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8281166024830152604482018490527f000000000000000000000000000000000000000000000000000000000000000016906323b872dd90606401600060405180830381600087803b15801561035057600080fd5b505af1158015610364573d6000803e3d6000fd5b50506040518492507f6318005f6dc5a71d3e4ad5b4d1fe455ef3402d62b64573777af55bb6bfe3daab9150600090a25050565b6000818152602081815260408083208151808301909252805473ffffffffffffffffffffffffffffffffffffffff81168352600182018054848601908152878752948690527fffffffffffffffffffffffff000000000000000000000000000000000000000090911690915592909255513414610475576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f77726f6e672076616c756500000000000000000000000000000000000000000060448201526064015b60405180910390fd5b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152306004820152336024820152604481018390527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906323b872dd90606401600060405180830381600087803b15801561050957600080fd5b505af115801561051d573d6000803e3d6000fd5b5050505061053381600001518260200151610564565b604051339083907f938e870e870a8d47d06b8bbd499d54ea37fb4f7777de1ff086d6d71e1fa1599690600090a35050565b804710156105ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161046c565b60008273ffffffffffffffffffffffffffffffffffffffff168260405160006040518083038185875af1925050503d8060008114610628576040519150601f19603f3d011682016040523d82523d6000602084013e61062d565b606091505b50509050806106be576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161046c565b505050565b6000602082840312156106d557600080fd5b5035919050565b600080604083850312156106ef57600080fd5b5050803592602090910135915056fea2646970667358221220bfda9f8e28f6e0bdaf906f51bef910b0b6e0dde6391639c2688a92afd943b8f964736f6c634300080700330000000000000000000000008e7fc9c67cf2bc5d001682d17355dc5c7f41e4c1

Deployed ByteCode

0x60806040526004361061003f5760003560e01c806350fd736714610044578063bf5a4dd314610066578063d96a094a14610086578063de74e57b14610099575b600080fd5b34801561005057600080fd5b5061006461005f3660046106dc565b610116565b005b34801561007257600080fd5b506100646100813660046106c3565b61024f565b6100646100943660046106c3565b610397565b3480156100a557600080fd5b506100e66100b43660046106c3565b6000602081905290815260409020805460019091015473ffffffffffffffffffffffffffffffffffffffff9091169082565b6040805173ffffffffffffffffffffffffffffffffffffffff909316835260208301919091520160405180910390f35b60408051808201825233808252602080830185815260008781529182905290849020925183547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff918216178455905160019093019290925591517f23b872dd0000000000000000000000000000000000000000000000000000000081526004810192909252306024830152604482018490527f0000000000000000000000008e7fc9c67cf2bc5d001682d17355dc5c7f41e4c116906323b872dd90606401600060405180830381600087803b15801561020457600080fd5b505af1158015610218573d6000803e3d6000fd5b505060405133925083915084907fb4e5606a376800f822ae7ce93010dddb4ebd38ca6db1bdbc2d0a1de90c9079e490600090a45050565b60008181526020819052604090205473ffffffffffffffffffffffffffffffffffffffff1633811461028057600080fd5b60008281526020819052604080822080547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560010191909155517f23b872dd00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8281166024830152604482018490527f0000000000000000000000008e7fc9c67cf2bc5d001682d17355dc5c7f41e4c116906323b872dd90606401600060405180830381600087803b15801561035057600080fd5b505af1158015610364573d6000803e3d6000fd5b50506040518492507f6318005f6dc5a71d3e4ad5b4d1fe455ef3402d62b64573777af55bb6bfe3daab9150600090a25050565b6000818152602081815260408083208151808301909252805473ffffffffffffffffffffffffffffffffffffffff81168352600182018054848601908152878752948690527fffffffffffffffffffffffff000000000000000000000000000000000000000090911690915592909255513414610475576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f77726f6e672076616c756500000000000000000000000000000000000000000060448201526064015b60405180910390fd5b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152306004820152336024820152604481018390527f0000000000000000000000008e7fc9c67cf2bc5d001682d17355dc5c7f41e4c173ffffffffffffffffffffffffffffffffffffffff16906323b872dd90606401600060405180830381600087803b15801561050957600080fd5b505af115801561051d573d6000803e3d6000fd5b5050505061053381600001518260200151610564565b604051339083907f938e870e870a8d47d06b8bbd499d54ea37fb4f7777de1ff086d6d71e1fa1599690600090a35050565b804710156105ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161046c565b60008273ffffffffffffffffffffffffffffffffffffffff168260405160006040518083038185875af1925050503d8060008114610628576040519150601f19603f3d011682016040523d82523d6000602084013e61062d565b606091505b50509050806106be576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161046c565b505050565b6000602082840312156106d557600080fd5b5035919050565b600080604083850312156106ef57600080fd5b5050803592602090910135915056fea2646970667358221220bfda9f8e28f6e0bdaf906f51bef910b0b6e0dde6391639c2688a92afd943b8f964736f6c63430008070033