-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleVault.sol
More file actions
55 lines (45 loc) · 1.96 KB
/
SimpleVault.sol
File metadata and controls
55 lines (45 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
pragma solidity ^0.8.0;
// ----------------------------------------------------------------------------
// Simple Vault
//
// https://github.com/bokkypoobah/GettingStartedInEthereum
//
// Deployed to Sepolia
//
// SPDX-License-Identifier: MIT
//
// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2024. The MIT Licence.
// ----------------------------------------------------------------------------
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed owner, address indexed spender, uint tokens);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint balance);
function allowance(address owner, address spender) external view returns (uint remaining);
function transfer(address to, uint tokens) external returns (bool success);
function approve(address spender, uint tokens) external returns (bool success);
function transferFrom(address from, address to, uint tokens) external returns (bool success);
}
contract SimpleVault {
address public owner;
event TokensDeposited(address indexed from, address indexed token, uint tokens);
event TokensWithdrawn(address indexed to, address indexed token, uint tokens);
modifier onlyOwner {
require(msg.sender == owner, "Not owner");
_;
}
constructor() {
owner = msg.sender;
}
function depositTokens(address token, uint tokens) external {
IERC20(token).transferFrom(msg.sender, address(this), tokens);
emit TokensDeposited(msg.sender, token, tokens);
}
function withdrawTokens(address token, uint tokens) external onlyOwner {
IERC20(token).transfer(msg.sender, tokens);
emit TokensWithdrawn(msg.sender, token, tokens);
}
}