Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0x768864B2c8e9e15Ec91Be1DB124469F861cFd2c2
Balance 0.033065 ETH ($65.55)
Nonce 1
Code Size 16684 bytes
Indexed Transactions 0 (1 on-chain, 1.3% indexed)
External Etherscan · Sourcify

Contract Bytecode

16684 bytes
0x6080604052600436106101875763ffffffff60e060020a600035041663015008b181146102c5578063018a25e8146102eb57806306fdde03146103125780630f15f4c01461039c57806310f01eba146103b157806311a09ae7146103d2578063200373c9146103e75780632660316e146103fc5780632e19ebdc1461042b57806337c30a98146104435780633ccfd60b146104995780633ddd4698146104ae578063409dba831461050a578063438d359e1461052257806349cc635d1461052d57806358d162da14610557578063630664341461056c578063685ffd83146105a2578063747dff42146105f55780638f7140ea146106545780638f8a58321461066f578063921dec211461068a57806393204075146106dd57806395d89b41146106f5578063aeeed0db1461070a578063c7e284b81461071e578063cd133c8f14610733578063cf8080001461073e578063d53b267914610756578063d87574e01461076b578063de7874f314610780578063ee0b5d8b146107d5578063fb9073eb1461082e575b61018f61404e565b60125460009060ff1615156001146101df576040805160e560020a62461bcd02815260206004820152601160248201526000805160206140c1833981519152604482015290519081900360640190fd5b3332146101eb57600080fd5b34633b9aca00811015610236576040805160e560020a62461bcd02815260206004820152601060248201526000805160206140e1833981519152604482015290519081900360640190fd5b69152d02c7e14af6800000811115610286576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206140a1833981519152604482015290519081900360640190fd5b61028f83610849565b336000908152600360209081526040808320548084526005928390529220015491945092506102c090839085610afe565b505050005b3480156102d157600080fd5b506102e9600160a060020a0360043516602435610c77565b005b3480156102f757600080fd5b50610300610e23565b60408051918252519081900360200190f35b34801561031e57600080fd5b50610327610e9a565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610361578181015183820152602001610349565b50505050905090810190601f16801561038e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103a857600080fd5b506102e9610ed1565b3480156103bd57600080fd5b50610300600160a060020a0360043516610fd7565b3480156103de57600080fd5b50610300610fe9565b3480156103f357600080fd5b50610300610fef565b34801561040857600080fd5b50610417600435602435610ff5565b604080519115158252519081900360200190f35b34801561043757600080fd5b50610300600435611015565b34801561044f57600080fd5b50610458611027565b604080519889526020890197909752941515878701526060870193909352608086019190915260a085015260c084015260e083015251908190036101000190f35b3480156104a557600080fd5b506102e9611048565b6040805160206004803580820135601f81018490048402850184019095528484526102e994369492936024939284019190819084018382808284375094975050600160a060020a038535169550505050506020013515156112e2565b34801561051657600080fd5b5061030060043561145e565b6102e96004356114bc565b34801561053957600080fd5b506102e9600435600160a060020a0360243516604435606435611667565b34801561056357600080fd5b50610300611859565b34801561057857600080fd5b5061058460043561185f565b60408051938452602084019290925282820152519081900360600190f35b6040805160206004803580820135601f81018490048402850184019095528484526102e994369492936024939284019190819084018382808284375094975050843595505050505060200135151561199e565b34801561060157600080fd5b5061060a611a43565b6040805198895260208901979097528787019590955260608701939093526080860191909152600160a060020a031660a085015260c084015260e083015251908190036101000190f35b34801561066057600080fd5b506102e9600435602435611a8b565b34801561067b57600080fd5b506102e9600435602435611b68565b6040805160206004803580820135601f81018490048402850184019095528484526102e9943694929360249392840191908190840183828082843750949750508435955050505050602001351515611cdf565b3480156106e957600080fd5b50610584600435611d84565b34801561070157600080fd5b50610327611da5565b6102e9600160a060020a0360043516611ddc565b34801561072a57600080fd5b50610300611f8a565b6102e9600435611fda565b34801561074a57600080fd5b5061030060043561215c565b34801561076257600080fd5b506104176121b3565b34801561077757600080fd5b506103006121bc565b34801561078c57600080fd5b506107986004356121c2565b60408051600160a060020a0390971687526020870195909552858501939093526060850191909152608084015260a0830152519081900360c00190f35b3480156107e157600080fd5b506107f6600160a060020a0360043516612201565b604080519788526020880196909652868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b34801561083a57600080fd5b506102e9600435602435612290565b61085161404e565b336000908152600360205260408120549080821515610af557604080517fe56556a9000000000000000000000000000000000000000000000000000000008152336004820152905173c9bbdf8cb30fdb0a6a40abecc267ccaa7e222dbe9163e56556a99160248083019260209291908290030181600087803b1580156108d657600080fd5b505af11580156108ea573d6000803e3d6000fd5b505050506040513d602081101561090057600080fd5b5051604080517f82e37b2c00000000000000000000000000000000000000000000000000000000815260048101839052905191945073c9bbdf8cb30fdb0a6a40abecc267ccaa7e222dbe916382e37b2c916024808201926020929091908290030181600087803b15801561097357600080fd5b505af1158015610987573d6000803e3d6000fd5b505050506040513d602081101561099d57600080fd5b5051604080517fe3c08adf00000000000000000000000000000000000000000000000000000000815260048101869052905191935073c9bbdf8cb30fdb0a6a40abecc267ccaa7e222dbe9163e3c08adf916024808201926020929091908290030181600087803b158015610a1057600080fd5b505af1158015610a24573d6000803e3d6000fd5b505050506040513d6020811015610a3a57600080fd5b505133600081815260036020908152604080832088905587835260059091529020805473ffffffffffffffffffffffffffffffffffffffff1916909117905590508115610ac357600082815260046020908152604080832086905585835260058252808320600190810186905560078352818420868552909252909120805460ff191690911790555b8015801590610ad25750828114155b15610aed576000838152600560208190526040909120018190555b845160010185525b50929392505050565b600054600b5442910181118015610b2d575060095481111580610b2d575060095481118015610b2d5750600854155b15610b4357610b3e84348585612428565b610c71565b60095481118015610b575750600a5460ff16155b15610c3c57600a805460ff19166001179055610b728261289c565b8051670de0b6b3a7640000830201815260208082018051870181526000878152600583526040908190206001015484519251828601516060808801516080808a015160a0808c015160c0808e01518b513381529d8e019a909a52348d8c0152958c019a909a52918a0195909552600160a060020a039093169288019290925286015260e0850152610100840192909252610120830191909152519193507f5905265be09e3f6f7813c1dce4febfad76d4b3a46288aa344d2531532c3519c991908190036101400190a15b600084815260056020526040902060030154610c5e903463ffffffff612ae716565b6000858152600560205260409020600301555b50505050565b610c7f61404e565b601254600090819060ff161515600114610cd1576040805160e560020a62461bcd02815260206004820152601160248201526000805160206140c1833981519152604482015290519081900360640190fd5b333214610cdd57600080fd5b83633b9aca00811015610d28576040805160e560020a62461bcd02815260206004820152601060248201526000805160206140e1833981519152604482015290519081900360640190fd5b69152d02c7e14af6800000811115610d78576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206140a1833981519152604482015290519081900360640190fd5b336000908152600360205260409020549250600160a060020a0386161580610da85750600160a060020a03861633145b15610dc757600083815260056020819052604090912001549150610e0f565b600160a060020a038616600090815260036020908152604080832054868452600592839052922001549092508214610e0f576000838152600560208190526040909120018290555b610e1b83838787612b48565b505050505050565b60008054600b5442910181118015610e53575060095481111580610e53575060095481118015610e535750600854155b15610e8c57600c54610e8590670de0b6b3a764000090610e79908263ffffffff612ae716565b9063ffffffff612ca816565b9150610e96565b6544364c5bb00091505b5090565b60408051808201909152601081527f5261745363616d20526f756e6420233100000000000000000000000000000000602082015281565b73f4c6bb681800ffb96bc046f56af9f06ab5774156331480610f0657507383c0efc6d8b16d87bfe1335ab6bcab3ed396028533145b1515610f5c576040805160e560020a62461bcd02815260206004820152601760248201527f6f6e6c79206f776e65722063616e206163746976617465000000000000000000604482015290519081900360640190fd5b60125460ff1615610fb7576040805160e560020a62461bcd02815260206004820152601960248201527f7261747363616d20616c72656164792061637469766174656400000000000000604482015290519081900360640190fd5b6012805460ff1916600117905560005442908103600b55610e1001600955565b60036020526000908152604090205481565b60025481565b60105481565b600760209081526000928352604080842090915290825290205460ff1681565b60046020526000908152604090205481565b600854600954600a54600b54600c54600d54600e54600f5460ff9095169488565b600080600061105561404e565b60125460ff1615156001146110a2576040805160e560020a62461bcd02815260206004820152601160248201526000805160206140c1833981519152604482015290519081900360640190fd5b3332146110ae57600080fd5b33600090815260036020526040902054600954429550909350841180156110d85750600a5460ff16155b80156110e5575060085415155b1561122757600a805460ff191660011790556111008161289c565b905061110b83612cd5565b9150600082111561115c57600083815260056020526040808220549051600160a060020a039091169184156108fc02918591818181858888f1935050505015801561115a573d6000803e3d6000fd5b505b8051670de0b6b3a7640000850201815260208082018051850181526000858152600583526040908190206001015484519251828601516060808801516080808a015160a0808c015160c0808e01518b513381529d8e019a909a528c8b018f9052958c019a909a52918a0195909552600160a060020a039093169288019290925286015260e0850152610100840192909252610120830191909152517f9e9c9331834267c84342f2dce38f9ba35eb0bfbcc207c64872e1e74f9706f2a3918190036101400190a1610c71565b61123083612cd5565b9150600082111561128157600083815260056020526040808220549051600160a060020a039091169184156108fc02918591818181858888f1935050505015801561127f573d6000803e3d6000fd5b505b6000838152600560209081526040918290206001015482513381529182015280820184905260608101869052905184917f8f36579a548bc439baa172a6521207464154da77f411e2da3db2f53affe6cc3a919081900360800190a250505050565b600080808080803332146112f557600080fd5b6112fe89612d50565b604080517faa4d490b000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052600160a060020a038c1660448301528a151560648301528251939950975034965073c9bbdf8cb30fdb0a6a40abecc267ccaa7e222dbe9263aa4d490b9288926084808201939182900301818588803b15801561138f57600080fd5b505af11580156113a3573d6000803e3d6000fd5b50505050506040513d60408110156113ba57600080fd5b508051602091820151600160a060020a0380891660008181526003865260408082205485835260058852918190208054600190910154825188151581529889018790529416878201526060870193909352608086018a90524260a0870152915193975091955093508892909184917fdd6176433ff5026bbce96b068584b7bbe3514227e72df9c630b749ae87e64442919081900360c00190a4505050505050505050565b60008054600b544291018111801561148e57506009548111158061148e57506009548111801561148e5750600854155b156114ad57600d546114a6908463ffffffff61356316565b91506114b6565b6114a683613584565b50919050565b6114c461404e565b601254600090819060ff161515600114611516576040805160e560020a62461bcd02815260206004820152601160248201526000805160206140c1833981519152604482015290519081900360640190fd5b33321461152257600080fd5b34633b9aca0081101561156d576040805160e560020a62461bcd02815260206004820152601060248201526000805160206140e1833981519152604482015290519081900360640190fd5b69152d02c7e14af68000008111156115bd576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206140a1833981519152604482015290519081900360640190fd5b6115c684610849565b3360009081526003602052604090205490945092508415806115f8575060008381526005602052604090206001015485145b1561161757600083815260056020819052604090912001549150611655565b600085815260046020908152604080832054868452600592839052922001549092508214611655576000838152600560208190526040909120018290555b611660838386610afe565b5050505050565b3373c9bbdf8cb30fdb0a6a40abecc267ccaa7e222dbe146116f8576040805160e560020a62461bcd02815260206004820152602360248201527f6f6e6c7920526174426f6f6b2063616e2063616c6c20746869732066756e637460448201527f696f6e0000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600160a060020a038316600090815260036020526040902054841461173357600160a060020a03831660009081526003602052604090208490555b600082815260046020526040902054841461175a5760008281526004602052604090208490555b600084815260056020526040902054600160a060020a038481169116146117b0576000848152600560205260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0385161790555b60008481526005602052604090206001015482146117dd5760008481526005602052604090206001018290555b60008481526005602081905260409091200154811461180c576000848152600560208190526040909120018190555b600084815260076020908152604080832085845290915290205460ff161515610c715760008481526007602090815260408083208584529091529020805460ff1916600117905550505050565b60115481565b60008060006008600101544211801561187b5750600a5460ff16155b8015611888575060085415155b156119795760085484141561194657600e546118db906064906118b290603063ffffffff61360816565b8115156118bb57fe5b60008781526005602052604090206002015491900463ffffffff612ae716565b6000858152600660205260409020600201546119289061190a906118fe8861367f565b9063ffffffff6136f716565b6000878152600560205260409020600301549063ffffffff612ae716565b60008681526005602052604090206004015491945092509050611997565b600084815260056020908152604080832060029081015460069093529220909101546119289061190a906118fe8861367f565b60008481526005602052604090206002015461192861190a86613757565b9193909250565b600080808080803332146119b157600080fd5b6119ba89612d50565b604080517f745ea0c1000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052604482018c90528a151560648301528251939950975034965073c9bbdf8cb30fdb0a6a40abecc267ccaa7e222dbe9263745ea0c19288926084808201939182900301818588803b15801561138f57600080fd5b600c54600954600b54600e54600854600081815260056020526040902080546001918201549154600254600160a060020a0390921692916103e8909102019091929394959697565b3373c9bbdf8cb30fdb0a6a40abecc267ccaa7e222dbe14611b1c576040805160e560020a62461bcd02815260206004820152602360248201527f6f6e6c7920526174426f6f6b2063616e2063616c6c20746869732066756e637460448201527f696f6e0000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600082815260076020908152604080832084845290915290205460ff161515611b645760008281526007602090815260408083208484529091529020805460ff191660011790555b5050565b611b7061404e565b60125460009060ff161515600114611bc0576040805160e560020a62461bcd02815260206004820152601160248201526000805160206140c1833981519152604482015290519081900360640190fd5b333214611bcc57600080fd5b82633b9aca00811015611c17576040805160e560020a62461bcd02815260206004820152601060248201526000805160206140e1833981519152604482015290519081900360640190fd5b69152d02c7e14af6800000811115611c67576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206140a1833981519152604482015290519081900360640190fd5b336000908152600360205260409020549150841580611c8557508185145b15611ca457600082815260056020819052604090912001549450611cd3565b600082815260056020819052604090912001548514611cd3576000828152600560208190526040909120018590555b61166082868686612b48565b60008080808080333214611cf257600080fd5b611cfb89612d50565b604080517fc0942dfd000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052604482018c90528a151560648301528251939950975034965073c9bbdf8cb30fdb0a6a40abecc267ccaa7e222dbe9263c0942dfd9288926084808201939182900301818588803b15801561138f57600080fd5b60066020526000908152604090208054600182015460029092015490919083565b60408051808201909152600381527f5253310000000000000000000000000000000000000000000000000000000000602082015281565b611de461404e565b601254600090819060ff161515600114611e36576040805160e560020a62461bcd02815260206004820152601160248201526000805160206140c1833981519152604482015290519081900360640190fd5b333214611e4257600080fd5b34633b9aca00811015611e8d576040805160e560020a62461bcd02815260206004820152601060248201526000805160206140e1833981519152604482015290519081900360640190fd5b69152d02c7e14af6800000811115611edd576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206140a1833981519152604482015290519081900360640190fd5b611ee684610849565b336000908152600360205260409020549094509250600160a060020a0385161580611f195750600160a060020a03851633145b15611f3857600083815260056020819052604090912001549150611655565b600160a060020a03851660009081526003602090815260408083205486845260059283905292200154909250821461165557600083815260056020819052604090912001829055611660838386610afe565b6009546000904290811015611fd157600054600b5401811115611fba57600954610e85908263ffffffff6136f716565b600054600b54610e8591018263ffffffff6136f716565b60009150610e96565b611fe261404e565b60125460009060ff161515600114612032576040805160e560020a62461bcd02815260206004820152601160248201526000805160206140c1833981519152604482015290519081900360640190fd5b33321461203e57600080fd5b34633b9aca00811015612089576040805160e560020a62461bcd02815260206004820152601060248201526000805160206140e1833981519152604482015290519081900360640190fd5b69152d02c7e14af68000008111156120d9576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206140a1833981519152604482015290519081900360640190fd5b6120e283610849565b33600090815260036020526040902054909350915083158061210357508184145b1561212257600082815260056020819052604090912001549350612151565b600082815260056020819052604090912001548414612151576000828152600560208190526040909120018490555b610c71828585610afe565b60008054600b544291018111801561218c57506009548111158061218c57506009548111801561218c5750600854155b156121aa57600c546114a6908490610e79908263ffffffff612ae716565b6114a6836137a7565b60125460ff1681565b60015481565b6005602081905260009182526040909120805460018201546002830154600384015460048501549490950154600160a060020a03909316949193909286565b6000806000806000806000600160a060020a0388166000908152600360209081526040808320548084526005808452828520600180820154600687529490962090950154935260029093015483929061225c61190a85613757565b600095865260056020908152604080882060040154600690925290962054949e939d50919b50995097509195509350915050565b61229861404e565b601254600090819060ff1615156001146122ea576040805160e560020a62461bcd02815260206004820152601160248201526000805160206140c1833981519152604482015290519081900360640190fd5b3332146122f657600080fd5b83633b9aca00811015612341576040805160e560020a62461bcd02815260206004820152601060248201526000805160206140e1833981519152604482015290519081900360640190fd5b69152d02c7e14af6800000811115612391576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206140a1833981519152604482015290519081900360640190fd5b3360009081526003602052604090205492508515806123c0575060008381526005602052604090206001015486145b156123df57600083815260056020819052604090912001549150610e0f565b600086815260046020908152604080832054868452600592839052922001549092508214610e0f57600083815260056020819052604090912001829055610e1b83838787612b48565b60008481526006602052604081206001015481908190819081901515612455576124528987613814565b95505b600d5468056bc75e2d631000001180156124955750600089815260066020526040902054678ac7230489e8000090612493908a63ffffffff612ae716565b115b15612511576000898152600660205260409020546124c290678ac7230489e800009063ffffffff6136f716565b94506124d4888663ffffffff6136f716565b60008a8152600560205260409020600301549094506124f9908563ffffffff612ae716565b60008a81526005602052604090206003015593965086935b633b9aca0088111561289157600d54612530908963ffffffff61356316565b9250670de0b6b3a764000083106125615761254a83613829565b60085489146125595760088990555b855160640186525b67016345785d8a000088106127a1576002805460010190556125816138c1565b1515600114156127a157678ac7230489e800008810612622576001546064906125b190604b63ffffffff61360816565b8115156125ba57fe5b60008b81526005602052604090206002015491900492506125e1908363ffffffff612ae716565b60008a815260056020526040902060020155600154612606908363ffffffff6136f716565b60015585516d0eca8847c4129106ce8300000000018652612776565b670de0b6b3a764000088101580156126415750678ac7230489e8000088105b156126ce5760015460649061265d90603263ffffffff61360816565b81151561266657fe5b60008b815260056020526040902060020154919004925061268d908363ffffffff612ae716565b60008a8152600560205260409020600201556001546126b2908363ffffffff6136f716565b60015585516d09dc5ada82b70b59df0200000000018652612776565b67016345785d8a000088101580156126ed5750670de0b6b3a764000088105b156127765760015460649061270990601963ffffffff61360816565b81151561271257fe5b60008b8152600560205260409020600201549190049250612739908363ffffffff612ae716565b60008a81526005602052604090206002015560015461275e908363ffffffff6136f716565b60015585516d04ee2d6d415b85acef81000000000186525b85516d314dc6448d9338c15b0a000000008302016c7e37be2022c0914b268000000001865260006002555b60025486516103e89091020186526000898152600660205260409020600101546127d290849063ffffffff612ae716565b60008a81526006602052604090206001810191909155546127fa90899063ffffffff612ae716565b60008a815260066020526040902055600c5461281d90849063ffffffff612ae716565b600c55600d5461283490899063ffffffff612ae716565b600d55868914801590612857575060008781526005602052604090206001015415155b1561286457506000612868565b5060015b61287489898989613acf565b95506128838989858985613c2a565b955061289189898589613d3d565b505050505050505050565b6128a461404e565b600854600154600e540160008080808060646128c787602d63ffffffff61360816565b8115156128d057fe5b049450600a8604935060646128f06011548861360890919063ffffffff16565b8115156128f957fe5b600c54919004935061291984670de0b6b3a764000063ffffffff61360816565b81151561292257fe5b049150612961670de0b6b3a76400006129496008600401548561360890919063ffffffff16565b81151561295257fe5b8591900463ffffffff6136f716565b905060008111156129915761297c838263ffffffff6136f716565b925061298e848263ffffffff612ae716565b93505b6000878152600560205260409020600201546129b490869063ffffffff612ae716565b6000888152600560205260408082206002019290925581517f6465706f736974282900000000000000000000000000000000000000000000008152825190819003600901812063ffffffff60e060020a9182900490811690910282529251737099ea5286aa066b5e6194ffebee691332502d8a9392889260048082019391829003018185885af193505050501515612a5d57612a56838563ffffffff612ae716565b9250600093505b600f54612a7190839063ffffffff612ae716565b600f5550506009548751620f4240909102018752602080880180516a52b7d2dcc80cd2e400000088020190526000868152600580835260408083208054600160a060020a0316918c0191909152978252909152600190950154606088015260808701929092525060c08501525060a08301525090565b81810182811015612b42576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d61746820616464206661696c656400000000000000000000000000604482015290519081900360640190fd5b92915050565b600054600b5442910181118015612b77575060095481111580612b77575060095481118015612b775750600854155b15612bac57612b89836118fe87612cd5565b600086815260056020526040902060030155612ba785848685612428565b611660565b60095481118015612bc05750600a5460ff16155b1561166057600a805460ff19166001179055612bdb8261289c565b8051670de0b6b3a7640000830201815260208082018051880181526000888152600583526040908190206001015484519251828601516060808801516080808a015160a0808c015160c0808e01518b513381529d8e019a909a528c8b019b909b52948b0196909652600160a060020a0390941690890152928701929092529385019390935260e0840192909252610100830191909152519193507f603a740c9291cc914e0c8d16b355cdb091aefd5d9bbdf4f95371ce756f5e8a4091908190036101200190a15050505050565b6000612cce612cc5612cc0858563ffffffff6136f716565b6137a7565b6118fe856137a7565b9392505050565b600080612ce183613e70565b600083815260056020526040902060048101546003820154600290920154612d1f92612d13919063ffffffff612ae716565b9063ffffffff612ae716565b90506000811115612b4257600083815260056020526040812060028101829055600381018290556004015592915050565b8051600090829082808060208411801590612d6b5750600084115b1515612de7576040805160e560020a62461bcd02815260206004820152602a60248201527f737472696e67206d757374206265206265747765656e203120616e642033322060448201527f6368617261637465727300000000000000000000000000000000000000000000606482015290519081900360840190fd5b846000815181101515612df657fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214158015612e5d57508460018503815181101515612e3557fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214155b1515612ed9576040805160e560020a62461bcd02815260206004820152602560248201527f737472696e672063616e6e6f74207374617274206f7220656e6420776974682060448201527f7370616365000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b846000815181101515612ee857fe5b90602001015160f860020a900460f860020a02600160f860020a031916603060f860020a02141561302b57846001815181101515612f2257fe5b90602001015160f860020a900460f860020a02600160f860020a031916607860f860020a0214151515612f9f576040805160e560020a62461bcd02815260206004820152601b60248201527f737472696e672063616e6e6f7420737461727420776974682030780000000000604482015290519081900360640190fd5b846001815181101515612fae57fe5b90602001015160f860020a900460f860020a02600160f860020a031916605860f860020a021415151561302b576040805160e560020a62461bcd02815260206004820152601b60248201527f737472696e672063616e6e6f7420737461727420776974682030580000000000604482015290519081900360640190fd5b600091505b838210156134fb5784517f40000000000000000000000000000000000000000000000000000000000000009086908490811061306857fe5b90602001015160f860020a900460f860020a02600160f860020a0319161180156130dc575084517f5b00000000000000000000000000000000000000000000000000000000000000908690849081106130bd57fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b156131495784828151811015156130ef57fe5b90602001015160f860020a900460f860020a0260f860020a900460200160f860020a02858381518110151561312057fe5b906020010190600160f860020a031916908160001a90535082151561314457600192505b6134f0565b848281518110151561315757fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a021480613227575084517f6000000000000000000000000000000000000000000000000000000000000000908690849081106131b357fe5b90602001015160f860020a900460f860020a02600160f860020a031916118015613227575084517f7b000000000000000000000000000000000000000000000000000000000000009086908490811061320857fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b806132d1575084517f2f000000000000000000000000000000000000000000000000000000000000009086908490811061325d57fe5b90602001015160f860020a900460f860020a02600160f860020a0319161180156132d1575084517f3a00000000000000000000000000000000000000000000000000000000000000908690849081106132b257fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b151561334d576040805160e560020a62461bcd02815260206004820152602260248201527f737472696e6720636f6e7461696e7320696e76616c696420636861726163746560448201527f7273000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b848281518110151561335b57fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a02141561343a57848260010181518110151561339757fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a021415151561343a576040805160e560020a62461bcd02815260206004820152602860248201527f737472696e672063616e6e6f7420636f6e7461696e20636f6e7365637574697660448201527f6520737061636573000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b821580156134e6575084517f30000000000000000000000000000000000000000000000000000000000000009086908490811061347357fe5b90602001015160f860020a900460f860020a02600160f860020a03191610806134e6575084517f3900000000000000000000000000000000000000000000000000000000000000908690849081106134c757fe5b90602001015160f860020a900460f860020a02600160f860020a031916115b156134f057600192505b600190910190613030565b600183151514613555576040805160e560020a62461bcd02815260206004820152601d60248201527f737472696e672063616e6e6f74206265206f6e6c79206e756d62657273000000604482015290519081900360640190fd5b505050506020015192915050565b6000612cce61357184613584565b6118fe613584868663ffffffff612ae716565b60006309502f906135f86d03b2a1d15167e7c5699bfde000006118fe6135f37a0dac7055469777a6122ee4310dd6c14410500f2904840000000000612d136b01027e72f1f12813088000006135e78a670de0b6b3a764000063ffffffff61360816565b9063ffffffff61360816565b613ef1565b81151561360157fe5b0492915050565b600082151561361957506000612b42565b5081810281838281151561362957fe5b0414612b42576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d617468206d756c206661696c656400000000000000000000000000604482015290519081900360640190fd5b600081815260066020526040812060010154600c54601154600e54670de0b6b3a7640000936135f89390926135e7926136dd9187916064916136c7919063ffffffff61360816565b8115156136d057fe5b049063ffffffff61360816565b8115156136e657fe5b600f5491900463ffffffff612ae716565b600082821115613751576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d61746820737562206661696c656400000000000000000000000000604482015290519081900360640190fd5b50900390565b60008181526006602052604081206002810154600190910154600f54612b429291670de0b6b3a7640000916137919163ffffffff61360816565b81151561379a57fe5b049063ffffffff6136f716565b60006137ba670de0b6b3a7640000613f44565b6135f860026137ed6137da86670de0b6b3a764000063ffffffff61360816565b65886c8f6730709063ffffffff61360816565b8115156137f657fe5b04612d1361380386613f44565b6304a817c89063ffffffff61360816565b61381c61404e565b508051600a018152919050565b60095442906000908211801561383f5750600854155b156138635761385c82612d13601e670de0b6b3a7640000876136d0565b9050613881565b60095461387e90612d13601e670de0b6b3a7640000876136d0565b90505b613894620151808363ffffffff612ae716565b8110156138a55760098190556138bc565b6138b8620151808363ffffffff612ae716565b6009555b505050565b600080613a3243612d1342336040516020018082600160a060020a0316600160a060020a03166c010000000000000000000000000281526014019150506040516020818303038152906040526040518082805190602001908083835b6020831061393c5780518252601f19909201916020918201910161391d565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091209250505081151561397257fe5b04612d1345612d1342416040516020018082600160a060020a0316600160a060020a03166c010000000000000000000000000281526014019150506040516020818303038152906040526040518082805190602001908083835b602083106139eb5780518252601f1990920191602091820191016139cc565b5181516020939093036101000a6000190180199091169216919091179052604051920182900390912092505050811515613a2157fe5b04612d13424463ffffffff612ae716565b604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b60208310613a805780518252601f199092019160209182019101613a61565b5181516020939093036101000a6000190180199091169216919091179052604051920182900390912060025490945092506103e89150839050046103e80282031015611fd15760019150610e96565b613ad761404e565b60646005850204600a8504848714801590613b02575060008581526005602052604090206001015415155b15613b9b57600085815260056020526040902060040154613b2a90829063ffffffff612ae716565b600086815260056020908152604091829020600481019390935582546001909301548251600160a060020a0390941684529083015281810183905242606083015251889187917f4fe7f9b4bd76588f3098f293ddab46b9436200adb9595540fce031e6fdfbe8a19181900360800190a35b737099ea5286aa066b5e6194ffebee691332502d8a600160a060020a03168260405180807f6465706f736974282900000000000000000000000000000000000000000000008152506009019050604051809103902060e060020a9004906040518263ffffffff1660e060020a02815260040160006040518083038185885af150969a9950505050505050505050565b613c3261404e565b6000806000806064613c4f6010548b61360890919063ffffffff16565b811515613c5857fe5b0493508515613c9257613c8f6064613c778b600a63ffffffff61360816565b811515613c8057fe5b8691900463ffffffff612ae716565b93505b60015460148a049350613cab908463ffffffff612ae716565b6001556064613cc18a601463ffffffff61360816565b811515613cca57fe5b049150613cd88a858a613f50565b90506000811115613cf657613cf3848263ffffffff6136f716565b93505b600e54613d0d90612d13848463ffffffff612ae716565b600e5560c0870151613d2690859063ffffffff612ae716565b60c08801525060e086015250929695505050505050565b42670de0b6b3a764000002816000015101816000018181525050838160200151018160200181815250507f3671a735b2c7f1e43f1ab4385d4c5b480bbff437ad893b703fb0dfdbd24679e28160000151826020015160056000888152602001908152602001600020600101543387878760400151886060015189608001518a60a001518b60c001518c60e00151600154604051808e81526020018d81526020018c600019166000191681526020018b600160a060020a0316600160a060020a031681526020018a815260200189815260200188600160a060020a0316600160a060020a0316815260200187600019166000191681526020018681526020018581526020018481526020018381526020018281526020019d505050505050505050505050505060405180910390a150505050565b6000613e7b82613757565b90506000811115611b6457600082815260056020526040902060030154613ea990829063ffffffff612ae716565b600083815260056020908152604080832060030193909355600690522060020154613edb90829063ffffffff612ae716565b6000838152600660205260409020600201555050565b6000806002613f01846001612ae7565b811515613f0a57fe5b0490508291505b818110156114b6578091506002613f338285811515613f2c57fe5b0483612ae7565b811515613f3c57fe5b049050613f11565b6000612b428283613608565b600c5460009081908190613f7286670de0b6b3a764000063ffffffff61360816565b811515613f7b57fe5b600f549190049250613f9490839063ffffffff612ae716565b600f55670de0b6b3a7640000613fb0838663ffffffff61360816565b811515613fb957fe5b600088815260066020526040902060020154600f54929091049250613ff891612d13908490670de0b6b3a764000090613791908a63ffffffff61360816565b600087815260066020526040902060020155600c5461404490670de0b6b3a76400009061402c90859063ffffffff61360816565b81151561403557fe5b8791900463ffffffff6136f716565b9695505050505050565b6101006040519081016040528060008152602001600081526020016000600160a060020a03168152602001600080191681526020016000815260200160008152602001600081526020016000815250905600746f6f206d756368206d6f6e6579000000000000000000000000000000000000697473206e6f7420726561647920796574000000000000000000000000000000746f6f206c6974746c65206d6f6e657900000000000000000000000000000000a165627a7a723058206870525ac48508a6030da3ac3ef44077272b5b76ea8edaaf7d69c896b17759110029

