The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
woop/contracts/DepositContract.sol

27 lines
797 B

pragma solidity >=0.4.22;
contract DepositContract {
mapping(address => uint) private stakes;
address public owner;
function deposit() public payable returns(uint) {
stakes[msg.sender] += msg.value;
return stakes[msg.sender];
}
function withdraw(uint withdrawAmount) public returns (uint remainingStake) {
if (withdrawAmount <= stakes[msg.sender]){
stakes[msg.sender] -= withdrawAmount;
msg.sender.transfer(withdrawAmount);
return stakes[msg.sender]; //Overdraft protection, no money is withdrawn!
}
}
function balance() public view returns (uint) {
return stakes[msg.sender];
}
function stakesBalance() public view returns (uint) {
return address(this).balance;
}
}