-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
xiaofeng
committed
Jul 27, 2020
1 parent
542d68c
commit e8fb845
Showing
9 changed files
with
1,594 additions
and
2,750 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
pragma solidity 0.6.2; | ||
|
||
//based on Osiris | ||
|
||
/* | ||
If A is less than 0, the value of B will be large when A is converted to an | ||
unsigned integer B of the same width. Consider withdrawOnce function in this | ||
example, enter a negative value will lead to the contract when the balance | ||
of a roll out more than 1 ether. | ||
*/ | ||
|
||
contract signednessError{ | ||
mapping(address => bool) public transferred; | ||
address public owner; | ||
|
||
constructor() public payable{ | ||
owner = msg.sender; | ||
require(msg.value > 0 && msg.value % 1 ether == 0); | ||
} | ||
|
||
function withdrawOnce (int amount) public { | ||
if ( amount > 1 ether || transferred [msg.sender]) { | ||
revert() ; | ||
} | ||
//In Solidity, casting a negative integer to an unsigned integer results in an error and does not throw an exception. Avoid such conversions. | ||
msg.sender.transfer(uint(amount)); | ||
transferred [msg.sender] = true ; | ||
} | ||
} |
Oops, something went wrong.