Skip to content

Instantly share code, notes, and snippets.


innovator256/Dappserytemp.sol Secret

Last active Dec 17, 2015
What would you like to do?
newest not library/db based database dappsery api
contract DappseryTest {
mapping (address => DappseryUser) public registeredUsers;
//for internal use construction only
mapping(bytes32 => bytes32) private categories;
//public indexes
mapping(bytes32 => uint) public userCategories;
mapping(uint => address) public featuredUsers;
//users index
uint public userIndex;
function DappseryTest(){
categories["Dapps"] = "Dapps";
categories["All Things Apple"] = "All Things Apple";
categories["Automotive"] = "Automotive";
categories["Beauty & Fashion"] = "Beauty & Fashion";
categories["Business & Finance"] = "Business & Finance";
categories["Cryptocurrency"] = "Cryptocurrency";
categories["Education"] = "Education";
categories["Entertainment"] = "Entertainment";
categories["Family & Parenting"] = "Family & Parenting";
categories["Food & Drink"] = "Food & Drink";
categories["Gaming"] = "Gaming";
categories["Goverment & Politics"] = "Goverment & Politics";
categories["Health & Fitness"] = "Health & Fitness";
categories["Home & Architecture"] = "Home & Architecture";
categories["Pets"] = "Pets";
categories["Podcasts"] = "Podcasts";
categories["Sports"] = "Sports";
categories["Technology"] = "Technology";
categories["Travel"] = "Travel";
categories["Virtualization"] = "Virtualization";
categories["Visual Arts & Design"] = "Visual Arts & Design";
categories["Web Design & Development"] = "Web Design & Development";
struct DappseryUser{
bytes32 userType; //publisher advertiser or quality assuarance team
bytes32 name; // name
address userAdr; //user ethereum address identifier
uint uID; //userid number (incremented unique id)
bytes32 token; // sha3 hash of Name & passphrase clientside encryption
bytes32 webUrl; // Website
bytes32 logoUrl; //logo url or photo id url
bytes32 category; //category
bool isFeatured;
//id, userType, date(block.timestamp), blocknumber,
event UserIndex(uint _UId, bytes32 _userType, uint _date, uint _blockNumber);
//id, category, usertype, date(block.timestamp)
event Category(uint _UId, bytes32 _catType, uint _date);
event Featured(uint _UId, bytes32 _catType, uint _date);
//pubId, adID, date(block.timestamp)
event AdIndex(uint _adId, uint _UId, uint _date);
//id, userType
event PublisherIndex();
//id, userType
event AdvertiserIndex();
//id, userType
event QaIndex();
modifier isExist(address newUserAdr) { if (newUserAdr == registeredUsers[newUserAdr].userAdr)
function regPublisher(bytes32 _newUserType,
bytes32 _newName,
address _newUserAdr,
bytes32 _token,
bytes32 _webUrl,
bytes32 _logoUrl,
bytes32 _category) isExist( _newUserAdr) returns (bool success){
if(categories[_category] == _category){
DappseryUser account = registeredUsers[_newUserAdr];
account.userType = _newUserType; = _newName;
account.userAdr = _newUserAdr;
account.uID = userIndex;
account.token = sha3(_token);
account.webUrl = _webUrl;
account.logoUrl = _logoUrl;
account.category = categories[_category];
userCategories[account.category] = account.uID;
//modify and figure out conditions for being featured by quality assurance later
featuredUsers[account.uID] = _newUserAdr;
if (account.userAdr == featuredUsers[account.uID]){
account.isFeatured = true;
return true;
return false;
function eventer(DappseryUser _account) private {
//General acount & category log
UserIndex(_account.uID, _account.userType, now, block.number);
//id, category, usertype, date(block.timestamp)
Category(_account.uID, _account.category, now);
//some conditional filter in order to log featured user// to be improved later
if(_account.userAdr == featuredUsers[_account.uID]){
Featured(_account.uID, _account.category, now);
function getUser(address _adr) constant public returns (
bytes32 uname,
bytes32 uType,
bytes32 uwebUrl,
bytes32 ulogoUrl,
bytes32 ucategory,
bool ufeauturedStatus
DappseryUser account = registeredUsers[_adr];
uname =;
uType = account.userType;
uwebUrl = account.webUrl;
ulogoUrl = account.logoUrl;
ucategory = account.category;
ufeauturedStatus = account.isFeatured;
function updateProfile(address _adr,
bytes32 _token,
bytes32 _userType,
bytes32 _name,
address _userAdr,
bytes32 _webUrl,
bytes32 _logoUrl,
bytes32 _category) returns (bool success){
DappseryUser account = registeredUsers[_adr];
if(account.token == sha3(_token)){ = _name;
account.userType = _userType;
account.userAdr = _userAdr;
account.webUrl = _webUrl;
account.logoUrl = _logoUrl;
account.category = categories[_category];
return true;
return false;
function listAd() public returns (string message){
message = "TBD not yet";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment