SurveyTokenICO solidity code and ABI interface:


Contract address:

0xd90e0709131788c157034ec86a155ce516fad44a


ABI:

[{constant:!0,inputs:[],name:"goldRemnant",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"bonusBalance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"earlyBonusOf",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"refBonusOf",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"earlyBonusPeriod",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"beginSilv",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"preBalance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"lastInvestorPayback",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"icoBalance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"endGold",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"silverBalance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"goldPrice",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"silverBonOf",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"goldDose",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"silverDose",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"",type:"address"}],name:"goldBonOf",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"silverPrice",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"goldBalance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"silverRemnant",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"getFullInfo",outputs:[{name:"stage",type:"uint8"},{name:"tok",type:"uint256"},{name:"eth",type:"uint256"},{name:"rate",type:"uint256"},{name:"gb",type:"uint256"},{name:"sb",type:"uint256"},{name:"ref",type:"uint256"},{name:"ear",type:"uint256"},{name:"gd",type:"uint256"},{name:"sd",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"srt",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"ethRaised",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"beginPre",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"endSilv",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"beginIco",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"endPre",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"beginGold",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"endIco",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"price",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{anonymous:!1,inputs:[{indexed:!1,name:"investor",type:"address"},{indexed:!1,name:"dose",type:"uint256"}],name:"DoseTaken",type:"event"},{constant:!1,inputs:[{name:"newPrice",type:"uint256"}],name:"setPrice",outputs:[{name:"success",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[],name:"withdrawTokens",outputs:[{name:"success",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"force",type:"bool"}],name:"withdrawFunds",outputs:[{name:"success",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{anonymous:!1,inputs:[{indexed:!1,name:"investor",type:"address"},{indexed:!1,name:"investedEth",type:"uint256"}],name:"NewInvestor",type:"event"},{constant:!1,inputs:[{name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[],name:"takeSilverDose",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[],name:"takeGoldDose",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"refer",type:"address"}],name:"purchaseSurveyToken",outputs:[],payable:!0,stateMutability:"payable",type:"function"},{constant:!1,inputs:[{name:"bPre",type:"uint256"},{name:"ePre",type:"uint256"},{name:"bIco",type:"uint256"},{name:"eIco",type:"uint256"},{name:"bGold",type:"uint256"},{name:"eGold",type:"uint256"},{name:"bSilv",type:"uint256"},{name:"eSilv",type:"uint256"}],name:"setPeriods",outputs:[{name:"success",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[],name:"returnPayback",outputs:[{name:"success",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{inputs:[],payable:!1,stateMutability:"nonpayable",type:"constructor"}]


Code:

