├── .gitignore ├── README.md ├── eosioshadows-logo.jpg ├── eosioshadows-logo.png ├── eosioshadows.abi ├── eosioshadows.cpp ├── eosioshadows.wasm ├── eosioshadows.wast ├── idice-logo.jpg └── idice-logo.png /.gitignore: -------------------------------------------------------------------------------- 1 | /shadows-logo.jpg 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 简影游戏平台 2 | 简影致力于打造基于EOS的游戏平台,你在这里既是玩家也是我们的合作人,让结局不留遗憾,让过程更加完美。 3 | 4 | 5 | ## 智能合约 6 | 7 | 合约账号:eosioshadows 8 | 9 | 网站地址:https://eosbao.io 10 | 11 | 合约地址:https://eospark.com/MainNet/contract/eosioshadows 12 | 13 | 开源代码:https://github.com/eosioshadows/eos-shadows 14 | 15 | 16 | ## 游戏规则 17 | 18 | #### Bancor算法销售 19 | * 我们的KEY与EOS的RAM一样,使用Bancor算法销售和回收KEY,按当前资金储备中EOS数量定价,越早购买的KEY越便宜,购买KEY的玩家越多,价格越呈指数级增长,也可以随时卖出KEY。 20 | 21 | #### 倒计时发布新游戏 22 | * 新游戏分红是以买入KEY的形式回馈给持KEY玩家,无论当时KEY价多少,新游戏合约里50%利润自动转入当前合约买进KEY。团队不保证每个新游戏绝对盈利,请根据风险理性投资。 23 | 24 | #### 多级推荐奖励 25 | * 任何一位玩家购买KEY,都会向上2级贡献总资金5%的利润,然后再按80%、20%的比例划分给2个上级,直接上级功劳最大获得80%。真正意义上实现任何人都可以作为顶级推荐人享受下级的红利,每个人都有机会站在金字塔顶端。 26 | 27 | #### 分红奖池 28 | * 每KEY销售的20%给所有已持KEY用户按持KEY比例分红,每30分钟分红一次,分红自动进入“我的利润”,可随时提现。 29 | * `用户分红=持KEY数量/总售出KEY*分红奖池` 30 | 31 | #### 权重奖池 32 | * 玩家持KEY权重大于等于7时,再买入1EOS数量的KEY即可获得权重奖励,权重奖励最大不超过权重奖池的10%。获得权重奖励后权重归零,秉承先买先得原则,分完为止。注意:买入的每个EOS增加我的权重60秒,卖出KEY我的权重会归零。 33 | 34 | * `权重奖励=持KEY数量/总售出KEY * 权重奖池 * 我的权重/7` 35 | 36 | #### 奖励分配 37 | * 资金储备:每KEY销售的50%进入资金储备用Bancor对KEY定价 38 | 39 | * 推荐奖励:每KEY销售的5%贡献给2个上级推广人 40 | 41 | * 权重奖池:每KEY销售的15%累计权重奖池 42 | 43 | * 研发消耗:每KEY销售的10%用作团队研发手续费及资源消耗 44 | 45 | * 分红奖池:每KEY销售的20%进入分红奖池,每30分钟按持KEY比例分红 46 | 47 | ## 特别提示 48 | 49 | * 固定数量:100万KEY,永不增发 50 | 51 | * 购买限额:购买EOS数量必须>=1EOS且<=10万EOS 52 | 53 | * 提取限额:提取利润必须至少大于等于0.1EOS 54 | 55 | * 资金储备:为玩家卖出KEY预留的资金,研发团队无法动用 56 | 57 | * 系统底仓:初始底仓1万EOS的KEY,用作Bancor定价,不能交易 58 | 59 | * 权重奖池:买入的每个EOS增加我的权重60秒,卖出KEY我的权重会归零 60 | 61 | * 推荐账号:如果玩家不输入推荐人账号或推荐人不存在,则默认推荐人为研发团队账号,请不要让我们赚这笔钱 62 | -------------------------------------------------------------------------------- /eosioshadows-logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eosioshadows/eos-shadows/54d90bc80387ddb789a1cd4f42fce4a751356422/eosioshadows-logo.jpg -------------------------------------------------------------------------------- /eosioshadows-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eosioshadows/eos-shadows/54d90bc80387ddb789a1cd4f42fce4a751356422/eosioshadows-logo.png -------------------------------------------------------------------------------- /eosioshadows.abi: -------------------------------------------------------------------------------- 1 | { 2 | "____comment": "This file was generated by eosio-abigen. DO NOT EDIT - 2018-08-21T12:54:18", 3 | "version": "eosio::abi/1.0", 4 | "types": [], 5 | "structs": [{ 6 | "name": "game", 7 | "base": "", 8 | "fields": [{ 9 | "name": "i", 10 | "type": "uint64" 11 | },{ 12 | "name": "k", 13 | "type": "uint64" 14 | },{ 15 | "name": "e", 16 | "type": "uint64" 17 | },{ 18 | "name": "f", 19 | "type": "uint64" 20 | },{ 21 | "name": "w", 22 | "type": "uint64" 23 | },{ 24 | "name": "r", 25 | "type": "uint64" 26 | },{ 27 | "name": "d", 28 | "type": "uint64" 29 | } 30 | ] 31 | },{ 32 | "name": "user", 33 | "base": "", 34 | "fields": [{ 35 | "name": "n", 36 | "type": "name" 37 | },{ 38 | "name": "r", 39 | "type": "name" 40 | },{ 41 | "name": "e", 42 | "type": "uint64" 43 | },{ 44 | "name": "k", 45 | "type": "uint64" 46 | },{ 47 | "name": "p", 48 | "type": "int64" 49 | },{ 50 | "name": "t", 51 | "type": "uint64" 52 | } 53 | ] 54 | },{ 55 | "name": "bonus", 56 | "base": "", 57 | "fields": [{ 58 | "name": "i", 59 | "type": "uint64" 60 | },{ 61 | "name": "n", 62 | "type": "name" 63 | } 64 | ] 65 | },{ 66 | "name": "sell", 67 | "base": "", 68 | "fields": [{ 69 | "name": "from", 70 | "type": "name" 71 | },{ 72 | "name": "quantity", 73 | "type": "asset" 74 | } 75 | ] 76 | },{ 77 | "name": "jackpot", 78 | "base": "", 79 | "fields": [] 80 | } 81 | ], 82 | "actions": [{ 83 | "name": "sell", 84 | "type": "sell", 85 | "ricardian_contract": "" 86 | },{ 87 | "name": "jackpot", 88 | "type": "jackpot", 89 | "ricardian_contract": "" 90 | } 91 | ], 92 | "tables": [{ 93 | "name": "games", 94 | "index_type": "i64", 95 | "key_names": [ 96 | "i" 97 | ], 98 | "key_types": [ 99 | "uint64" 100 | ], 101 | "type": "game" 102 | },{ 103 | "name": "users", 104 | "index_type": "i64", 105 | "key_names": [ 106 | "n" 107 | ], 108 | "key_types": [ 109 | "name" 110 | ], 111 | "type": "user" 112 | },{ 113 | "name": "bonuses", 114 | "index_type": "i64", 115 | "key_names": [ 116 | "i" 117 | ], 118 | "key_types": [ 119 | "uint64" 120 | ], 121 | "type": "bonus" 122 | } 123 | ], 124 | "ricardian_clauses": [], 125 | "error_messages": [], 126 | "abi_extensions": [] 127 | } -------------------------------------------------------------------------------- /eosioshadows.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using eosio::indexed_by; 6 | using eosio::const_mem_fun; 7 | using eosio::asset; 8 | using eosio::permission_level; 9 | using eosio::action; 10 | using eosio::print; 11 | using eosio::name; 12 | using std::string; 13 | using eosio::name; 14 | using eosio::string_to_name; 15 | 16 | class eosioshadows : public eosio::contract { 17 | 18 | const uint64_t INIT_BATCH = 100; // 每次分红处理人数 19 | const uint64_t INIT_WEIGHT = 7*24*60*60; // 权重奖池领取时间(7天) 20 | const uint64_t INIT_TIME = 1534075688; // 2018-08-12 20:08:08 启动游戏 21 | const uint64_t INIT_EOS = 100000000.0;//底仓股份1万,用于bancor定价,不能交易 22 | const uint64_t INIT_KEY = 10000000000.0;//总股本100万 23 | const std::string TEAM_ACCOUNT = "eosiodrizzle";//研发团队账号 24 | 25 | public: 26 | eosioshadows(account_name self):eosio::contract(self),users(_self, _self),games(_self, _self),bonuses(_self, _self){} 27 | 28 | void transfer( account_name from, account_name to, asset quantity, std::string memo ) { 29 | 30 | require_auth( from ); 31 | 32 | //eosio_assert( now()<=0, "正在优化合约代码,请稍后买入"); 33 | //eosio_assert( now()>=1533979200, "游戏在2018年8月11日下午5点30内测"); 34 | eosio_assert( now()>=INIT_TIME, "游戏在2018年8月12日晚上8点8分8秒启动游戏"); 35 | 36 | if(quantity.is_valid() && quantity.symbol == S(4, EOS) && from != _self && to == _self) 37 | { 38 | if(quantity.amount==1) 39 | { 40 | auto useritr = users.find( from ); 41 | eosio_assert( useritr != users.end(), "账号不存在"); 42 | eosio_assert( useritr->p >= 1000, "提取的利润不足0.1EOS"); 43 | 44 | asset balance(useritr->p,S(4,EOS)); 45 | users.modify( useritr, 0, [&]( auto& s ) { 46 | s.p = 0; 47 | }); 48 | 49 | action( 50 | permission_level{ _self, N(active) }, 51 | N(eosio.token), N(transfer), 52 | std::make_tuple(_self,from, balance, std::string("简影游戏团队感谢你的支持:http://eosbao.io")) 53 | ).send(); 54 | 55 | }else if(quantity.amount==2) 56 | { 57 | auto useritr = users.find( from ); 58 | eosio_assert( useritr != users.end(), "账号不存在"); 59 | eosio_assert( useritr->k >= 10000, "账号没有足够多的股份"); 60 | 61 | auto gameitr = games.begin(); 62 | eosio_assert( gameitr->k >= useritr->k, "发行的股份不足以出售"); 63 | 64 | uint64_t eos = (INIT_EOS+gameitr->e) * useritr->k / (INIT_KEY-gameitr->k+useritr->k); 65 | eosio_assert( eos>0 && gameitr->e >= eos, "资金储备没有足够EOS"); 66 | 67 | games.modify( gameitr, 0, [&]( auto& s ) { 68 | s.k -= useritr->k; 69 | s.e -= eos; 70 | }); 71 | 72 | users.modify( useritr, 0, [&]( auto& s ) { 73 | s.k = 0; 74 | s.p += eos; 75 | s.t = now(); 76 | }); 77 | 78 | }else if(quantity.amount >= 1000){ 79 | 80 | eosio_assert( quantity.amount >= 10000, "购买数量必须大于等于1EOS" ); 81 | eosio_assert( quantity.amount <= 100000*10000, "单次购买数量超出上限" ); 82 | eosio_assert( memo.size() <= 256, "备注信息不能超过256位" ); 83 | 84 | uint64_t eos = quantity.amount; // 总的EOS 85 | uint64_t fee = eos*0.10; // 10% 手续费给资源消耗及研发团队 86 | uint64_t referrer = eos*0.05; // 5% 给推荐人 87 | uint64_t weight = eos*0.15; // 15% 权重奖池 88 | uint64_t jackpot = eos*0.50; // 50% 储备资金用于Bancor定价 89 | uint64_t distribute = eos-fee-referrer-weight-jackpot; // 20% 为持股用户直接分红 90 | 91 | auto gameitr = games.begin(); 92 | if( gameitr == games.end() ) { 93 | gameitr = games.emplace(_self,[&](auto& s) 94 | { 95 | s.i = 0; 96 | s.e = 0; 97 | s.k = 0; 98 | s.f = 0; 99 | s.w = 0; 100 | s.r = 0; 101 | s.d = 0; 102 | }); 103 | } 104 | 105 | uint64_t key = (INIT_KEY-gameitr->k) * jackpot / (INIT_EOS+gameitr->e+jackpot); 106 | eosio_assert( key>0 && key<=INIT_KEY, "股份数量不正确" ); 107 | 108 | games.modify( gameitr, 0, [&]( auto& s ) { 109 | s.e += jackpot; 110 | s.k += key; 111 | s.f += fee+distribute; 112 | s.w += weight; 113 | s.r += referrer; 114 | s.d += distribute; 115 | }); 116 | 117 | auto teamAccount = string_to_name(TEAM_ACCOUNT.c_str()); 118 | auto teamitr = users.find( teamAccount ); 119 | if( teamitr == users.end()) 120 | { 121 | teamitr = users.emplace( _self, [&]( auto& s ) { 122 | s.n = teamAccount; 123 | s.r = 0; 124 | s.e = 0; 125 | s.k = 0; 126 | s.p = 0; 127 | s.t = now(); 128 | }); 129 | } 130 | users.modify( teamitr,0, [&]( auto& s ) { 131 | s.p += fee; 132 | }); 133 | 134 | auto useritr = users.find( from ); 135 | if( useritr == users.end() ) { 136 | auto parent = string_to_name(memo.c_str()); 137 | auto parentitr = users.find( parent ); 138 | if(memo.size()<=0 || memo.size()>12 || parent==_self || from==parent || parentitr==users.end()) 139 | { 140 | parent = teamAccount; 141 | } 142 | if(from==teamAccount) 143 | { 144 | parent = 0; 145 | } 146 | useritr = users.emplace( _self, [&]( auto& s ) { 147 | s.n = from; 148 | s.r = parent; 149 | s.e = eos; 150 | s.k = key; 151 | s.p = 0; 152 | s.t = now(); 153 | }); 154 | } else{ 155 | uint64_t timespan = now()-useritr->t; 156 | if(timespan>=INIT_WEIGHT && gameitr->w>10000) 157 | { 158 | double user_key = double(useritr->k); 159 | double game_key = double(gameitr->k); 160 | double time_ratio = double(timespan)/double(INIT_WEIGHT); 161 | uint64_t weight_amount = uint64_t(floor(user_key/game_key*gameitr->w*time_ratio)); 162 | 163 | if(weight_amount>gameitr->w*0.1) 164 | { 165 | weight_amount = gameitr->w*0.1; 166 | } 167 | 168 | games.modify( gameitr, 0, [&]( auto& s ) { 169 | s.w -= weight_amount; 170 | }); 171 | 172 | users.modify( useritr,0, [&]( auto& s ) { 173 | s.e += eos; 174 | s.k += key; 175 | s.p += weight_amount; 176 | s.t = now()-eos/10000*60; 177 | }); 178 | }else 179 | { 180 | users.modify( useritr,0, [&]( auto& s ) { 181 | s.e += eos; 182 | s.k += key; 183 | s.t = useritr->t - eos/10000*60; 184 | }); 185 | } 186 | } 187 | 188 | uint64_t profit_left = referrer; 189 | if(useritr->r>0) 190 | { 191 | auto agent = users.find(useritr->r); 192 | if(agent != users.end() ) 193 | { 194 | users.modify( agent,0, [&]( auto& s ) { 195 | s.p += referrer*0.80; 196 | }); 197 | profit_left -= referrer*0.80; 198 | } 199 | 200 | if(agent->r>0){ 201 | auto big_agent = users.find(agent->r); 202 | if(big_agent != users.end() ) 203 | { 204 | users.modify( big_agent,0, [&]( auto& s ) { 205 | s.p += referrer*0.20; 206 | }); 207 | if(profit_left>=referrer*0.20) 208 | { 209 | profit_left -= referrer*0.20; 210 | } 211 | } 212 | } 213 | if(profit_left>0 && agent != users.end()) 214 | { 215 | users.modify( agent,0, [&]( auto& s ) { 216 | s.p += profit_left; 217 | }); 218 | } 219 | }else 220 | { 221 | users.modify( useritr,0, [&]( auto& s ) { 222 | s.p += referrer; 223 | }); 224 | } 225 | } 226 | } 227 | 228 | } 229 | 230 | //@abi action 231 | void sell(account_name from, asset quantity) 232 | { 233 | require_auth( from ); 234 | 235 | eosio_assert( quantity.is_valid(), "股份数量不正确"); 236 | eosio_assert( quantity.amount >= 10000, "请至少出售1股" ); 237 | eosio_assert( quantity.amount <= 1000000*10000, "卖出的股份超出上限" ); 238 | 239 | auto useritr = users.find( from ); 240 | eosio_assert( useritr != users.end(), "账号不存在"); 241 | eosio_assert( useritr->k >= quantity.amount, "账号没有足够多的股份"); 242 | 243 | auto gameitr = games.begin(); 244 | uint64_t eos = (INIT_EOS+gameitr->e) * quantity.amount / (INIT_KEY-gameitr->k+quantity.amount); 245 | eosio_assert( gameitr->e >= eos, "资金储备没有足够多的EOS"); 246 | eosio_assert( gameitr->k >= quantity.amount, "已售股份没有足够多的KEY"); 247 | 248 | users.modify( useritr, 0, [&]( auto& s ) { 249 | s.k -= quantity.amount; 250 | s.p += eos; 251 | s.t = now(); 252 | }); 253 | 254 | games.modify( gameitr, 0, [&]( auto& s ) { 255 | s.k -= quantity.amount; 256 | s.e -= eos; 257 | }); 258 | } 259 | 260 | 261 | //@abi action 262 | void jackpot() 263 | { 264 | auto gameitr = games.begin(); 265 | eosio_assert( gameitr != games.end(), "系统数据不存在" ); 266 | 267 | auto bonusitr = bonuses.begin(); 268 | if(bonusitr==bonuses.end()) 269 | { 270 | bonusitr = bonuses.emplace(_self,[&](auto& s) 271 | { 272 | s.n = 0; 273 | s.i = 0; 274 | }); 275 | } 276 | eosio_assert( gameitr->d>10000, "分红已经分配完" ); 277 | 278 | auto useritr =users.begin(); 279 | if(bonusitr->n>0) 280 | { 281 | useritr = users.lower_bound(bonusitr->n); 282 | } 283 | 284 | uint64_t count = 0; 285 | for(;useritr!=users.end();++useritr) 286 | { 287 | if(useritr->n == bonusitr->n || useritr->k<10000) continue; 288 | 289 | double user_key = double(useritr->k); 290 | double game_key = double(gameitr->k); 291 | double game_bonus = double(gameitr->d); 292 | double ratio = user_key/game_key; 293 | 294 | users.modify( useritr,0, [&]( auto& s ) { 295 | s.p += uint64_t(floor(ratio*game_bonus)); 296 | }); 297 | 298 | if(count>INIT_BATCH) 299 | { 300 | bonuses.modify( bonusitr,0, [&]( auto& s ) { 301 | s.n = useritr->n; 302 | }); 303 | break; 304 | } 305 | count++; 306 | } 307 | 308 | if(useritr==users.end()) 309 | { 310 | bonuses.modify( bonusitr,0, [&]( auto& s ) { 311 | s.n = 0; 312 | }); 313 | games.modify( gameitr,0, [&]( auto& s ) { 314 | s.d = 0; 315 | }); 316 | } 317 | } 318 | 319 | 320 | private: 321 | 322 | // @abi table games i64 323 | struct game{ 324 | uint64_t i; 325 | uint64_t k; 326 | uint64_t e; 327 | uint64_t f; 328 | uint64_t w; 329 | uint64_t r; 330 | uint64_t d; 331 | 332 | uint64_t primary_key() const { return i; } 333 | EOSLIB_SERIALIZE(game, (i)(k)(e)(f)(w)(r)(d)) 334 | }; 335 | typedef eosio::multi_index game_list; 336 | game_list games; 337 | 338 | // @abi table users i64 339 | struct user { 340 | account_name n; 341 | account_name r; 342 | uint64_t e; 343 | uint64_t k; 344 | int64_t p; 345 | uint64_t t; 346 | 347 | uint64_t primary_key() const { return n; } 348 | uint64_t get_key() const { return k; } 349 | EOSLIB_SERIALIZE(user, (n)(r)(e)(k)(p)(t)) 350 | }; 351 | typedef eosio::multi_index> 353 | > user_list; 354 | user_list users; 355 | 356 | // @abi table bonuses i64 357 | struct bonus{ 358 | uint64_t i; 359 | account_name n; 360 | 361 | uint64_t primary_key() const { return i; } 362 | EOSLIB_SERIALIZE(bonus, (i)(n)) 363 | }; 364 | typedef eosio::multi_index bonus_list; 365 | bonus_list bonuses; 366 | }; 367 | 368 | #define EOSIO_ABI_EX( TYPE, MEMBERS ) \ 369 | extern "C" { \ 370 | void apply( uint64_t receiver, uint64_t code, uint64_t action ) { \ 371 | if( action == N(onerror)) { \ 372 | eosio_assert(code == N(eosio), "onerror action's are only valid from the \"eosio\" system account"); \ 373 | } \ 374 | auto self = receiver; \ 375 | if((code == N(eosio.token) && action == N(transfer)) || (code == self && (action==N(sell) || action == N(jackpot) || action == N(onerror))) ) { \ 376 | TYPE thiscontract( self ); \ 377 | switch( action ) { \ 378 | EOSIO_API( TYPE, MEMBERS ) \ 379 | } \ 380 | } \ 381 | } \ 382 | } 383 | 384 | EOSIO_ABI_EX(eosioshadows, (transfer)(sell)(jackpot)) -------------------------------------------------------------------------------- /eosioshadows.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eosioshadows/eos-shadows/54d90bc80387ddb789a1cd4f42fce4a751356422/eosioshadows.wasm -------------------------------------------------------------------------------- /idice-logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eosioshadows/eos-shadows/54d90bc80387ddb789a1cd4f42fce4a751356422/idice-logo.jpg -------------------------------------------------------------------------------- /idice-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eosioshadows/eos-shadows/54d90bc80387ddb789a1cd4f42fce4a751356422/idice-logo.png --------------------------------------------------------------------------------