Verified Source Code Partial Match

Compiler: v0.4.24+commit.e67f0147 EVM: byzantium Optimization: Yes (200 runs)
RatScam.sol 1693 lines
pragma solidity ^0.4.24;

contract RSEvents {

    // fired whenever a player registers a name
    event onNewName
    (
        uint256 indexed playerID,
        address indexed playerAddress,
        bytes32 indexed playerName,
        bool isNewPlayer,
        uint256 affiliateID,
        address affiliateAddress,
        bytes32 affiliateName,
        uint256 amountPaid,
        uint256 timeStamp
    );
    
    // fired at end of buy or reload
    event onEndTx
    (
        uint256 compressedData,     
        uint256 compressedIDs,      
        bytes32 playerName,
        address playerAddress,
        uint256 ethIn,
        uint256 keysBought,
        address winnerAddr,
        bytes32 winnerName,
        uint256 amountWon,
        uint256 newPot,
        uint256 genAmount,
        uint256 potAmount,
        uint256 airDropPot
    );
    
	// fired whenever theres a withdraw
    event onWithdraw
    (
        uint256 indexed playerID,
        address playerAddress,
        bytes32 playerName,
        uint256 ethOut,
        uint256 timeStamp
    );
    
    // fired whenever a withdraw forces end round to be ran
    event onWithdrawAndDistribute
    (
        address playerAddress,
        bytes32 playerName,
        uint256 ethOut,
        uint256 compressedData,
        uint256 compressedIDs,
        address winnerAddr,
        bytes32 winnerName,
        uint256 amountWon,
        uint256 newPot,
        uint256 genAmount
    );
    
    // fired whenever a player tries a buy after round timer 
    // hit zero, and causes end round to be ran.
    event onBuyAndDistribute
    (
        address playerAddress,
        bytes32 playerName,
        uint256 ethIn,
        uint256 compressedData,
        uint256 compressedIDs,
        address winnerAddr,
        bytes32 winnerName,
        uint256 amountWon,
        uint256 newPot,
        uint256 genAmount
    );
    
    // fired whenever a player tries a reload after round timer 
    // hit zero, and causes end round to be ran.
    event onReLoadAndDistribute
    (
        address playerAddress,
        bytes32 playerName,
        uint256 compressedData,
        uint256 compressedIDs,
        address winnerAddr,
        bytes32 winnerName,
        uint256 amountWon,
        uint256 newPot,
        uint256 genAmount
    );
    
    // fired whenever an affiliate is paid
    event onAffiliatePayout
    (
        uint256 indexed affiliateID,
        address affiliateAddress,
        bytes32 affiliateName,
        uint256 indexed buyerID,
        uint256 amount,
        uint256 timeStamp
    );
}

