-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWallet.sol
More file actions
46 lines (38 loc) · 1.41 KB
/
Wallet.sol
File metadata and controls
46 lines (38 loc) · 1.41 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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Wallet{
event Log(string message);
fallback() external payable{
if(msg.value > 0){
emit Log("Se llamo a 'Fallback' y Ether fue depositado");
} else{
emit Log("Se llamo a 'Fallback'");
}
}
receive() external payable{
if(msg.value > 0){
emit Log("Se llamo a 'Receive' y Ether fue depositado");
} else{
emit Log("Se llamo a 'Receive'");
}
}
function deposit() external payable{
emit Log("Deposit function has been called");
}
function getBalance() external view returns (uint256){
return address(this).balance;
}
function withDraw() external{
msg.sender.call{value: address(this).balance}('');
}
}
// primeros 4 bytes de "msg.data" vacios?
// / \
// si no
// / \
// receive() existe? esta el "function selector" de deposit?
// / \ / \
// si no no si
// / \ / \
// receive() fallback() deposit()
//