pragma solidity ^0.4.16; contract owned { address public owner; function owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { owner = newOwner; } } interface token { function transfer(address receiver, uint amount); } contract SurveyTokenICO is owned { uint public preBalance = 120000000000000000000000000; // 120 M uint public icoBalance = 300000000000000000000000000; // 300 M uint public bonusBalance = 30000000000000000000000000; // 30 M uint public goldBalance = 180; uint public silverBalance = 12500; uint public goldRemnant = 0; uint public silverRemnant = 0; uint public goldDose = 0; uint public silverDose = 0; uint public price; // SRT price in ETH uint public goldPrice = 600000000000000000000000; // GoldBon price in SRT uint public silverPrice = 20000000000000000000000; // SilverBon price in SRT uint public ethRaised = 0; uint public beginPre = 1521201600; // 16.03.2018 12:00 uint public endPre = 1522411200; // 30.03.2018 12:00 uint public beginIco = 1523880000; // 16.04.2018 12:00 uint public endIco = 1527681600; // 30.05.2018 12:00 uint public beginGold = 1528027200; // 03.06.2018 12:00 uint public endGold = 1528891200; // 13.06.2018 12:00 uint public beginSilv = 1528977600; // 14.06.2018 12:00 uint public endSilv = 1530360000; // 30.06.2018 12:00 // ALL TIMESTAMPS WAS CHANGED (+4 days) uint public earlyBonusPeriod = 1209600; // 14 days token public srt = token(address(0xd0e911200DF40B41662bd464d006D8599cDadb96)); // SRT contract uint public lastInvestorPayback = 0; address lastInvestor = 0x0; mapping(address => uint) public silverBonOf; mapping(address => uint) public goldBonOf; mapping(address => uint) public refBonusOf; mapping(address => uint) public earlyBonusOf; event NewInvestor(address investor, uint investedEth); event DoseTaken(address investor, uint dose); function SurveyTokenICO() public { price = 8125; // 1 ETH - $800, mult by 1 000 000 000 } function currentStage() internal constant returns(uint8 stage) { if (now >= beginPre && now <= endPre) return 1; if (now >= beginIco && now <= endIco) return 2; if (now >= beginGold && now <= endGold) return 3; if (now >= beginSilv && now <= endSilv) return 4; return 0; } function getFullInfo() public constant returns(uint8 stage, uint tok, uint eth, uint rate, uint gb, uint sb, uint ref, uint ear, uint gd, uint sd) { uint8 st = currentStage(); uint left = 0; address addr = msg.sender; if (st == 1) left = preBalance; else if (st == 2) left = icoBalance; return (st, left, ethRaised, price, goldBonOf[addr], silverBonOf[addr], refBonusOf[addr], earlyBonusOf[addr], goldDose, silverDose); } function setPeriods(uint bPre, uint ePre, uint bIco, uint eIco, uint bGold, uint eGold, uint bSilv, uint eSilv) public onlyOwner returns(bool success) { require(now < beginIco); if (bPre > 0) beginPre = bPre; if (ePre > 0) endPre = ePre; if (bIco > 0) beginIco = bIco; if (eIco > 0) endIco = eIco; if (bGold > 0) beginGold = bGold; if (eGold > 0) endGold = eGold; if (bSilv > 0) beginSilv = bSilv; if (eSilv > 0) endSilv = eSilv; return true; } function setPrice(uint newPrice) public onlyOwner returns(bool success) { require(newPrice > 0 && newPrice != price); price = newPrice; return true; } function purchaseSurveyToken(address refer) payable { require(msg.value > 0 && price > 0); uint8 stage = currentStage(); require(stage == 1 || stage == 2); uint ethValue = msg.value; uint srtAmount = (ethValue / price) * 1000000000; uint payback = 0; // PRE-ICO stage if (stage == 1) { require(preBalance > 0); if (preBalance >= goldPrice) require(srtAmount >= goldPrice); if (srtAmount > preBalance) { payback = ((srtAmount - preBalance) * price) / 1000000000; srtAmount = preBalance; } srt.transfer(msg.sender, srtAmount); preBalance -= srtAmount; if (goldBalance > 0) { uint goldAmount = 1; srtAmount -= goldPrice; while (srtAmount >= goldPrice) { srtAmount -= goldPrice; goldAmount++; } if (goldAmount > goldBalance) goldAmount = goldBalance; goldBalance -= goldAmount; goldBonOf[msg.sender] += goldAmount; } } // ICO stage else { require(icoBalance > 0); if (srtAmount > icoBalance) { payback = ((srtAmount - icoBalance) * price) / 1000000000; srtAmount = icoBalance; } if (refer != 0x0 && bonusBalance > 0 && refer != msg.sender && (silverBonOf[refer] > 2 || goldBonOf[refer] > 0)) { uint refBonus = srtAmount / 20; if (refBonus > bonusBalance) refBonus = bonusBalance; srt.transfer(refer, refBonus); bonusBalance -= refBonus; refBonusOf[refer] += refBonus; } uint bonus = 0; if (now < beginIco + earlyBonusPeriod && bonusBalance > 0) { bonus = srtAmount / 20; if (bonus > bonusBalance) bonus = bonusBalance; } srt.transfer(msg.sender, srtAmount + bonus); icoBalance -= srtAmount; if (bonus > 0) { bonusBalance -= bonus; earlyBonusOf[msg.sender] += bonus; } if (silverBalance > 0) { uint silverAmount = 0; while (srtAmount >= silverPrice) { srtAmount -= silverPrice; silverAmount++; } if (silverAmount > silverBalance) silverAmount = silverBalance; silverBalance -= silverAmount; silverBonOf[msg.sender] += silverAmount; } } if (payback > 0) { ethValue -= payback; lastInvestorPayback = payback; } ethRaised += ethValue; NewInvestor(msg.sender, ethValue); } function takeGoldDose() public { require(currentStage() == 3); require(goldBonOf[msg.sender] > 0); if (goldDose == 0) { goldRemnant = icoBalance + bonusBalance; icoBalance = 0; bonusBalance = 0; goldDose = goldRemnant / 200; } require(goldRemnant > 0); uint dose = goldDose * goldBonOf[msg.sender]; if (dose > goldRemnant) dose = goldRemnant; srt.transfer(msg.sender, dose); goldRemnant -= dose; goldBonOf[msg.sender] = 0; DoseTaken(msg.sender, dose); } function takeSilverDose() public { require(currentStage() == 4); require(silverBonOf[msg.sender] > 0); if (silverDose == 0) { silverRemnant = icoBalance + bonusBalance + goldRemnant + preBalance; icoBalance = 0; bonusBalance = 0; goldRemnant = 0; preBalance = 0; silverDose = silverRemnant / 12500; } require(silverRemnant > 0); uint dose = silverDose * silverBonOf[msg.sender]; if (dose > silverRemnant) dose = silverRemnant; srt.transfer(msg.sender, dose); silverRemnant -= dose; silverBonOf[msg.sender] = 0; DoseTaken(msg.sender, dose); } function withdrawFunds(bool force) public onlyOwner returns(bool success) { uint bal = this.balance; if (!force && lastInvestorPayback > 0) { require(bal > lastInvestorPayback); bal -= lastInvestorPayback; } owner.transfer(bal); return true; } function withdrawTokens() public onlyOwner returns(bool success) { require(now > endSilv); uint amount = preBalance + icoBalance + bonusBalance + goldRemnant + silverRemnant; require(amount > 0); srt.transfer(owner, amount); preBalance = 0; icoBalance = 0; bonusBalance = 0; goldRemnant = 0; silverRemnant = 0; return true; } function returnPayback() public returns(bool success) { require(lastInvestor == msg.sender); require(lastInvestorPayback > 0 && lastInvestorPayback <= this.balance); lastInvestor.transfer(lastInvestorPayback); lastInvestorPayback = 0; lastInvestor = 0x0; return true; } }