contract modularRatScam is RSEvents {}

contract RatScam is modularRatScam {
    using SafeMath for *;
    using NameFilter for string;
    using RSKeysCalc for uint256;
	
    // TODO: check address
    RatInterfaceForForwarder constant private RatKingCorp = RatInterfaceForForwarder(0x7099eA5286AA066b5e6194ffebEe691332502d8a);
	RatBookInterface constant private RatBook = RatBookInterface(0xc9bbdf8cb30fdb0a6a40abecc267ccaa7e222dbe);

    string constant public name = "RatScam Round #1";
    string constant public symbol = "RS1";
    uint256 private rndGap_ = 0;

    // TODO: check time
    uint256 constant private rndInit_ = 1 hours;                // round timer starts at this
    uint256 constant private rndInc_ = 30 seconds;              // every full key purchased adds this much to the timer
    uint256 constant private rndMax_ = 24 hours;                // max length a round timer can be
//==============================================================================
//     _| _ _|_ _    _ _ _|_    _   .
//    (_|(_| | (_|  _\(/_ | |_||_)  .  (data used to store game info that changes)
//=============================|================================================
	uint256 public airDropPot_;             // person who gets the airdrop wins part of this pot
    uint256 public airDropTracker_ = 0;     // incremented each time a "qualified" tx occurs.  used to determine winning air drop
//****************
// PLAYER DATA 
//****************
    mapping (address => uint256) public pIDxAddr_;          // (addr => pID) returns player id by address
    mapping (bytes32 => uint256) public pIDxName_;          // (name => pID) returns player id by name
    mapping (uint256 => RSdatasets.Player) public plyr_;   // (pID => data) player data
    mapping (uint256 => RSdatasets.PlayerRounds) public plyrRnds_;    // (pID => rID => data) player round data by player id & round id
    mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns.  (used so you can change your display name amongst any name you own)
//****************
// ROUND DATA 
//****************
    RSdatasets.Round public round_;   // round data
//****************
// TEAM FEE DATA 
//****************
    uint256 public fees_ = 60;          // fee distribution
    uint256 public potSplit_ = 45;     // pot split distribution
//==============================================================================
//     _ _  _  __|_ _    __|_ _  _  .
//    (_(_)| |_\ | | |_|(_ | (_)|   .  (initial data setup upon contract deploy)
//==============================================================================
    constructor()
        public
    {
	}
//==============================================================================
//     _ _  _  _|. |`. _  _ _  .
//    | | |(_)(_||~|~|(/_| _\  .  (these are safety checks)
//==============================================================================
    /**
     * @dev used to make sure no one can interact with contract until it has 
     * been activated. 
     */
    modifier isActivated() {
        require(activated_ == true, "its not ready yet"); 
        _;
    }
    
    /**
     * @dev prevents contracts from interacting with ratscam 
     */
    modifier isHuman() {
        require(msg.sender == tx.origin);
        _;
    }

    /**
     * @dev sets boundaries for incoming tx 
     */
    modifier isWithinLimits(uint256 _eth) {
        require(_eth >= 1000000000, "too little money");
        require(_eth <= 100000000000000000000000, "too much money");
        _;    
    }
    
//==============================================================================
//     _    |_ |. _   |`    _  __|_. _  _  _  .
//    |_)|_||_)||(_  ~|~|_|| |(_ | |(_)| |_\  .  (use these to interact with contract)
//====|=========================================================================
    /**
     * @dev emergency buy uses last stored affiliate ID and team snek
     */
    function()
        isActivated()
        isHuman()
        isWithinLimits(msg.value)
        public
        payable
    {
        // set up our tx event data and determine if player is new or not
        RSdatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
            
        // fetch player id
        uint256 _pID = pIDxAddr_[msg.sender];
        
        // buy core 
        buyCore(_pID, plyr_[_pID].laff, _eventData_);
    }
    
    /**
     * @dev converts all incoming ethereum to keys.
     * -functionhash- 0x8f38f309 (using ID for affiliate)
     * -functionhash- 0x98a0871d (using address for affiliate)
     * -functionhash- 0xa65b37a1 (using name for affiliate)
     * @param _affCode the ID/address/name of the player who gets the affiliate fee
     */
    function buyXid(uint256 _affCode)
        isActivated()
        isHuman()
        isWithinLimits(msg.value)
        public
        payable
    {
        // set up our tx event data and determine if player is new or not
        RSdatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
        
        // fetch player id
        uint256 _pID = pIDxAddr_[msg.sender];
        
        // manage affiliate residuals
        // if no affiliate code was given or player tried to use their own, lolz
        if (_affCode == 0 || _affCode == _pID)
        {
            // use last stored affiliate code 
            _affCode = plyr_[_pID].laff;
            
        // if affiliate code was given & its not the same as previously stored 
        } else if (_affCode != plyr_[_pID].laff) {
            // update last affiliate 
            plyr_[_pID].laff = _affCode;
        }
                
        // buy core 
        buyCore(_pID, _affCode, _eventData_);
    }
    
    function buyXaddr(address _affCode)
        isActivated()
        isHuman()
        isWithinLimits(msg.value)
        public
        payable
    {
        // set up our tx event data and determine if player is new or not
        RSdatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
        
        // fetch player id
        uint256 _pID = pIDxAddr_[msg.sender];
        
        // manage affiliate residuals
        uint256 _affID;
        // if no affiliate code was given or player tried to use their own, lolz
        if (_affCode == address(0) || _affCode == msg.sender)
        {
            // use last stored affiliate code
            _affID = plyr_[_pID].laff;
        
        // if affiliate code was given    
        } else {
            // get affiliate ID from aff Code 
            _affID = pIDxAddr_[_affCode];
            
            // if affID is not the same as previously stored 
            if (_affID != plyr_[_pID].laff)
            {
                // update last affiliate
                plyr_[_pID].laff = _affID;
            }
        }
        
        // buy core 
        buyCore(_pID, _affID, _eventData_);
    }
    
    function buyXname(bytes32 _affCode)
        isActivated()
        isHuman()
        isWithinLimits(msg.value)
        public
        payable
    {
        // set up our tx event data and determine if player is new or not
        RSdatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
        
        // fetch player id
        uint256 _pID = pIDxAddr_[msg.sender];
        
        // manage affiliate residuals
        uint256 _affID;
        // if no affiliate code was given or player tried to use their own, lolz
        if (_affCode == '' || _affCode == plyr_[_pID].name)
        {
            // use last stored affiliate code
            _affID = plyr_[_pID].laff;
        
        // if affiliate code was given
        } else {
            // get affiliate ID from aff Code
            _affID = pIDxName_[_affCode];
            
            // if affID is not the same as previously stored
            if (_affID != plyr_[_pID].laff)
            {
                // update last affiliate
                plyr_[_pID].laff = _affID;
            }
        }
        
        // buy core 
        buyCore(_pID, _affID, _eventData_);
    }
    
    /**
     * @dev essentially the same as buy, but instead of you sending ether 
     * from your wallet, it uses your unwithdrawn earnings.
     * -functionhash- 0x349cdcac (using ID for affiliate)
     * -functionhash- 0x82bfc739 (using address for affiliate)
     * -functionhash- 0x079ce327 (using name for affiliate)
     * @param _affCode the ID/address/name of the player who gets the affiliate fee
     * @param _eth amount of earnings to use (remainder returned to gen vault)
     */
    function reLoadXid(uint256 _affCode, uint256 _eth)
        isActivated()
        isHuman()
        isWithinLimits(_eth)
        public
    {
        // set up our tx event data
        RSdatasets.EventReturns memory _eventData_;
        
        // fetch player ID
        uint256 _pID = pIDxAddr_[msg.sender];
        
        // manage affiliate residuals
        // if no affiliate code was given or player tried to use their own, lolz
        if (_affCode == 0 || _affCode == _pID)
        {
            // use last stored affiliate code 
            _affCode = plyr_[_pID].laff;
            
        // if affiliate code was given & its not the same as previously stored 
        } else if (_affCode != plyr_[_pID].laff) {
            // update last affiliate 
            plyr_[_pID].laff = _affCode;
        }

        // reload core
        reLoadCore(_pID, _affCode, _eth, _eventData_);
    }
    
    function reLoadXaddr(address _affCode, uint256 _eth)
        isActivated()
        isHuman()
        isWithinLimits(_eth)
        public
    {
        // set up our tx event data
        RSdatasets.EventReturns memory _eventData_;
        
        // fetch player ID
        uint256 _pID = pIDxAddr_[msg.sender];
        
        // manage affiliate residuals
        uint256 _affID;
        // if no affiliate code was given or player tried to use their own, lolz
        if (_affCode == address(0) || _affCode == msg.sender)
        {
            // use last stored affiliate code
            _affID = plyr_[_pID].laff;
        
        // if affiliate code was given    
        } else {
            // get affiliate ID from aff Code 
            _affID = pIDxAddr_[_affCode];
            
            // if affID is not the same as previously stored 
            if (_affID != plyr_[_pID].laff)
            {
                // update last affiliate
                plyr_[_pID].laff = _affID;
            }
        }
                
        // reload core
        reLoadCore(_pID, _affID, _eth, _eventData_);
    }
    
    function reLoadXname(bytes32 _affCode, uint256 _eth)
        isActivated()
        isHuman()
        isWithinLimits(_eth)
        public
    {
        // set up our tx event data
        RSdatasets.EventReturns memory _eventData_;
        
        // fetch player ID
        uint256 _pID = pIDxAddr_[msg.sender];
        
        // manage affiliate residuals
        uint256 _affID;
        // if no affiliate code was given or player tried to use their own, lolz
        if (_affCode == '' || _affCode == plyr_[_pID].name)
        {
            // use last stored affiliate code
            _affID = plyr_[_pID].laff;
        
        // if affiliate code was given
        } else {
            // get affiliate ID from aff Code
            _affID = pIDxName_[_affCode];
            
            // if affID is not the same as previously stored
            if (_affID != plyr_[_pID].laff)
            {
                // update last affiliate
                plyr_[_pID].laff = _affID;
            }
        }
                
        // reload core
        reLoadCore(_pID, _affID, _eth, _eventData_);
    }

    /**
     * @dev withdraws all of your earnings.
     * -functionhash- 0x3ccfd60b
     */
    function withdraw()
        isActivated()
        isHuman()
        public
    {        
        // grab time
        uint256 _now = now;
        
        // fetch player ID
        uint256 _pID = pIDxAddr_[msg.sender];
        
        // setup temp var for player eth
        uint256 _eth;
        
        // check to see if round has ended and no one has run round end yet
        if (_now > round_.end && round_.ended == false && round_.plyr != 0)
        {
            // set up our tx event data
            RSdatasets.EventReturns memory _eventData_;
            
            // end the round (distributes pot)
			round_.ended = true;
            _eventData_ = endRound(_eventData_);
            
			// get their earnings
            _eth = withdrawEarnings(_pID);
            
            // gib moni
            if (_eth > 0)
                plyr_[_pID].addr.transfer(_eth);    
            
            // build event data
            _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
            _eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
            
            // fire withdraw and distribute event
            emit RSEvents.onWithdrawAndDistribute
            (
                msg.sender, 
                plyr_[_pID].name, 
                _eth, 
                _eventData_.compressedData, 
                _eventData_.compressedIDs, 
                _eventData_.winnerAddr, 
                _eventData_.winnerName, 
                _eventData_.amountWon, 
                _eventData_.newPot, 
                _eventData_.genAmount
            );
            
        // in any other situation
        } else {
            // get their earnings
            _eth = withdrawEarnings(_pID);
            
            // gib moni
            if (_eth > 0)
                plyr_[_pID].addr.transfer(_eth);
            
            // fire withdraw event
            emit RSEvents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now);
        }
    }
    
    /**
     * @dev use these to register names.  they are just wrappers that will send the
     * registration requests to the PlayerBook contract.  So registering here is the 
     * same as registering there.  UI will always display the last name you registered.
     * but you will still own all previously registered names to use as affiliate 
     * links.
     * - must pay a registration fee.
     * - name must be unique
     * - names will be converted to lowercase
     * - name cannot start or end with a space 
     * - cannot have more than 1 space in a row
     * - cannot be only numbers
     * - cannot start with 0x 
     * - name must be at least 1 char
     * - max length of 32 characters long
     * - allowed characters: a-z, 0-9, and space
     * -functionhash- 0x921dec21 (using ID for affiliate)
     * -functionhash- 0x3ddd4698 (using address for affiliate)
     * -functionhash- 0x685ffd83 (using name for affiliate)
     * @param _nameString players desired name
     * @param _affCode affiliate ID, address, or name of who referred you
     * @param _all set to true if you want this to push your info to all games 
     * (this might cost a lot of gas)
     */
    function registerNameXID(string _nameString, uint256 _affCode, bool _all)
        isHuman()
        public
        payable
    {
        bytes32 _name = _nameString.nameFilter();
        address _addr = msg.sender;
        uint256 _paid = msg.value;
        (bool _isNewPlayer, uint256 _affID) = RatBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all);

        uint256 _pID = pIDxAddr_[_addr];
        
        // fire event
        emit RSEvents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
    }
    
    function registerNameXaddr(string _nameString, address _affCode, bool _all)
        isHuman()
        public
        payable
    {
        bytes32 _name = _nameString.nameFilter();
        address _addr = msg.sender;
        uint256 _paid = msg.value;
        (bool _isNewPlayer, uint256 _affID) = RatBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all);
        
        uint256 _pID = pIDxAddr_[_addr];
        
        // fire event
        emit RSEvents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
    }
    
    function registerNameXname(string _nameString, bytes32 _affCode, bool _all)
        isHuman()
        public
        payable
    {
        bytes32 _name = _nameString.nameFilter();
        address _addr = msg.sender;
        uint256 _paid = msg.value;
        (bool _isNewPlayer, uint256 _affID) = RatBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all);
        
        uint256 _pID = pIDxAddr_[_addr];
        
        // fire event
        emit RSEvents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
    }
