Contract Address Details
contract

0xdCc1dD0BC399fbd6c8b9Fbe5d2c5AF998C66d6ed

Contract Name
Etherboard
Creator
0x88a80d–7fcc6e at 0x4718bc–67344f
Balance
19.61640625 xDAI ( )
Tokens
Fetching tokens...
Transactions
56 Transactions
Transfers
0 Transfers
Gas Used
7,964,572
Last Balance Update
22193013
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
Etherboard




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




Optimization runs
200
EVM Version
london




Verified at
2022-03-06 22:32:01.865575Z

contracts/etherboard.sol

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

contract Etherboard {

    // @dev Data model for every slot without owner.
    struct Slot {
        string img;
        string caption;
        string link;
        uint   minSalePrice;
        uint   totalSales;
    }

    mapping (uint    => Slot)    private slots;
    // @dev In some cases, we need to check only the owner of the slot.
    // Slot owners are stored separately to avoid retrieving the whole slot
    // to make ownership checks.
    mapping (uint256 => address) public  slotOwners;
    mapping (address => bool)    private managerLookup;
    mapping (address => uint256) private managerBalances;

    address[]      managers;
    uint256 public firstMinSalePrice;
    uint256 public numOfSlots = 10;
    uint256 public commissionPercent = 20;
    uint256 public autoPriceIncreasePercent = 50;
    bool    public pricesAreLocked = false;

    function isManager(address _address)
    public view returns (bool) {
        return managerLookup[_address];
    }

    modifier onlyManagers() {
        require(
            isManager(msg.sender) == true,
            "Only managers can run this operation."
        ); _;
    }

    modifier onlyNonManagers() {
        require(
            isManager(msg.sender) == false,
            "Managers can not run this operation."
        ); _;
    }

    modifier onlySlotOwnerOrManager(uint256 index) {
        require(
            slotOwners[index] == msg.sender || isManager(msg.sender) == true,
            "Only owner of the slot can run this operation."
        ); _;
    }

    function setFirstMinSalePrice(
        uint _firstMinSalePrice
    ) public payable onlyManagers {
        firstMinSalePrice = _firstMinSalePrice;
    }

    function setCommissionPercent(
        uint _commissionPercent
    ) public payable onlyManagers {
         commissionPercent = _commissionPercent;
    }

    function setAutoPriceIncreasePercent(
        uint _autoPriceIncreasePercent
    ) public payable onlyManagers {
         autoPriceIncreasePercent = _autoPriceIncreasePercent;
    }

    function setPricesAreLocked(
        bool _pricesAreLocked
    ) public payable onlyManagers {
        pricesAreLocked = _pricesAreLocked;
    }

    // TODO: private or internal?
    function shareManagerProfits(
        uint256 totalProfit
    ) private {
        uint256 share = totalProfit / managers.length;
        for(uint i = 0; i < managers.length; i++){
            address manager = managers[i];
            managerBalances[manager] += share;
        }
    }

    // Function that allow managers to withdraw their money.
    function managerWithdraw() public onlyManagers {
        uint256 balance = managerBalances[msg.sender];
        require(balance > 0, "You don't have any balance to withdraw.");
        payable(msg.sender).transfer(balance);
    }

    function getManagerBalance(address _manager)
    public view onlyManagers returns (uint256 balance) {
        return managerBalances[_manager];
    }

    constructor(
        uint             _firstMinSalePrice,
        address[] memory _managers
    ) payable {
        for(uint i = 0; i < _managers.length; i++){
            address manager = _managers[i];
            managers.push(manager);
            managerLookup[manager] = true;
        }
        firstMinSalePrice = _firstMinSalePrice;
    }

    function getSlot(uint256 index)
    public view returns (
        string memory caption,
        string memory link,
        string memory img,
        uint256 minSalePrice,
        uint256 totalSales
    ) {
        Slot storage slot  = slots[index];
        return (
            slot.caption,
            slot.link,
            slot.img,
            slot.totalSales > 0 ? slot.minSalePrice : firstMinSalePrice,
            slot.totalSales
        );
    }

    function processPayment(
        uint256       index,
        string memory caption,
        string memory link,
        string memory img
    ) public payable onlyNonManagers {

        // TODO: Why this??
        require(msg.sender != address(0), "Invalid address for operation");
        require(index <= numOfSlots, "Invalid slot index.");

        Slot storage slot  = slots[index];
        uint256 buyerPrice = msg.value;
        uint256 slotPrice  = slot.totalSales == 0 ? firstMinSalePrice : slot.minSalePrice;
        require(buyerPrice >= slotPrice, "Insufficient fund");

        uint newMinSalePrice = buyerPrice + (buyerPrice * autoPriceIncreasePercent / 100);
        address slotOwner    = slotOwners[index];

        if(slotOwner == address(0)) { // First sale.
            shareManagerProfits(buyerPrice);
            if (index >= numOfSlots) {numOfSlots = index + 1;}
        } else {
            uint managersProfit = buyerPrice * commissionPercent / 100;
            uint ownerProfit    = buyerPrice - managersProfit;
            shareManagerProfits(managersProfit);
            payable(slotOwners[index]).transfer(ownerProfit);
        }
        slotOwners[index] = msg.sender;
        slot.minSalePrice = newMinSalePrice;
        slot.img          = img;
        slot.caption      = caption;
        slot.link         = link;
        slot.totalSales  += 1;
    }

    function setSlotProperties(
        uint256 index,
        string memory caption,
        string memory link,
        string memory img,
        uint   minSalePrice
    ) public onlySlotOwnerOrManager(index) {
        Slot storage slot = slots[index];
        if (pricesAreLocked) {
            require(
                slot.minSalePrice == minSalePrice,
                "Slot price must be same as before."
            );
        }
        slot.img = img;
        slot.caption = caption;
        slot.link = link;
        slot.minSalePrice = minSalePrice;
    }
}
        

