smartcontracts100 (OP)
|
|
March 23, 2020, 08:57:18 PM Last edit: March 28, 2020, 06:20:52 PM by smartcontracts100 |
|
Invest/Donate so i can continue developing smart contracts Please donate/Invest at 0xA01F32b1898Ea5c0079997D28bF00D441Ad0883c Donate/Invest so i can focus on smart contracts ,add more smart contracts here and fix the bugs.Thank you ! Contract 1: Turn your token in to shares/stocks with my honeypot contract . pragma solidity ^0.4.24;
contract ERC20 { function totalSupply() public constant returns (uint _totalSupply); function balanceOf(address _owner) public constant returns (uint balance); function transfer(address _to, uint _value) public returns (bool success); function transferFrom(address _from, address _to, uint _value) public returns (bool success); function approve(address _spender, uint _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint remaining); event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); }
contract HoneyPot {
//step 1 create admin
address public honeypotadmin; address public contractaddress; address public tokenaddress; address public useraddr; uint public withdrawlimit; uint public mindeposit; uint public maxdeposit; uint public totaltokenbalance; uint public allowrelease; uint public sharedamount; uint public sharevalue;
// Here Stibco becomes owner of the main contract function CreateAdmin() public { if(honeypotadmin!=address(0)){ honeypotadmin = honeypotadmin; }else{ honeypotadmin = msg.sender; } }
//only admin addr modifier adminsets() { require(msg.sender == honeypotadmin); _; }
function AddTokenAndSetLimit(address token,uint withdrawlimi,uint minimumdeposit,uint maximumdeposit) public payable adminsets { require(withdrawlimit == 0); tokenaddress = token; withdrawlimit = withdrawlimi; mindeposit = minimumdeposit; maxdeposit = maximumdeposit; contractaddress = address(this); allowrelease = 0; }
//users deposits
mapping (address => uint) public sharesbyaddress;
//user has to approve before deposit function UserDepositsToken(address tokensaddress,uint amount) public payable { require(tokenaddress == tokensaddress); require(amount >= mindeposit); require(amount <= maxdeposit); require(amount > 0);
sharesbyaddress[msg.sender] = sharesbyaddress[msg.sender] + amount; totaltokenbalance = totaltokenbalance + amount; ERC20(tokensaddress).transferFrom(msg.sender,contractaddress,amount);
}
function DepositETH(uint amount) public payable{ require(amount == msg.value); }
function AllowRelease() public payable { if(withdrawlimit == address(this).balance){ //allow relase for all users allowrelease = 1; }
}
function UserWithdraws() public payable { require(allowrelease == 1);
//total eth balance = 10 000 000 //case 1 total user deposited = 1000 token //case 2 total user deposited = 95.8542 token //total token balance in contract = 1000000 token
sharevalue = address(this).balance / totaltokenbalance; sharedamount = sharevalue * sharesbyaddress[msg.sender]; useraddr = msg.sender; useraddr.transfer(sharedamount);
}
//get contract address function getContractAddr() public view returns (address) { return contractaddress; }
//get contract balance function getContractBalance() public view returns (uint) { return address(this).balance; }
//get Minimum deposit amount set by Admin function getMinAm() public view returns (uint) { return mindeposit; }
//get Maximum deposit amount set by Admin function getMaxAm() public view returns (uint) { return maxdeposit; }
//get withdrawlimit set by Admin function getWithdrawLimit() public view returns (uint) { return withdrawlimit; }
//get allowedtoken set by Admin function getAllowedToken() public view returns (address) { return tokenaddress; }
//get token balance function getBalanceToken() public view returns (uint) { return totaltokenbalance; }
//get contract admin function getContractAdmin() public view returns (address) { return honeypotadmin; }
//get user total tokens deposited function getUserTotalTokens(address uaddr) public view returns (uint) { return sharesbyaddress[uaddr]; }
}
|
|
|
|
smartcontracts100 (OP)
|
|
March 23, 2020, 09:38:27 PM |
|
Contract 2 Loan or Escrow contract pragma solidity ^0.4.24;
contract LoansorEscrow{ address public Lender; address public theJudge; address public Borrower; uint public LoanAmount; uint public ApprovedJudge; uint public ApproveCancel; uint public JudgeFee;
function CreateLender() public { if(Lender!=address(0)){ Lender = Lender; }else{ Lender = msg.sender; } }
//Borrower Deposits Collateral function DepositCollateral(uint amount,address judge,uint judgefee) public payable{ require(amount == msg.value); require(LoanAmount == 0); LoanAmount = amount; theJudge = judge; Borrower = msg.sender; JudgeFee = judgefee; } //Lender Checks if Judge if Fair and Approves Him ,if Lender does not like judge he cancels loan function LenderApprovesJudge(uint approve) public payable{ require(Lender == msg.sender); require(LoanAmount > 0); if(approve == 1){ ApprovedJudge = 1; }else{ Borrower.transfer(LoanAmount); } }
function BorrowerCancelsLoanBeforeJudgeApproved() public payable{ require(ApprovedJudge == 0); require(LoanAmount > 0); require(Borrower == msg.sender); Borrower.transfer(LoanAmount); }
function JudgeDecidesHowGetsCollateral(uint winner) public payable{ require(theJudge == msg.sender); require(ApprovedJudge == 1); require(LoanAmount > 0); if(winner == 1){ Lender.transfer(LoanAmount - JudgeFee); theJudge.transfer(JudgeFee); }else{ Borrower.transfer(LoanAmount - JudgeFee); theJudge.transfer(JudgeFee); } }
}
|
|
|
|
smartcontracts100 (OP)
|
|
March 24, 2020, 08:07:19 AM |
|
Contract 3 Time Release Contract 1.x Deposits ,adds address of y that can withdraw,adds future timestamp when y can withdraw 2.y will be allowed to withdraw when futuretimestamp = prestent timestamp pragma solidity ^0.4.24;
contract TimeRelease{ address public releaseto; uint public releasetimestamp; uint public timenow;
function Deposit(uint amount,uint futuretimestamp,address ReleaseTo) public payable{ require(amount == msg.value); releaseto = ReleaseTo; releasetimestamp = futuretimestamp;
}
function Release() external{ timenow = block.timestamp; require(releaseto == msg.sender); if(timenow >= releasetimestamp){ releaseto.transfer(address(this).balance); } }
}
|
|
|
|
smartcontracts100 (OP)
|
|
March 27, 2020, 10:48:31 AM Last edit: March 27, 2020, 11:26:04 AM by smartcontracts100 |
|
Contract 4 Simple donations contract pragma solidity ^0.4.24;
contract SimpleDonationContract {
address public admin;
// Here you become admin function CreateAdmin() public { if(admin!=address(0)){ admin = admin; }else{ admin = msg.sender; } }
// Only admin allowed modifier adminrestricted() { require(msg.sender == admin); _; }
function Deposit(uint depositamount) public payable { require(msg.value == depositamount); } //Widthdraw function Withdraw() external adminrestricted {
admin.transfer(address(this).balance);
}
function GetBalance() public view returns (uint){ return address(this).balance; }
}
|
|
|
|
smartcontracts100 (OP)
|
|
March 27, 2020, 11:23:19 AM |
|
Contract 5 Guess Number Contract User 1 Deposits x eth and sets a number. User 2 Deposits same amount as User 1 he sets a number that User 1 set + block number + block time at time of Guess,if the number set by User 2 is equal to number set by User 1 + block number + block time ,then User 2 wins else User 1 wins. pragma solidity ^0.4.24;
contract GuessGame { address public admin; address public sendto; uint public fee; uint public inDeposit; uint public number; uint public minimumallowed; uint public bTime; uint public bNumber; uint public znumber; uint public bet; uint public totalfees;
// Here you become admin function CreateAdmin() public { if(admin!=address(0)){ admin = admin; }else{ admin = msg.sender; } }
//only admin addr modifier adminsets() { require(msg.sender == admin); _; } //Admin sets fee and minimum allowed function SetFee(uint thefee,uint minimum) public payable adminsets { fee = thefee; minimumallowed = minimum; }
//here people deposit eth,adds address where winnings are sent to and adds a random number function Deposit(uint amount,address sendtoaddr,uint tnumber) public payable { require(inDeposit == 0); require(amount > 0); require(amount > minimumallowed); require(tnumber > 0); require(amount == msg.value); bet = amount; inDeposit = 1; sendto = sendtoaddr; number = tnumber; }
function Guess(uint yournumber) public payable { require(bet == msg.value); bTime = block.timestamp; bNumber = block.number; znumber = bTime + bNumber - number; inDeposit = 0; totalfees = totalfees + fee; if(yournumber != znumber){ sendto.transfer(address(this).balance - fee); }else{ sendto = msg.sender; sendto.transfer(address(this).balance - fee); } } //Collect Fees function CollectFee() external adminsets { totalfees = 0; admin.transfer(totalfees);
}
}
|
|
|
|
smartcontracts100 (OP)
|
|
March 27, 2020, 07:23:44 PM |
|
Contract 6 Sell Your ERC 20 token via auction for ETH pragma solidity ^0.4.24;
contract ERC20 { function totalSupply() public constant returns (uint _totalSupply); function balanceOf(address _owner) public constant returns (uint balance); function transfer(address _to, uint _value) public returns (bool success); function transferFrom(address _from, address _to, uint _value) public returns (bool success); function approve(address _spender, uint _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint remaining); event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); }
contract TokenAuction {
address public ztoken; address public auctioncreator; uint public totaltokens; uint public isdeposit; uint public minbid; uint public endauctiontime; uint public currentbid; address public winner; uint public bidderaccepts;
//approve before deposit function DepositToken(address tokensaddress,uint amount,uint endauctiontimestamp,uint minimumbid) public payable { require(amount > 0); require(isdeposit == 0); //set end auction timestamp heigher then 30 minutes require(endauctiontimestamp > block.timestamp); endauctiontime = endauctiontimestamp; minbid = minimumbid; isdeposit = 1; totaltokens = amount; ztoken = tokensaddress; auctioncreator = msg.sender; ERC20(ztoken).transferFrom(msg.sender,address(this),amount);
}
function Bid(uint amount) public payable{ require(amount > minbid); require(amount > currentbid); require(block.timestamp < endauctiontime); require(isdeposit == 1); currentbid = amount; winner = msg.sender; }
//Bidder Accepts to Pay and deposits eth function BidderAcceptsToPay() public payable{ require(endauctiontime >= block.timestamp); require(winner == msg.sender); require(currentbid == msg.value); require(isdeposit == 1); bidderaccepts = 1; }
//Bidder gets his token function GetToken() public payable{ require(endauctiontime >= block.timestamp); require(winner == msg.sender); require(isdeposit == 1); require(bidderaccepts == 1); isdeposit = 0; ERC20(ztoken).transfer(winner,totaltokens); }
function CancelAuction() public payable{ require(endauctiontime >= block.timestamp); require(auctioncreator == msg.sender); require(bidderaccepts == 0); require(isdeposit == 1); isdeposit = 0; ERC20(ztoken).transfer(auctioncreator,totaltokens); }
function AuctionStarterCollectsEth() external{ require(auctioncreator == msg.sender); auctioncreator.transfer( address(this).balance); }
function getCurrentBid() public view returns (uint) { return currentbid; }
function getTokenAddress() public view returns (address) { return ztoken; }
function getWinner() public view returns (address) { return winner; }
function getAuctionCreator() public view returns (address) { return auctioncreator; }
function getETHBalance() public view returns (uint) { return address(this).balance; }
function getTokenBalance() public view returns (uint) { return totaltokens; }
function getEndAuctionTimestamp() public view returns (uint) { return endauctiontime; }
//more getters here ...
}
|
|
|
|
smartcontracts100 (OP)
|
|
March 28, 2020, 06:12:13 PM |
|
Contract 7 Loan contract with erc 20 as collateral and interest paid in advanced by borrower pragma solidity ^0.4.24;
contract ERC20 { function totalSupply() public constant returns (uint _totalSupply); function balanceOf(address _owner) public constant returns (uint balance); function transfer(address _to, uint _value) public returns (bool success); function transferFrom(address _from, address _to, uint _value) public returns (bool success); function approve(address _spender, uint _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint remaining); event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); }
contract LoanETH {
address public borrower; address public lender; address public ztoken; uint public loanamount; uint public istokendeposit; uint public totaltokens; uint public interest; uint public repayloantimestamp; uint public interestpayed; uint public lenderdeposited; uint public loanrepaid;
//approve before deposit function DepositToken(address tokensaddress,uint amount,uint loanamounteth,uint willrepaytimmestamp) public payable { require(amount > 0); //make sure you sent willrepaytimmestamp bigger then 30 minutes from present time ,it's like i will repay loan on date xyz //watch out as loan timer starts the moment you set this function require(willrepaytimmestamp > block.timestamp); require(istokendeposit == 0); istokendeposit = 1; totaltokens = amount; ztoken = tokensaddress; borrower = msg.sender; loanamount = loanamounteth; repayloantimestamp = willrepaytimmestamp; ERC20(ztoken).transferFrom(msg.sender,address(this),amount);
}
function DepositInterestETH(uint theinterest) public payable{ require(borrower == msg.sender); require(istokendeposit == 1); require(theinterest == msg.value); interest = theinterest; interestpayed = 1; }
function LenderDepositsETH() public payable{ require(istokendeposit == 1); require(interestpayed == 1); require(loanamount == msg.value); lenderdeposited = 1; lender = msg.sender; }
function BorrowerGetsLoan() external{ require(istokendeposit == 1); require(interestpayed == 1); require(lenderdeposited == 1); require(borrower == msg.sender); borrower.transfer(loanamount); }
function BorrowerRepaisLoan() public payable{ require(istokendeposit == 1); require(interestpayed == 1); require(loanamount == msg.value); require(borrower == msg.sender); loanrepaid = 1; } function LenderGetsBackETHPlusInterest() external{ require(istokendeposit == 1); require(interestpayed == 1); require(lenderdeposited == 1); require(loanrepaid == 1); require(lender == msg.sender); lender.transfer(loanamount + interest); }
//borrower cancels here
//lender cancels here
//getters here
//donate if you want me to complete this contract for you or make more complex contracs and secure them ! After you donate ,let me know what you want me to do for you. Thank you ! //donate/Invest at 0xA01F32b1898Ea5c0079997D28bF00D441Ad0883c
}
|
|
|
|
smartcontracts100 (OP)
|
|
March 28, 2020, 06:16:17 PM |
|
Contract 8 2 against 1 vote / bet 3 people deposit same amount they vote how wins the pot and when 2 people vote same addr ,that addr wins the pot pragma solidity ^0.4.24;
contract TwoVsOne { uint public count; address public thewinner; uint public winnings; mapping (uint => uint) public bet; mapping (uint => uint) public totalbetters; mapping (address => uint) public better; mapping (uint => address) public winner; mapping (uint => uint) public votecompleted; //Once ETH Deposited by One ,ETH can only be won by vote ,bet not allowed to be canceled
function One(uint betamount,uint thebetid) public payable { require(betamount == msg.value); require(better[msg.sender] != thebetid); bet[thebetid] = msg.value; better[msg.sender] = thebetid; totalbetters[thebetid] = 1; votecompleted[thebetid] = 0; } function Two(uint thebetid) public payable { require(bet[thebetid] == msg.value); require(totalbetters[thebetid] == 1); require(better[msg.sender] != thebetid); better[msg.sender] = thebetid; totalbetters[thebetid] = 2; }
function Three(uint thebetid) public payable { require(bet[thebetid] == msg.value); require(totalbetters[thebetid] == 2); require(better[msg.sender] != thebetid); better[msg.sender] = thebetid; totalbetters[thebetid] = 3; }
function SendETHToWinner(address zwinner,uint thebetid) public payable { require(better[zwinner] == thebetid); require(zwinner != msg.sender); require(better[msg.sender] == thebetid); require(totalbetters[thebetid] == 3); require(votecompleted[thebetid] == 0);
winnings = bet[thebetid] * 3; count = count + 1; thewinner = winner[thebetid]; if(count == 2){ count = 0; votecompleted[thebetid] = 1; thewinner.transfer(winnings); }else{ winner[thebetid] = zwinner; votecompleted[thebetid] = 0; }
}
}
|
|
|
|
smartcontracts100 (OP)
|
|
March 28, 2020, 06:19:01 PM |
|
Contract 9 p2p betting contract pragma solidity ^0.4.24;
contract P2PBettingContrat {
address public thejudge; address public zbetter; uint public betwinnings; uint public betwinningsfee; mapping (address => uint) public thebetamount; mapping (address => address) public thebetjudge; mapping (address => address) public better; mapping (address => address) public eventmaker; mapping (address => uint) public isbetactive; mapping (address => uint) public betwinlose; mapping (address => uint) public thejudgefee; function CreateEvent(uint betamount,address persontobetagainst,address betjudge,uint judgefee) public payable { require(betamount == msg.value); require(persontobetagainst != msg.sender); require(betjudge != msg.sender || betjudge != persontobetagainst); require(isbetactive[msg.sender] == 0); thebetamount[msg.sender] = msg.value; thebetjudge[msg.sender] = betjudge; better[msg.sender] = persontobetagainst; isbetactive[msg.sender] = 0; eventmaker[msg.sender] = msg.sender; betwinlose[msg.sender] = 1; thejudgefee[msg.sender] = judgefee; }
function BetonEvent(address eventcreator) public payable { require(isbetactive[eventcreator] == 0); require(better[msg.sender] == msg.sender); require(thebetamount[eventcreator] == msg.value); isbetactive[eventcreator] == 1; }
function EventCreatorCancelsBet(address eventcreator) external { require(isbetactive[eventcreator] == 0); require(eventmaker[eventcreator] == msg.sender); eventcreator.transfer(thebetamount[eventcreator]); }
function JudgeDecidedBetWinner(uint winner,address eventcreator) external { require(isbetactive[eventcreator] == 1); require(thebetjudge[eventcreator] == msg.sender); betwinnings = thebetamount[eventcreator] + thebetamount[eventcreator]; betwinningsfee = betwinnings - thejudgefee[eventcreator]; thejudge = thebetjudge[eventcreator]; zbetter = better[eventcreator]; if(betwinlose[eventcreator] == winner){ eventcreator.transfer(betwinningsfee); thejudge.transfer(thejudgefee[eventcreator]); }else{ zbetter.transfer(betwinningsfee); thejudge.transfer(thejudgefee[eventcreator]); } }
}
|
|
|
|
cyberjs
Newbie
Offline
Activity: 62
Merit: 0
|
|
February 23, 2022, 04:02:14 PM |
|
Invest/Donate so i can continue developing smart contracts Please donate/Invest at 0xA01F32b1898Ea5c0079997D28bF00D441Ad0883c Donate/Invest so i can focus on smart contracts ,add more smart contracts here and fix the bugs.Thank you ! Contract 1: Turn your token in to shares/stocks with my honeypot contract . pragma solidity ^0.4.24;
contract ERC20 { function totalSupply() public constant returns (uint _totalSupply); function balanceOf(address _owner) public constant returns (uint balance); function transfer(address _to, uint _value) public returns (bool success); function transferFrom(address _from, address _to, uint _value) public returns (bool success); function approve(address _spender, uint _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint remaining); event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); }
contract HoneyPot {
//step 1 create admin
address public honeypotadmin; address public contractaddress; address public tokenaddress; address public useraddr; uint public withdrawlimit; uint public mindeposit; uint public maxdeposit; uint public totaltokenbalance; uint public allowrelease; uint public sharedamount; uint public sharevalue;
// Here Stibco becomes owner of the main contract function CreateAdmin() public { if(honeypotadmin!=address(0)){ honeypotadmin = honeypotadmin; }else{ honeypotadmin = msg.sender; } }
//only admin addr modifier adminsets() { require(msg.sender == honeypotadmin); _; }
function AddTokenAndSetLimit(address token,uint withdrawlimi,uint minimumdeposit,uint maximumdeposit) public payable adminsets { require(withdrawlimit == 0); tokenaddress = token; withdrawlimit = withdrawlimi; mindeposit = minimumdeposit; maxdeposit = maximumdeposit; contractaddress = address(this); allowrelease = 0; }
//users deposits
mapping (address => uint) public sharesbyaddress;
//user has to approve before deposit function UserDepositsToken(address tokensaddress,uint amount) public payable { require(tokenaddress == tokensaddress); require(amount >= mindeposit); require(amount <= maxdeposit); require(amount > 0);
sharesbyaddress[msg.sender] = sharesbyaddress[msg.sender] + amount; totaltokenbalance = totaltokenbalance + amount; ERC20(tokensaddress).transferFrom(msg.sender,contractaddress,amount);
}
function DepositETH(uint amount) public payable{ require(amount == msg.value); }
function AllowRelease() public payable { if(withdrawlimit == address(this).balance){ //allow relase for all users allowrelease = 1; }
}
function UserWithdraws() public payable { require(allowrelease == 1);
//total eth balance = 10 000 000 //case 1 total user deposited = 1000 token //case 2 total user deposited = 95.8542 token //total token balance in contract = 1000000 token
sharevalue = address(this).balance / totaltokenbalance; sharedamount = sharevalue * sharesbyaddress[msg.sender]; useraddr = msg.sender; useraddr.transfer(sharedamount);
}
//get contract address function getContractAddr() public view returns (address) { return contractaddress; }
//get contract balance function getContractBalance() public view returns (uint) { return address(this).balance; }
//get Minimum deposit amount set by Admin function getMinAm() public view returns (uint) { return mindeposit; }
//get Maximum deposit amount set by Admin function getMaxAm() public view returns (uint) { return maxdeposit; }
//get withdrawlimit set by Admin function getWithdrawLimit() public view returns (uint) { return withdrawlimit; }
//get allowedtoken set by Admin function getAllowedToken() public view returns (address) { return tokenaddress; }
//get token balance function getBalanceToken() public view returns (uint) { return totaltokenbalance; }
//get contract admin function getContractAdmin() public view returns (address) { return honeypotadmin; }
//get user total tokens deposited function getUserTotalTokens(address uaddr) public view returns (uint) { return sharesbyaddress[uaddr]; }
}
How can I run this contract? I want to change the total supply area. When I added it on the testnet, it was like a wallet and the token I wanted to add did not come. Where can I enter the token name, symbol, total supply values? (Do I need to create and connect another smart contract for this?)
|
|
|
|
|