//==============================================================================
//     _  _ _|__|_ _  _ _  .
//    (_|(/_ |  | (/_| _\  . (for UI & viewing things on etherscan)
//=====_|=======================================================================
    /**
     * @dev return the price buyer will pay for next 1 individual key.
     * -functionhash- 0x018a25e8
     * @return price for next key bought (in wei format)
     */
    function getBuyPrice()
        public 
        view 
        returns(uint256)
    {          
        // grab time
        uint256 _now = now;
        
        // are we in a round?
        if (_now > round_.strt + rndGap_ && (_now <= round_.end || (_now > round_.end && round_.plyr == 0)))
            return ( (round_.keys.add(1000000000000000000)).ethRec(1000000000000000000) );
        else // rounds over.  need price for new round
            return ( 75000000000000 ); // init
    }
    
    /**
     * @dev returns time left.  dont spam this, you'll ddos yourself from your node 
     * provider
     * -functionhash- 0xc7e284b8
     * @return time left in seconds
     */
    function getTimeLeft()
        public
        view
        returns(uint256)
    {
        // grab time
        uint256 _now = now;
        
        if (_now < round_.end)
            if (_now > round_.strt + rndGap_)
                return( (round_.end).sub(_now) );
            else
                return( (round_.strt + rndGap_).sub(_now));
        else
            return(0);
    }
    
    /**
     * @dev returns player earnings per vaults 
     * -functionhash- 0x63066434
     * @return winnings vault
     * @return general vault
     * @return affiliate vault
     */
    function getPlayerVaults(uint256 _pID)
        public
        view
        returns(uint256 ,uint256, uint256)
    {
        // if round has ended.  but round end has not been run (so contract has not distributed winnings)
        if (now > round_.end && round_.ended == false && round_.plyr != 0)
        {
            // if player is winner 
            if (round_.plyr == _pID)
            {
                return
                (
                    (plyr_[_pID].win).add( ((round_.pot).mul(48)) / 100 ),
                    (plyr_[_pID].gen).add(  getPlayerVaultsHelper(_pID).sub(plyrRnds_[_pID].mask)   ),
                    plyr_[_pID].aff
                );
            // if player is not the winner
            } else {
                return
                (
                    plyr_[_pID].win,
                    (plyr_[_pID].gen).add(  getPlayerVaultsHelper(_pID).sub(plyrRnds_[_pID].mask)  ),
                    plyr_[_pID].aff
                );
            }
            
        // if round is still going on, or round has ended and round end has been ran
        } else {
            return
            (
                plyr_[_pID].win,
                (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID)),
                plyr_[_pID].aff
            );
        }
    }
    
    /**
     * solidity hates stack limits.  this lets us avoid that hate 
     */
    function getPlayerVaultsHelper(uint256 _pID)
        private
        view
        returns(uint256)
    {
        return(  ((((round_.mask).add(((((round_.pot).mul(potSplit_)) / 100).mul(1000000000000000000)) / (round_.keys))).mul(plyrRnds_[_pID].keys)) / 1000000000000000000)  );
    }
    
    /**
     * @dev returns all current round info needed for front end
     * -functionhash- 0x747dff42
     * @return total keys
     * @return time ends
     * @return time started
     * @return current pot 
     * @return current player ID in lead 
     * @return current player in leads address 
     * @return current player in leads name
     * @return airdrop tracker # & airdrop pot
     */
    function getCurrentRoundInfo()
        public
        view
        returns(uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256)
    {
        return
        (
            round_.keys,              //0
            round_.end,               //1
            round_.strt,              //2
            round_.pot,               //3
            round_.plyr,              //4
            plyr_[round_.plyr].addr,  //5
            plyr_[round_.plyr].name,  //6
            airDropTracker_ + (airDropPot_ * 1000)              //7
        );
    }

    /**
     * @dev returns player info based on address.  if no address is given, it will 
     * use msg.sender 
     * -functionhash- 0xee0b5d8b
     * @param _addr address of the player you want to lookup 
     * @return player ID 
     * @return player name
     * @return keys owned (current round)
     * @return winnings vault
     * @return general vault 
     * @return affiliate vault 
	 * @return player round eth
     */
    function getPlayerInfoByAddress(address _addr)
        public 
        view 
        returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256)
    {
        if (_addr == address(0))
        {
            _addr == msg.sender;
        }
        uint256 _pID = pIDxAddr_[_addr];
        
        return
        (
            _pID,                               //0
            plyr_[_pID].name,                   //1
            plyrRnds_[_pID].keys,         //2
            plyr_[_pID].win,                    //3
            (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID)),       //4
            plyr_[_pID].aff,                    //5
            plyrRnds_[_pID].eth           //6
        );
    }