Contract ABI

[{"type":"constructor","stateMutability":"payable","inputs":[{"type":"uint256","name":"_firstMinSalePrice","internalType":"uint256"},{"type":"address[]","name":"_managers","internalType":"address[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"autoPriceIncreasePercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"commissionPercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"firstMinSalePrice","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"balance","internalType":"uint256"}],"name":"getManagerBalance","inputs":[{"type":"address","name":"_manager","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"caption","internalType":"string"},{"type":"string","name":"link","internalType":"string"},{"type":"string","name":"img","internalType":"string"},{"type":"uint256","name":"minSalePrice","internalType":"uint256"},{"type":"uint256","name":"totalSales","internalType":"uint256"}],"name":"getSlot","inputs":[{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isManager","inputs":[{"type":"address","name":"_address","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"managerWithdraw","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"numOfSlots","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"pricesAreLocked","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"processPayment","inputs":[{"type":"uint256","name":"index","internalType":"uint256"},{"type":"string","name":"caption","internalType":"string"},{"type":"string","name":"link","internalType":"string"},{"type":"string","name":"img","internalType":"string"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"setAutoPriceIncreasePercent","inputs":[{"type":"uint256","name":"_autoPriceIncreasePercent","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"setCommissionPercent","inputs":[{"type":"uint256","name":"_commissionPercent","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"setFirstMinSalePrice","inputs":[{"type":"uint256","name":"_firstMinSalePrice","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"setPricesAreLocked","inputs":[{"type":"bool","name":"_pricesAreLocked","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSlotProperties","inputs":[{"type":"uint256","name":"index","internalType":"uint256"},{"type":"string","name":"caption","internalType":"string"},{"type":"string","name":"link","internalType":"string"},{"type":"string","name":"img","internalType":"string"},{"type":"uint256","name":"minSalePrice","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"slotOwners","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]}]
            

Deployed ByteCode

0x6080604052600436106100f35760003560e01c806377d3550b1161008a578063b4f5b37f11610059578063b4f5b37f14610237578063ce16097e1461024a578063ddc963c514610298578063f3ae2415146102c257600080fd5b806377d3550b146101bd5780637eba7ba6146101d357806390a9f3ea14610204578063969ec5181461022457600080fd5b8063404a9ab8116100c6578063404a9ab814610161578063442f8dd0146101745780634894d533146101875780634e39bcf4146101a757600080fd5b8063066de3e3146100f857806315e16a181461010f57806319cfc36a146101385780633c2240ff1461014b575b600080fd5b34801561010457600080fd5b5061010d6102e2565b005b34801561011b57600080fd5b5061012560085481565b6040519081526020015b60405180910390f35b61010d610146366004610d29565b6103b3565b34801561015757600080fd5b5061012560065481565b61010d61016f366004610d10565b61068e565b61010d610182366004610d10565b6106bd565b34801561019357600080fd5b5061010d6101a2366004610dbb565b6106ec565b3480156101b357600080fd5b5061012560055481565b3480156101c957600080fd5b5061012560075481565b3480156101df57600080fd5b506101f36101ee366004610d10565b610844565b60405161012f959493929190610ea2565b34801561021057600080fd5b5061012561021f366004610cbe565b610a3c565b61010d610232366004610d10565b610a84565b61010d610245366004610cee565b610ab3565b34801561025657600080fd5b50610280610265366004610d10565b6001602052600090815260409020546001600160a01b031681565b6040516001600160a01b03909116815260200161012f565b3480156102a457600080fd5b506009546102b29060ff1681565b604051901515815260200161012f565b3480156102ce57600080fd5b506102b26102dd366004610cbe565b610af0565b6102eb33610af0565b15156001146103155760405162461bcd60e51b815260040161030c90610ef0565b60405180910390fd5b33600090815260036020526040902054806103825760405162461bcd60e51b815260206004820152602760248201527f596f7520646f6e2774206861766520616e792062616c616e636520746f2077696044820152663a34323930bb9760c91b606482015260840161030c565b604051339082156108fc029083906000818181858888f193505050501580156103af573d6000803e3d6000fd5b5050565b6103bc33610af0565b156104155760405162461bcd60e51b8152602060048201526024808201527f4d616e61676572732063616e206e6f742072756e2074686973206f706572617460448201526334b7b71760e11b606482015260840161030c565b336104625760405162461bcd60e51b815260206004820152601d60248201527f496e76616c6964206164647265737320666f72206f7065726174696f6e000000604482015260640161030c565b6006548411156104aa5760405162461bcd60e51b815260206004820152601360248201527224b73b30b634b21039b637ba1034b73232bc1760691b604482015260640161030c565b6000848152602081905260408120600481015490913491156104d05782600301546104d4565b6005545b90508082101561051a5760405162461bcd60e51b8152602060048201526011602482015270125b9cdd59999a58da595b9d08199d5b99607a1b604482015260640161030c565b600060646008548461052c9190610f6f565b6105369190610f4d565b6105409084610f35565b6000898152600160205260409020549091506001600160a01b0316806105865761056984610b0e565b60065489106105815761057d896001610f35565b6006555b610603565b60006064600754866105989190610f6f565b6105a29190610f4d565b905060006105b08287610f8e565b90506105bb82610b0e565b60008b8152600160205260408082205490516001600160a01b039091169183156108fc02918491818181858888f193505050501580156105ff573d6000803e3d6000fd5b5050505b600089815260016020908152604090912080546001600160a01b0319163317905560038601839055865161063c91879190890190610b98565b50875161065290600187019060208b0190610b98565b50865161066890600287019060208a0190610b98565b50600185600401600082825461067e9190610f35565b9091555050505050505050505050565b61069733610af0565b15156001146106b85760405162461bcd60e51b815260040161030c90610ef0565b600755565b6106c633610af0565b15156001146106e75760405162461bcd60e51b815260040161030c90610ef0565b600555565b60008581526001602052604090205485906001600160a01b031633148061071d575061071733610af0565b15156001145b6107805760405162461bcd60e51b815260206004820152602e60248201527f4f6e6c79206f776e6572206f662074686520736c6f742063616e2072756e207460448201526d3434b99037b832b930ba34b7b71760911b606482015260840161030c565b600086815260208190526040902060095460ff16156107f757828160030154146107f75760405162461bcd60e51b815260206004820152602260248201527f536c6f74207072696365206d7573742062652073616d65206173206265666f72604482015261329760f11b606482015260840161030c565b83516108099082906020870190610b98565b50855161081f9060018301906020890190610b98565b5084516108359060028301906020880190610b98565b50600301919091555050505050565b60008181526020819052604081206004810154606092839283928291906001820190600283019083906108795760055461087f565b83600301545b846004015484805461089090610fa5565b80601f01602080910402602001604051908101604052809291908181526020018280546108bc90610fa5565b80156109095780601f106108de57610100808354040283529160200191610909565b820191906000526020600020905b8154815290600101906020018083116108ec57829003601f168201915b5050505050945083805461091c90610fa5565b80601f016020809104026020016040519081016040528092919081815260200182805461094890610fa5565b80156109955780601f1061096a57610100808354040283529160200191610995565b820191906000526020600020905b81548152906001019060200180831161097857829003601f168201915b505050505093508280546109a890610fa5565b80601f01602080910402602001604051908101604052809291908181526020018280546109d490610fa5565b8015610a215780601f106109f657610100808354040283529160200191610a21565b820191906000526020600020905b815481529060010190602001808311610a0457829003601f168201915b50505050509250955095509550955095505091939590929450565b6000610a4733610af0565b1515600114610a685760405162461bcd60e51b815260040161030c90610ef0565b506001600160a01b031660009081526003602052604090205490565b610a8d33610af0565b1515600114610aae5760405162461bcd60e51b815260040161030c90610ef0565b600855565b610abc33610af0565b1515600114610add5760405162461bcd60e51b815260040161030c90610ef0565b6009805460ff1916911515919091179055565b6001600160a01b031660009081526002602052604090205460ff1690565b600454600090610b1e9083610f4d565b905060005b600454811015610b9357600060048281548110610b4257610b42611011565b60009182526020808320909101546001600160a01b0316808352600390915260408220805491935085929091610b79908490610f35565b90915550829150610b8b905081610fe0565b915050610b23565b505050565b828054610ba490610fa5565b90600052602060002090601f016020900481019282610bc65760008555610c0c565b82601f10610bdf57805160ff1916838001178555610c0c565b82800160010185558215610c0c579182015b82811115610c0c578251825591602001919060010190610bf1565b50610c18929150610c1c565b5090565b5b80821115610c185760008155600101610c1d565b600082601f830112610c4257600080fd5b813567ffffffffffffffff80821115610c5d57610c5d611027565b604051601f8301601f19908116603f01168101908282118183101715610c8557610c85611027565b81604052838152866020858801011115610c9e57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215610cd057600080fd5b81356001600160a01b0381168114610ce757600080fd5b9392505050565b600060208284031215610d0057600080fd5b81358015158114610ce757600080fd5b600060208284031215610d2257600080fd5b5035919050565b60008060008060808587031215610d3f57600080fd5b84359350602085013567ffffffffffffffff80821115610d5e57600080fd5b610d6a88838901610c31565b94506040870135915080821115610d8057600080fd5b610d8c88838901610c31565b93506060870135915080821115610da257600080fd5b50610daf87828801610c31565b91505092959194509250565b600080600080600060a08688031215610dd357600080fd5b85359450602086013567ffffffffffffffff80821115610df257600080fd5b610dfe89838a01610c31565b95506040880135915080821115610e1457600080fd5b610e2089838a01610c31565b94506060880135915080821115610e3657600080fd5b50610e4388828901610c31565b95989497509295608001359392505050565b6000815180845260005b81811015610e7b57602081850181015186830182015201610e5f565b81811115610e8d576000602083870101525b50601f01601f19169290920160200192915050565b60a081526000610eb560a0830188610e55565b8281036020840152610ec78188610e55565b90508281036040840152610edb8187610e55565b60608401959095525050608001529392505050565b60208082526025908201527f4f6e6c79206d616e61676572732063616e2072756e2074686973206f706572616040820152643a34b7b71760d91b606082015260800190565b60008219821115610f4857610f48610ffb565b500190565b600082610f6a57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615610f8957610f89610ffb565b500290565b600082821015610fa057610fa0610ffb565b500390565b600181811c90821680610fb957607f821691505b60208210811415610fda57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415610ff457610ff4610ffb565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220325e6eae5c7d93327fe7edb508c374f2b9e919bf5f9b68891d2637dfde8e76a864736f6c63430008070033