-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunchecked-transfer.sol
More file actions
37 lines (32 loc) · 963 Bytes
/
Copy pathunchecked-transfer.sol
File metadata and controls
37 lines (32 loc) · 963 Bytes
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
abstract contract Token {
function transferFrom(address _from, address _to, uint256 _value) virtual public returns (bool success); //ok
}
contract MyBank{
mapping(address => uint) balances;
Token token;
function deposit(uint amount) public{
token.transferFrom(msg.sender, address(this), amount); //bug
balances[msg.sender] += amount;
}
}
contract ToBank{
mapping(address => uint) balances;
Token token;
function deposit(uint amount) public{
bool res=token.transferFrom(msg.sender, address(this), amount);//ok
balances[msg.sender] += amount;
require(res);
}
}
contract ToBank1{
mapping(address => uint) balances;
Token token;
function deposit(uint amount) public{
bool res=token.transferFrom(msg.sender, address(this), amount); //ok
balances[msg.sender] += amount;
if(!res){
}
}
}