Spaces:
Runtime error
Runtime error
File size: 21,444 Bytes
ee7776a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
pragma solidity ^0.4.18;
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Claimable is Ownable {
address public pendingOwner;
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
pendingOwner = newOwner;
}
function claimOwnership() onlyPendingOwner public {
OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
}
}
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
function pause() onlyOwner whenNotPaused public {
paused = true;
Pause();
}
function unpause() onlyOwner whenPaused public {
paused = false;
Unpause();
}
}
contract AccessDeploy is Claimable {
mapping(address => bool) private deployAccess;
modifier onlyAccessDeploy {
require(msg.sender == owner || deployAccess[msg.sender] == true);
_;
}
function grantAccessDeploy(address _address)
onlyOwner
public
{
deployAccess[_address] = true;
}
function revokeAccessDeploy(address _address)
onlyOwner
public
{
deployAccess[_address] = false;
}
}
contract AccessDeposit is Claimable {
mapping(address => bool) private depositAccess;
modifier onlyAccessDeposit {
require(msg.sender == owner || depositAccess[msg.sender] == true);
_;
}
function grantAccessDeposit(address _address)
onlyOwner
public
{
depositAccess[_address] = true;
}
function revokeAccessDeposit(address _address)
onlyOwner
public
{
depositAccess[_address] = false;
}
}
contract AccessMint is Claimable {
mapping(address => bool) private mintAccess;
modifier onlyAccessMint {
require(msg.sender == owner || mintAccess[msg.sender] == true);
_;
}
function grantAccessMint(address _address)
onlyOwner
public
{
mintAccess[_address] = true;
}
function revokeAccessMint(address _address)
onlyOwner
public
{
mintAccess[_address] = false;
}
}
contract ERC721 {
event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
function balanceOf(address _owner) public view returns (uint256 _balance);
function ownerOf(uint256 _tokenId) public view returns (address _owner);
function transfer(address _to, uint256 _tokenId) public;
function approve(address _to, uint256 _tokenId) public;
function takeOwnership(uint256 _tokenId) public;
}
contract ERC721Token is ERC721 {
using SafeMath for uint256;
uint256 private totalTokens;
mapping (uint256 => address) private tokenOwner;
mapping (uint256 => address) private tokenApprovals;
mapping (address => uint256[]) private ownedTokens;
mapping(uint256 => uint256) private ownedTokensIndex;
modifier onlyOwnerOf(uint256 _tokenId) {
require(ownerOf(_tokenId) == msg.sender);
_;
}
function totalSupply() public view returns (uint256) {
return totalTokens;
}
function balanceOf(address _owner) public view returns (uint256) {
return ownedTokens[_owner].length;
}
function tokensOf(address _owner) public view returns (uint256[]) {
return ownedTokens[_owner];
}
function ownerOf(uint256 _tokenId) public view returns (address) {
address owner = tokenOwner[_tokenId];
require(owner != address(0));
return owner;
}
function approvedFor(uint256 _tokenId) public view returns (address) {
return tokenApprovals[_tokenId];
}
function transfer(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
clearApprovalAndTransfer(msg.sender, _to, _tokenId);
}
function approve(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
address owner = ownerOf(_tokenId);
require(_to != owner);
if (approvedFor(_tokenId) != 0 || _to != 0) {
tokenApprovals[_tokenId] = _to;
Approval(owner, _to, _tokenId);
}
}
function takeOwnership(uint256 _tokenId) public {
require(isApprovedFor(msg.sender, _tokenId));
clearApprovalAndTransfer(ownerOf(_tokenId), msg.sender, _tokenId);
}
function _mint(address _to, uint256 _tokenId) internal {
require(_to != address(0));
addToken(_to, _tokenId);
Transfer(0x0, _to, _tokenId);
}
function _burn(uint256 _tokenId) onlyOwnerOf(_tokenId) internal {
if (approvedFor(_tokenId) != 0) {
clearApproval(msg.sender, _tokenId);
}
removeToken(msg.sender, _tokenId);
Transfer(msg.sender, 0x0, _tokenId);
}
function isApprovedFor(address _owner, uint256 _tokenId) internal view returns (bool) {
return approvedFor(_tokenId) == _owner;
}
function clearApprovalAndTransfer(address _from, address _to, uint256 _tokenId) internal {
require(_to != address(0));
require(_to != ownerOf(_tokenId));
require(ownerOf(_tokenId) == _from);
clearApproval(_from, _tokenId);
removeToken(_from, _tokenId);
addToken(_to, _tokenId);
Transfer(_from, _to, _tokenId);
}
function clearApproval(address _owner, uint256 _tokenId) private {
require(ownerOf(_tokenId) == _owner);
tokenApprovals[_tokenId] = 0;
Approval(_owner, 0, _tokenId);
}
function addToken(address _to, uint256 _tokenId) private {
require(tokenOwner[_tokenId] == address(0));
tokenOwner[_tokenId] = _to;
uint256 length = balanceOf(_to);
ownedTokens[_to].push(_tokenId);
ownedTokensIndex[_tokenId] = length;
totalTokens = totalTokens.add(1);
}
function removeToken(address _from, uint256 _tokenId) private {
require(ownerOf(_tokenId) == _from);
uint256 tokenIndex = ownedTokensIndex[_tokenId];
uint256 lastTokenIndex = balanceOf(_from).sub(1);
uint256 lastToken = ownedTokens[_from][lastTokenIndex];
tokenOwner[_tokenId] = 0;
ownedTokens[_from][tokenIndex] = lastToken;
ownedTokens[_from][lastTokenIndex] = 0;
ownedTokens[_from].length--;
ownedTokensIndex[_tokenId] = 0;
ownedTokensIndex[lastToken] = tokenIndex;
totalTokens = totalTokens.sub(1);
}
}
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public view returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
}
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
contract Gold is StandardToken, Claimable, AccessMint {
string public constant name = "Gold";
string public constant symbol = "G";
uint8 public constant decimals = 18;
event Mint(
address indexed _to,
uint256 indexed _tokenId
);
function mint(address _to, uint256 _amount)
onlyAccessMint
public
returns (bool)
{
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
}
contract CryptoSagaHero is ERC721Token, Claimable, Pausable, AccessMint, AccessDeploy, AccessDeposit {
string public constant name = "CryptoSaga Hero";
string public constant symbol = "HERO";
struct HeroClass {
string className;
uint8 classRank;
uint8 classRace;
uint32 classAge;
uint8 classType;
uint32 maxLevel;
uint8 aura;
uint32[5] baseStats;
uint32[5] minIVForStats;
uint32[5] maxIVForStats;
uint32 currentNumberOfInstancedHeroes;
}
struct HeroInstance {
uint32 heroClassId;
string heroName;
uint32 currentLevel;
uint32 currentExp;
uint32 lastLocationId;
uint256 availableAt;
uint32[5] currentStats;
uint32[5] ivForStats;
}
uint32 public requiredExpIncreaseFactor = 100;
uint256 public requiredGoldIncreaseFactor = 1000000000000000000;
mapping(uint32 => HeroClass) public heroClasses;
uint32 public numberOfHeroClasses;
mapping(uint256 => HeroInstance) public tokenIdToHeroInstance;
uint256 public numberOfTokenIds;
Gold public goldContract;
mapping(address => uint256) public addressToGoldDeposit;
uint32 private seed = 0;
event DefineType(
address indexed _by,
uint32 indexed _typeId,
string _className
);
event LevelUp(
address indexed _by,
uint256 indexed _tokenId,
uint32 _newLevel
);
event Deploy(
address indexed _by,
uint256 indexed _tokenId,
uint32 _locationId,
uint256 _duration
);
function getClassInfo(uint32 _classId)
external view
returns (string className, uint8 classRank, uint8 classRace, uint32 classAge, uint8 classType, uint32 maxLevel, uint8 aura, uint32[5] baseStats, uint32[5] minIVs, uint32[5] maxIVs)
{
var _cl = heroClasses[_classId];
return (_cl.className, _cl.classRank, _cl.classRace, _cl.classAge, _cl.classType, _cl.maxLevel, _cl.aura, _cl.baseStats, _cl.minIVForStats, _cl.maxIVForStats);
}
function getClassName(uint32 _classId)
external view
returns (string)
{
return heroClasses[_classId].className;
}
function getClassRank(uint32 _classId)
external view
returns (uint8)
{
return heroClasses[_classId].classRank;
}
function getClassMintCount(uint32 _classId)
external view
returns (uint32)
{
return heroClasses[_classId].currentNumberOfInstancedHeroes;
}
function getHeroInfo(uint256 _tokenId)
external view
returns (uint32 classId, string heroName, uint32 currentLevel, uint32 currentExp, uint32 lastLocationId, uint256 availableAt, uint32[5] currentStats, uint32[5] ivs, uint32 bp)
{
HeroInstance memory _h = tokenIdToHeroInstance[_tokenId];
var _bp = _h.currentStats[0] + _h.currentStats[1] + _h.currentStats[2] + _h.currentStats[3] + _h.currentStats[4];
return (_h.heroClassId, _h.heroName, _h.currentLevel, _h.currentExp, _h.lastLocationId, _h.availableAt, _h.currentStats, _h.ivForStats, _bp);
}
function getHeroClassId(uint256 _tokenId)
external view
returns (uint32)
{
return tokenIdToHeroInstance[_tokenId].heroClassId;
}
function getHeroName(uint256 _tokenId)
external view
returns (string)
{
return tokenIdToHeroInstance[_tokenId].heroName;
}
function getHeroLevel(uint256 _tokenId)
external view
returns (uint32)
{
return tokenIdToHeroInstance[_tokenId].currentLevel;
}
function getHeroLocation(uint256 _tokenId)
external view
returns (uint32)
{
return tokenIdToHeroInstance[_tokenId].lastLocationId;
}
function getHeroAvailableAt(uint256 _tokenId)
external view
returns (uint256)
{
return tokenIdToHeroInstance[_tokenId].availableAt;
}
function getHeroBP(uint256 _tokenId)
public view
returns (uint32)
{
var _tmp = tokenIdToHeroInstance[_tokenId].currentStats;
return (_tmp[0] + _tmp[1] + _tmp[2] + _tmp[3] + _tmp[4]);
}
function getHeroRequiredGoldForLevelUp(uint256 _tokenId)
public view
returns (uint256)
{
return (uint256(2) ** (tokenIdToHeroInstance[_tokenId].currentLevel / 10)) * requiredGoldIncreaseFactor;
}
function getHeroRequiredExpForLevelUp(uint256 _tokenId)
public view
returns (uint32)
{
return ((tokenIdToHeroInstance[_tokenId].currentLevel + 2) * requiredExpIncreaseFactor);
}
function getGoldDepositOfAddress(address _address)
external view
returns (uint256)
{
return addressToGoldDeposit[_address];
}
function getTokenIdOfAddressAndIndex(address _address, uint256 _index)
external view
returns (uint256)
{
return tokensOf(_address)[_index];
}
function getTotalBPOfAddress(address _address)
external view
returns (uint32)
{
var _tokens = tokensOf(_address);
uint32 _totalBP = 0;
for (uint256 i = 0; i < _tokens.length; i ++) {
_totalBP += getHeroBP(_tokens[i]);
}
return _totalBP;
}
function setHeroName(uint256 _tokenId, string _name)
onlyOwnerOf(_tokenId)
public
{
tokenIdToHeroInstance[_tokenId].heroName = _name;
}
function setGoldContract(address _contractAddress)
onlyOwner
public
{
goldContract = Gold(_contractAddress);
}
function setRequiredExpIncreaseFactor(uint32 _value)
onlyOwner
public
{
requiredExpIncreaseFactor = _value;
}
function setRequiredGoldIncreaseFactor(uint256 _value)
onlyOwner
public
{
requiredGoldIncreaseFactor = _value;
}
function CryptoSagaHero(address _goldAddress)
public
{
require(_goldAddress != address(0));
setGoldContract(_goldAddress);
defineType("Archangel", 4, 1, 13540, 0, 99, 3, [uint32(74), 75, 57, 99, 95], [uint32(8), 6, 8, 5, 5], [uint32(8), 10, 10, 6, 6]);
defineType("Shadowalker", 3, 4, 134, 1, 75, 4, [uint32(45), 35, 60, 80, 40], [uint32(3), 2, 10, 4, 5], [uint32(5), 5, 10, 7, 5]);
defineType("Pyromancer", 2, 0, 14, 2, 50, 1, [uint32(50), 28, 17, 40, 35], [uint32(5), 3, 2, 3, 3], [uint32(8), 4, 3, 4, 5]);
defineType("Magician", 1, 3, 224, 2, 30, 0, [uint32(35), 15, 25, 25, 30], [uint32(3), 1, 2, 2, 2], [uint32(5), 2, 3, 3, 3]);
defineType("Farmer", 0, 0, 59, 0, 15, 2, [uint32(10), 22, 8, 15, 25], [uint32(1), 2, 1, 1, 2], [uint32(1), 3, 1, 2, 3]);
}
function defineType(string _className, uint8 _classRank, uint8 _classRace, uint32 _classAge, uint8 _classType, uint32 _maxLevel, uint8 _aura, uint32[5] _baseStats, uint32[5] _minIVForStats, uint32[5] _maxIVForStats)
onlyOwner
public
{
require(_classRank < 5);
require(_classType < 3);
require(_aura < 5);
require(_minIVForStats[0] <= _maxIVForStats[0] && _minIVForStats[1] <= _maxIVForStats[1] && _minIVForStats[2] <= _maxIVForStats[2] && _minIVForStats[3] <= _maxIVForStats[3] && _minIVForStats[4] <= _maxIVForStats[4]);
HeroClass memory _heroType = HeroClass({
className: _className,
classRank: _classRank,
classRace: _classRace,
classAge: _classAge,
classType: _classType,
maxLevel: _maxLevel,
aura: _aura,
baseStats: _baseStats,
minIVForStats: _minIVForStats,
maxIVForStats: _maxIVForStats,
currentNumberOfInstancedHeroes: 0
});
heroClasses[numberOfHeroClasses] = _heroType;
DefineType(msg.sender, numberOfHeroClasses, _heroType.className);
numberOfHeroClasses ++;
}
function mint(address _owner, uint32 _heroClassId)
onlyAccessMint
public
returns (uint256)
{
require(_owner != address(0));
require(_heroClassId < numberOfHeroClasses);
var _heroClassInfo = heroClasses[_heroClassId];
_mint(_owner, numberOfTokenIds);
uint32[5] memory _ivForStats;
uint32[5] memory _initialStats;
for (uint8 i = 0; i < 5; i++) {
_ivForStats[i] = (random(_heroClassInfo.maxIVForStats[i] + 1, _heroClassInfo.minIVForStats[i]));
_initialStats[i] = _heroClassInfo.baseStats[i] + _ivForStats[i];
}
HeroInstance memory _heroInstance = HeroInstance({
heroClassId: _heroClassId,
heroName: "",
currentLevel: 1,
currentExp: 0,
lastLocationId: 0,
availableAt: now,
currentStats: _initialStats,
ivForStats: _ivForStats
});
tokenIdToHeroInstance[numberOfTokenIds] = _heroInstance;
numberOfTokenIds ++;
_heroClassInfo.currentNumberOfInstancedHeroes ++;
return numberOfTokenIds - 1;
}
function deploy(uint256 _tokenId, uint32 _locationId, uint256 _duration)
onlyAccessDeploy
public
returns (bool)
{
require(ownerOf(_tokenId) != address(0));
var _heroInstance = tokenIdToHeroInstance[_tokenId];
require(_heroInstance.availableAt <= now);
_heroInstance.lastLocationId = _locationId;
_heroInstance.availableAt = now + _duration;
Deploy(msg.sender, _tokenId, _locationId, _duration);
}
function addExp(uint256 _tokenId, uint32 _exp)
onlyAccessDeploy
public
returns (bool)
{
require(ownerOf(_tokenId) != address(0));
var _heroInstance = tokenIdToHeroInstance[_tokenId];
var _newExp = _heroInstance.currentExp + _exp;
require(_newExp == uint256(uint128(_newExp)));
_heroInstance.currentExp += _newExp;
}
function addDeposit(address _to, uint256 _amount)
onlyAccessDeposit
public
{
addressToGoldDeposit[_to] += _amount;
}
function levelUp(uint256 _tokenId)
onlyOwnerOf(_tokenId) whenNotPaused
public
{
var _heroInstance = tokenIdToHeroInstance[_tokenId];
require(_heroInstance.availableAt <= now);
var _heroClassInfo = heroClasses[_heroInstance.heroClassId];
require(_heroInstance.currentLevel < _heroClassInfo.maxLevel);
var requiredExp = getHeroRequiredExpForLevelUp(_tokenId);
require(_heroInstance.currentExp >= requiredExp);
var requiredGold = getHeroRequiredGoldForLevelUp(_tokenId);
var _ownerOfToken = ownerOf(_tokenId);
require(addressToGoldDeposit[_ownerOfToken] >= requiredGold);
_heroInstance.currentLevel += 1;
for (uint8 i = 0; i < 5; i++) {
_heroInstance.currentStats[i] = _heroClassInfo.baseStats[i] + (_heroInstance.currentLevel - 1) * _heroInstance.ivForStats[i];
}
_heroInstance.currentExp -= requiredExp;
addressToGoldDeposit[_ownerOfToken] -= requiredGold;
LevelUp(msg.sender, _tokenId, _heroInstance.currentLevel);
}
function transferDeposit(uint256 _amount)
whenNotPaused
public
{
require(goldContract.allowance(msg.sender, this) >= _amount);
if (goldContract.transferFrom(msg.sender, this, _amount)) {
addressToGoldDeposit[msg.sender] += _amount;
}
}
function withdrawDeposit(uint256 _amount)
public
{
require(addressToGoldDeposit[msg.sender] >= _amount);
if (goldContract.transfer(msg.sender, _amount)) {
addressToGoldDeposit[msg.sender] -= _amount;
}
}
function random(uint32 _upper, uint32 _lower)
private
returns (uint32)
{
require(_upper > _lower);
seed = uint32(keccak256(keccak256(block.blockhash(block.number), seed), now));
return seed % (_upper - _lower) + _lower;
}
} |