Created
May 21, 2023 11:12
-
-
Save a2468834/274f7495bd6b4544c179e6ac1a820c5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity 0.8.17; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
contract MyToken is ERC20 { | |
constructor() ERC20("MyToken", "MTK") {} | |
function mint(address to, uint256 amount) public { | |
_mint(to, amount); | |
} | |
} | |
contract RoughVault { | |
address public underlyingToken; | |
mapping(address => uint256) balanceOf; | |
constructor(address _underlyingToken) { | |
underlyingToken = _underlyingToken; | |
} | |
function deposit(uint256 amount) public returns (bool) { | |
balanceOf[msg.sender] += amount; | |
ERC20(underlyingToken).transferFrom(msg.sender, address(this), amount); | |
return true; | |
} | |
function withdraw(uint256 amount) public payable { | |
require(msg.value > 10 gwei, "Give me your money!"); | |
balanceOf[msg.sender] -= amount; | |
ERC20(underlyingToken).transfer(msg.sender, amount); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code snippet is just a toy model, so please DO NOT USE it in any of production environment.