//==============================================================================
//     _ _  _ _   | _  _ . _  .
//    (_(_)| (/_  |(_)(_||(_  . (this + tools + calcs + modules = our softwares engine)
//=====================_|=======================================================
    /**
     * @dev logic runs whenever a buy order is executed.  determines how to handle 
     * incoming eth depending on if we are in an active round or not
     */
    function buyCore(uint256 _pID, uint256 _affID, RSdatasets.EventReturns memory _eventData_)
        private
    {
        // grab time
        uint256 _now = now;
        
        // if round is active
        if (_now > round_.strt + rndGap_ && (_now <= round_.end || (_now > round_.end && round_.plyr == 0))) 
        {
            // call core 
            core(_pID, msg.value, _affID, _eventData_);
        
        // if round is not active     
        } else {
            // check to see if end round needs to be ran
            if (_now > round_.end && round_.ended == false) 
            {
                // end the round (distributes pot) & start new round
			    round_.ended = true;
                _eventData_ = endRound(_eventData_);
                
                // build event data
                _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
                _eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
                
                // fire buy and distribute event 
                emit RSEvents.onBuyAndDistribute
                (
                    msg.sender, 
                    plyr_[_pID].name, 
                    msg.value, 
                    _eventData_.compressedData, 
                    _eventData_.compressedIDs, 
                    _eventData_.winnerAddr, 
                    _eventData_.winnerName, 
                    _eventData_.amountWon, 
                    _eventData_.newPot, 
                    _eventData_.genAmount
                );
            }
            
            // put eth in players vault 
            plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value);
        }
    }
    
    /**
     * @dev logic runs whenever a reload order is executed.  determines how to handle 
     * incoming eth depending on if we are in an active round or not 
     */
    function reLoadCore(uint256 _pID, uint256 _affID, uint256 _eth, RSdatasets.EventReturns memory _eventData_)
        private
    {
        // grab time
        uint256 _now = now;
        
        // if round is active
        if (_now > round_.strt + rndGap_ && (_now <= round_.end || (_now > round_.end && round_.plyr == 0))) 
        {
            // get earnings from all vaults and return unused to gen vault
            // because we use a custom safemath library.  this will throw if player 
            // tried to spend more eth than they have.
            plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth);
            
            // call core 
            core(_pID, _eth, _affID, _eventData_);
        
        // if round is not active and end round needs to be ran   
        } else if (_now > round_.end && round_.ended == false) {
            // end the round (distributes pot) & start new round
            round_.ended = true;
            _eventData_ = endRound(_eventData_);
                
            // build event data
            _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
            _eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
                
            // fire buy and distribute event 
            emit RSEvents.onReLoadAndDistribute
            (
                msg.sender, 
                plyr_[_pID].name, 
                _eventData_.compressedData, 
                _eventData_.compressedIDs, 
                _eventData_.winnerAddr, 
                _eventData_.winnerName, 
                _eventData_.amountWon, 
                _eventData_.newPot, 
                _eventData_.genAmount
            );
        }
    }
    
    /**
     * @dev this is the core logic for any buy/reload that happens while a round 
     * is live.
     */
    function core(uint256 _pID, uint256 _eth, uint256 _affID, RSdatasets.EventReturns memory _eventData_)
        private
    {
        // if player is new to round
        if (plyrRnds_[_pID].keys == 0)
            _eventData_ = managePlayer(_pID, _eventData_);
        
        // early round eth limiter 
        if (round_.eth < 100000000000000000000 && plyrRnds_[_pID].eth.add(_eth) > 10000000000000000000)
        {
            uint256 _availableLimit = (10000000000000000000).sub(plyrRnds_[_pID].eth);
            uint256 _refund = _eth.sub(_availableLimit);
            plyr_[_pID].gen = plyr_[_pID].gen.add(_refund);
            _eth = _availableLimit;
        }
        
        // if eth left is greater than min eth allowed (sorry no pocket lint)
        if (_eth > 1000000000) 
        {
            
            // mint the new keys
            uint256 _keys = (round_.eth).keysRec(_eth);
            
            // if they bought at least 1 whole key
            if (_keys >= 1000000000000000000)
            {
            updateTimer(_keys);

            // set new leaders
            if (round_.plyr != _pID)
                round_.plyr = _pID;  
            
            // set the new leader bool to true
            _eventData_.compressedData = _eventData_.compressedData + 100;
        }
            
            // manage airdrops
            if (_eth >= 100000000000000000)
            {
            airDropTracker_++;
            if (airdrop() == true)
            {
                // gib muni
                uint256 _prize;
                if (_eth >= 10000000000000000000)
                {
                    // calculate prize and give it to winner
                    _prize = ((airDropPot_).mul(75)) / 100;
                    plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
                    
                    // adjust airDropPot 
                    airDropPot_ = (airDropPot_).sub(_prize);
                    
                    // let event know a tier 3 prize was won 
                    _eventData_.compressedData += 300000000000000000000000000000000;
                } else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) {
                    // calculate prize and give it to winner
                    _prize = ((airDropPot_).mul(50)) / 100;
                    plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
                    
                    // adjust airDropPot 
                    airDropPot_ = (airDropPot_).sub(_prize);
                    
                    // let event know a tier 2 prize was won 
                    _eventData_.compressedData += 200000000000000000000000000000000;
                } else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) {
                    // calculate prize and give it to winner
                    _prize = ((airDropPot_).mul(25)) / 100;
                    plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
                    
                    // adjust airDropPot 
                    airDropPot_ = (airDropPot_).sub(_prize);
                    
                    // let event know a tier 1 prize was won 
                    _eventData_.compressedData += 100000000000000000000000000000000;
                }
                // set airdrop happened bool to true
                _eventData_.compressedData += 10000000000000000000000000000000;
                // let event know how much was won 
                _eventData_.compressedData += _prize * 1000000000000000000000000000000000;
                
                // reset air drop tracker
                airDropTracker_ = 0;
            }
        }
    
            // store the air drop tracker number (number of buys since last airdrop)
            _eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000);
            
            // update player 
            plyrRnds_[_pID].keys = _keys.add(plyrRnds_[_pID].keys);
            plyrRnds_[_pID].eth = _eth.add(plyrRnds_[_pID].eth);
            
            // update round
            round_.keys = _keys.add(round_.keys);
            round_.eth = _eth.add(round_.eth);
    
            bool DistributeGenShare;
            if (_affID != _pID && plyr_[_affID].name != '') {
                DistributeGenShare = false;
            }
            else{
                DistributeGenShare = true;
            }
            // distribute eth
            _eventData_ = distributeExternal(_pID, _eth, _affID, _eventData_);
            _eventData_ = distributeInternal(_pID, _eth, _keys, _eventData_, DistributeGenShare);
            
            // call end tx function to fire end tx event.
		    endTx(_pID, _eth, _keys, _eventData_);
        }
    }
//==============================================================================
//     _ _ | _   | _ _|_ _  _ _  .
//    (_(_||(_|_||(_| | (_)| _\  .
//==============================================================================
    /**
     * @dev calculates unmasked earnings (just calculates, does not update mask)
     * @return earnings in wei format
     */
    function calcUnMaskedEarnings(uint256 _pID)
        private
        view
        returns(uint256)
    {
        return((((round_.mask).mul(plyrRnds_[_pID].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID].mask));
    }
    
    /** 
     * @dev returns the amount of keys you would get given an amount of eth. 
     * -functionhash- 0xce89c80c
     * @param _eth amount of eth sent in 
     * @return keys received 
     */
    function calcKeysReceived(uint256 _eth)
        public
        view
        returns(uint256)
    {
        // grab time
        uint256 _now = now;
        
        // are we in a round?
        if (_now > round_.strt + rndGap_ && (_now <= round_.end || (_now > round_.end && round_.plyr == 0)))
            return ( (round_.eth).keysRec(_eth) );
        else // rounds over.  need keys for new round
            return ( (_eth).keys() );
    }
    
    /** 
     * @dev returns current eth price for X keys.  
     * -functionhash- 0xcf808000
     * @param _keys number of keys desired (in 18 decimal format)
     * @return amount of eth needed to send
     */
    function iWantXKeys(uint256 _keys)
        public
        view
        returns(uint256)
    {
        // grab time
        uint256 _now = now;
        
        // are we in a round?
        if (_now > round_.strt + rndGap_ && (_now <= round_.end || (_now > round_.end && round_.plyr == 0)))
            return ( (round_.keys.add(_keys)).ethRec(_keys) );
        else // rounds over.  need price for new round
            return ( (_keys).eth() );
    }
//==============================================================================
//    _|_ _  _ | _  .
//     | (_)(_)|_\  .
//==============================================================================
    /**
	 * @dev receives name/player info from names contract 
     */
    function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff)
        external
    {
        require (msg.sender == address(RatBook), "only RatBook can call this function");
        if (pIDxAddr_[_addr] != _pID)
            pIDxAddr_[_addr] = _pID;
        if (pIDxName_[_name] != _pID)
            pIDxName_[_name] = _pID;
        if (plyr_[_pID].addr != _addr)
            plyr_[_pID].addr = _addr;
        if (plyr_[_pID].name != _name)
            plyr_[_pID].name = _name;
        if (plyr_[_pID].laff != _laff)
            plyr_[_pID].laff = _laff;
        if (plyrNames_[_pID][_name] == false)
            plyrNames_[_pID][_name] = true;
    }
    
    /**
     * @dev receives entire player name list 
     */
    function receivePlayerNameList(uint256 _pID, bytes32 _name)
        external
    {
        require (msg.sender == address(RatBook), "only RatBook can call this function");
        if(plyrNames_[_pID][_name] == false)
            plyrNames_[_pID][_name] = true;
    }   
        
    /**
     * @dev gets existing or registers new pID.  use this when a player may be new
     * @return pID 
     */
    function determinePID(RSdatasets.EventReturns memory _eventData_)
        private
        returns (RSdatasets.EventReturns)
    {
        uint256 _pID = pIDxAddr_[msg.sender];
        // if player is new to this version of ratscam
        if (_pID == 0)
        {
            // grab their player ID, name and last aff ID, from player names contract 
            _pID = RatBook.getPlayerID(msg.sender);
            bytes32 _name = RatBook.getPlayerName(_pID);
            uint256 _laff = RatBook.getPlayerLAff(_pID);
            
            // set up player account 
            pIDxAddr_[msg.sender] = _pID;
            plyr_[_pID].addr = msg.sender;
            
            if (_name != "")
            {
                pIDxName_[_name] = _pID;
                plyr_[_pID].name = _name;
                plyrNames_[_pID][_name] = true;
            }
            
            if (_laff != 0 && _laff != _pID)
                plyr_[_pID].laff = _laff;
            
            // set the new player bool to true
            _eventData_.compressedData = _eventData_.compressedData + 1;
        } 
        return (_eventData_);
    }

    /**
     * @dev decides if round end needs to be run & new round started.  and if 
     * player unmasked earnings from previously played rounds need to be moved.
     */
    function managePlayer(uint256 _pID, RSdatasets.EventReturns memory _eventData_)
        private
        returns (RSdatasets.EventReturns)
    {            
        // set the joined round bool to true
        _eventData_.compressedData = _eventData_.compressedData + 10;
        
        return(_eventData_);
    }
    
    /**
     * @dev ends the round. manages paying out winner/splitting up pot
     */
    function endRound(RSdatasets.EventReturns memory _eventData_)
        private
        returns (RSdatasets.EventReturns)
    {        
        // grab our winning player and team id's
        uint256 _winPID = round_.plyr;
        
        // grab our pot amount
        // add airdrop pot into the final pot
        uint256 _pot = round_.pot + airDropPot_;
        
        // calculate our winner share, community rewards, gen share, 
        // p3d share, and amount reserved for next pot 
        uint256 _win = (_pot.mul(45)) / 100;
        uint256 _com = (_pot / 10);
        uint256 _gen = (_pot.mul(potSplit_)) / 100;
        
        // calculate ppt for round mask
        uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_.keys);
        uint256 _dust = _gen.sub((_ppt.mul(round_.keys)) / 1000000000000000000);
        if (_dust > 0)
        {
            _gen = _gen.sub(_dust);
            _com = _com.add(_dust);
        }
        
        // pay our winner
        plyr_[_winPID].win = _win.add(plyr_[_winPID].win);
        
        // community rewards
        if (!address(RatKingCorp).call.value(_com)(bytes4(keccak256("deposit()"))))
        {
            _gen = _gen.add(_com);
            _com = 0;
        }
        
        // distribute gen portion to key holders
        round_.mask = _ppt.add(round_.mask);
            
        // prepare event data
        _eventData_.compressedData = _eventData_.compressedData + (round_.end * 1000000);
        _eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000);
        _eventData_.winnerAddr = plyr_[_winPID].addr;
        _eventData_.winnerName = plyr_[_winPID].name;
        _eventData_.amountWon = _win;
        _eventData_.genAmount = _gen;
        _eventData_.newPot = 0;
        
        return(_eventData_);
    }
    
    /**
     * @dev moves any unmasked earnings to gen vault.  updates earnings mask
     */
    function updateGenVault(uint256 _pID)
        private 
    {
        uint256 _earnings = calcUnMaskedEarnings(_pID);
        if (_earnings > 0)
        {
            // put in gen vault
            plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen);
            // zero out their earnings by updating mask
            plyrRnds_[_pID].mask = _earnings.add(plyrRnds_[_pID].mask);
        }
    }
    
    /**
     * @dev updates round timer based on number of whole keys bought.
     */
    function updateTimer(uint256 _keys)
        private
    {
        // grab time
        uint256 _now = now;
        
        // calculate time based on number of keys bought
        uint256 _newTime;
        if (_now > round_.end && round_.plyr == 0)
            _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now);
        else
            _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_.end);
        
        // compare to max and set new end time
        if (_newTime < (rndMax_).add(_now))
            round_.end = _newTime;
        else
            round_.end = rndMax_.add(_now);
    }
    
    /**
     * @dev generates a random number between 0-99 and checks to see if thats
     * resulted in an airdrop win
     * @return do we have a winner?
     */
    function airdrop()
        private 
        view 
        returns(bool)
    {
        uint256 seed = uint256(keccak256(abi.encodePacked(
            
            (block.timestamp).add
            (block.difficulty).add
            ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add
            (block.gaslimit).add
            ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add
            (block.number)
            
        )));
        if((seed - ((seed / 1000) * 1000)) < airDropTracker_)
            return(true);
        else
            return(false);
    }

    /**
     * @dev distributes eth based on fees to com, aff, and p3d
     */
    function distributeExternal(uint256 _pID, uint256 _eth, uint256 _affID, RSdatasets.EventReturns memory _eventData_)
        private
        returns(RSdatasets.EventReturns)
    {
        // pay 5% out to community rewards
        uint256 _com = _eth * 5 / 100;
                
        // distribute share to affiliate
        uint256 _aff = _eth / 10;
        
        // decide what to do with affiliate share of fees
        // affiliate must not be self, and must have a name registered
        if (_affID != _pID && plyr_[_affID].name != '') {
            plyr_[_affID].aff = _aff.add(plyr_[_affID].aff);
            emit RSEvents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _pID, _aff, now);
        } else {
            // no affiliates, add as divs [this is already done in distributeInternal]
           // plyr_[_pID].aff = _aff.add(plyr_[_pID].aff);
        }

        if (!address(RatKingCorp).call.value(_com)(bytes4(keccak256("deposit()"))))
        {
            // This ensures Team Just cannot influence the outcome of FoMo3D with
            // bank migrations by breaking outgoing transactions.
            // Something we would never do. But that's not the point.
            // We spent 2000$ in eth re-deploying just to patch this, we hold the 
            // highest belief that everything we create should be trustless.
            // Team JUST, The name you shouldn't have to trust.
        }

        return(_eventData_);
    }
    
    /**
     * @dev distributes eth based on fees to gen and pot
     */
    function distributeInternal(uint256 _pID, uint256 _eth, uint256 _keys, RSdatasets.EventReturns memory _eventData_, bool dgs)
        private
        returns(RSdatasets.EventReturns)
    {
        // calculate gen share
        uint256 _gen = (_eth.mul(fees_)) / 100;
        
        if (dgs){
            // no affiliate found so we dump it to keyholders
            _gen = _gen.add( (_eth.mul(10)) / 100);
        }
        
        // toss 5% into airdrop pot 
        uint256 _air = (_eth / 20);
        airDropPot_ = airDropPot_.add(_air);
                
        // calculate pot (20%) 
        uint256 _pot = (_eth.mul(20) / 100);
        
        // distribute gen share (thats what updateMasks() does) and adjust
        // balances for dust.
        uint256 _dust = updateMasks(_pID, _gen, _keys);
        if (_dust > 0)
            _gen = _gen.sub(_dust);
        
        // add eth to pot
        round_.pot = _pot.add(_dust).add(round_.pot);
        
        // set up event data
        _eventData_.genAmount = _gen.add(_eventData_.genAmount);
        _eventData_.potAmount = _pot;
        
        return(_eventData_);
    }

    /**
     * @dev updates masks for round and player when keys are bought
     * @return dust left over 
     */
    function updateMasks(uint256 _pID, uint256 _gen, uint256 _keys)
        private
        returns(uint256)
    {
        /* MASKING NOTES
            earnings masks are a tricky thing for people to wrap their minds around.
            the basic thing to understand here.  is were going to have a global
            tracker based on profit per share for each round, that increases in
            relevant proportion to the increase in share supply.
            
            the player will have an additional mask that basically says "based
            on the rounds mask, my shares, and how much i've already withdrawn,
            how much is still owed to me?"
        */
        
        // calc profit per key & round mask based on this buy:  (dust goes to pot)
        uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_.keys);
        round_.mask = _ppt.add(round_.mask);
            
        // calculate player earning from their own buy (only based on the keys
        // they just bought).  & update player earnings mask
        uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000);
        plyrRnds_[_pID].mask = (((round_.mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID].mask);
        
        // calculate & return dust
        return(_gen.sub((_ppt.mul(round_.keys)) / (1000000000000000000)));
    }
    
    /**
     * @dev adds up unmasked earnings, & vault earnings, sets them all to 0
     * @return earnings in wei format
     */
    function withdrawEarnings(uint256 _pID)
        private
        returns(uint256)
    {
        // update gen vault
        updateGenVault(_pID);
        
        // from vaults 
        uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff);
        if (_earnings > 0)
        {
            plyr_[_pID].win = 0;
            plyr_[_pID].gen = 0;
            plyr_[_pID].aff = 0;
        }

        return(_earnings);
    }
    
    /**
     * @dev prepares compression data and fires event for buy or reload tx's
     */
    function endTx(uint256 _pID, uint256 _eth, uint256 _keys, RSdatasets.EventReturns memory _eventData_)
        private
    {
        _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000);
        _eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
        
        emit RSEvents.onEndTx
        (
            _eventData_.compressedData,
            _eventData_.compressedIDs,
            plyr_[_pID].name,
            msg.sender,
            _eth,
            _keys,
            _eventData_.winnerAddr,
            _eventData_.winnerName,
            _eventData_.amountWon,
            _eventData_.newPot,
            _eventData_.genAmount,
            _eventData_.potAmount,
            airDropPot_
        );
    }

    /** upon contract deploy, it will be deactivated.  this is a one time
     * use function that will activate the co...

// [truncated — 60623 bytes total]

Read Contract

activated_ 0xd53b2679 → bool
airDropPot_ 0xd87574e0 → uint256
airDropTracker_ 0x11a09ae7 → uint256
calcKeysReceived 0x409dba83 → uint256
fees_ 0x200373c9 → uint256
getBuyPrice 0x018a25e8 → uint256
getCurrentRoundInfo 0x747dff42 → uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256
getPlayerInfoByAddress 0xee0b5d8b → uint256, bytes32, uint256, uint256, uint256, uint256, uint256
getPlayerVaults 0x63066434 → uint256, uint256, uint256
getTimeLeft 0xc7e284b8 → uint256
iWantXKeys 0xcf808000 → uint256
name 0x06fdde03 → string
pIDxAddr_ 0x10f01eba → uint256
pIDxName_ 0x2e19ebdc → uint256
plyrNames_ 0x2660316e → bool
plyrRnds_ 0x93204075 → uint256, uint256, uint256
plyr_ 0xde7874f3 → address, bytes32, uint256, uint256, uint256, uint256
potSplit_ 0x58d162da → uint256
round_ 0x37c30a98 → uint256, uint256, bool, uint256, uint256, uint256, uint256, uint256
symbol 0x95d89b41 → string

Write Contract 13 functions

These functions modify contract state and require a wallet transaction to execute.

activate 0x0f15f4c0
No parameters
buyXaddr 0xaeeed0db
address _affCode
buyXid 0xcd133c8f
uint256 _affCode
buyXname 0x438d359e
bytes32 _affCode
reLoadXaddr 0x015008b1
address _affCode
uint256 _eth
reLoadXid 0x8f8a5832
uint256 _affCode
uint256 _eth
reLoadXname 0xfb9073eb
bytes32 _affCode
uint256 _eth
receivePlayerInfo 0x49cc635d
uint256 _pID
address _addr
bytes32 _name
uint256 _laff
receivePlayerNameList 0x8f7140ea
uint256 _pID
bytes32 _name
registerNameXID 0x921dec21
string _nameString
uint256 _affCode
bool _all
registerNameXaddr 0x3ddd4698
string _nameString
address _affCode
bool _all
registerNameXname 0x685ffd83
string _nameString
bytes32 _affCode
bool _all
withdraw 0x3ccfd60b
No parameters

Recent Transactions

This address has 1 on-chain transactions, but only 1.3% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →