Skip to content

Instantly share code, notes, and snippets.

@casweeney
Last active August 4, 2022 16:58
Show Gist options
  • Select an option

  • Save casweeney/5965a21cc0a63561a6eb97fed0be8b6a to your computer and use it in GitHub Desktop.

Select an option

Save casweeney/5965a21cc0a63561a6eb97fed0be8b6a to your computer and use it in GitHub Desktop.
This is the a second test at Web3Bridge Cohort VII
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
contract Deposit {
mapping(address => uint) balances;
function deposit() public payable {
require(msg.value > 0, "No value sent");
balances[msg.sender] += msg.value;
}
function userBalance() external view returns(uint) {
return balances[msg.sender];
}
receive() external payable {
deposit();
}
function withdraw() public {
require(balances[msg.sender] > 0, "No stake");
payable(msg.sender).transfer(balances[msg.sender]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment