Skip to content

Instantly share code, notes, and snippets.

@sherlock-shi-x
Created February 15, 2018 04:38
Show Gist options
  • Save sherlock-shi-x/96d94e9796a68310e68ea553f2c383c8 to your computer and use it in GitHub Desktop.
Save sherlock-shi-x/96d94e9796a68310e68ea553f2c383c8 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.18;
contract RegData {
mapping (uint256 => address) private itemOwner;
mapping (uint256 => uint256) private itemPrice;
address private owner;
mapping (address => bool) private admins;
// Modifiers
modifier onlyOwner() {
require(owner == msg.sender);
_;
}
modifier onlyAdmin() {
require(admins[msg.sender]);
_;
}
function RegData() public {
owner = msg.sender;
admins[owner] = true;
}
function addAdmins(address _addr) public onlyOwner() {
admins[_addr] = true;
}
function addAddress(uint256[] _itemId, address[] _addr, uint256[] _price) public onlyAdmin() {
require(_itemId.length == _addr.length);
require(_itemId.length == _price.length);
for (uint256 i = 0; i < _itemId.length; i++) {
itemOwner[_itemId[i]] = _addr[i];
itemPrice[_itemId[i]] = _price[i];
}
}
// OnlyRead
function isAdmin(address _addr) public view returns(bool _isAdmin) {
return admins[_addr];
}
// Query Interface Function
function itemsForSaleLimit (uint256 _from, uint256 _take) public view returns (uint256[] _items) {
}
function ownerOf (uint256 _itemId) public view returns (address _owner) {
return itemOwner[_itemId];
}
function priceOf (uint256 _itemId) public view returns (uint256 _price) {
return itemPrice[_itemId];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment