├── Dockerfile ├── LICENSE ├── README.md ├── __pycache__ └── inject_file.cpython-38.pyc ├── bug_types.conf ├── bugs ├── Overflow-Underflow │ └── tf │ │ ├── 1.txt │ │ ├── 10.txt │ │ ├── 11.txt │ │ ├── 12.txt │ │ ├── 13.txt │ │ ├── 14.txt │ │ ├── 15.txt │ │ ├── 16.txt │ │ ├── 17.txt │ │ ├── 18.txt │ │ ├── 19.txt │ │ ├── 2.txt │ │ ├── 20.txt │ │ ├── 21.txt │ │ ├── 22.txt │ │ ├── 23.txt │ │ ├── 24.txt │ │ ├── 25.txt │ │ ├── 26.txt │ │ ├── 27.txt │ │ ├── 28.txt │ │ ├── 29.txt │ │ ├── 3.txt │ │ ├── 30.txt │ │ ├── 31.txt │ │ ├── 32.txt │ │ ├── 33.txt │ │ ├── 34.txt │ │ ├── 35.txt │ │ ├── 36.txt │ │ ├── 37.txt │ │ ├── 38.txt │ │ ├── 39.txt │ │ ├── 4.txt │ │ ├── 40.txt │ │ ├── 5.txt │ │ ├── 6.txt │ │ ├── 7.txt │ │ ├── 8.txt │ │ └── 9.txt ├── Re-entrancy │ └── tf │ │ ├── 1.txt │ │ ├── 10.txt │ │ ├── 11.txt │ │ ├── 12.txt │ │ ├── 13.txt │ │ ├── 14.txt │ │ ├── 15.txt │ │ ├── 16.txt │ │ ├── 17.txt │ │ ├── 18.txt │ │ ├── 19.txt │ │ ├── 2.txt │ │ ├── 20.txt │ │ ├── 21.txt │ │ ├── 22.txt │ │ ├── 23.txt │ │ ├── 24.txt │ │ ├── 25.txt │ │ ├── 26.txt │ │ ├── 27.txt │ │ ├── 28.txt │ │ ├── 29.txt │ │ ├── 3.txt │ │ ├── 30.txt │ │ ├── 31.txt │ │ ├── 32.txt │ │ ├── 33.txt │ │ ├── 34.txt │ │ ├── 35.txt │ │ ├── 36.txt │ │ ├── 37.txt │ │ ├── 38.txt │ │ ├── 39.txt │ │ ├── 4.txt │ │ ├── 40.txt │ │ ├── 41.txt │ │ ├── 42.txt │ │ ├── 5.txt │ │ ├── 6.txt │ │ ├── 7.txt │ │ ├── 8.txt │ │ └── 9.txt ├── TOD │ └── tf │ │ ├── 1.txt │ │ ├── 10.txt │ │ ├── 11.txt │ │ ├── 12.txt │ │ ├── 13.txt │ │ ├── 14.txt │ │ ├── 15.txt │ │ ├── 16.txt │ │ ├── 17.txt │ │ ├── 18.txt │ │ ├── 19.txt │ │ ├── 2.txt │ │ ├── 20.txt │ │ ├── 21.txt │ │ ├── 22.txt │ │ ├── 23.txt │ │ ├── 24.txt │ │ ├── 25.txt │ │ ├── 26.txt │ │ ├── 27.txt │ │ ├── 28.txt │ │ ├── 29.txt │ │ ├── 3.txt │ │ ├── 30.txt │ │ ├── 31.txt │ │ ├── 32.txt │ │ ├── 33.txt │ │ ├── 34.txt │ │ ├── 35.txt │ │ ├── 36.txt │ │ ├── 37.txt │ │ ├── 38.txt │ │ ├── 39.txt │ │ ├── 4.txt │ │ ├── 40.txt │ │ ├── 5.txt │ │ ├── 6.txt │ │ ├── 7.txt │ │ ├── 8.txt │ │ └── 9.txt ├── Timestamp-Dependency │ ├── tf │ │ ├── 1.txt │ │ ├── 10.txt │ │ ├── 11.txt │ │ ├── 12.txt │ │ ├── 13.txt │ │ ├── 14.txt │ │ ├── 15.txt │ │ ├── 16.txt │ │ ├── 17.txt │ │ ├── 18.txt │ │ ├── 19.txt │ │ ├── 2.txt │ │ ├── 20.txt │ │ ├── 21.txt │ │ ├── 22.txt │ │ ├── 23.txt │ │ ├── 24.txt │ │ ├── 25.txt │ │ ├── 26.txt │ │ ├── 27.txt │ │ ├── 28.txt │ │ ├── 29.txt │ │ ├── 3.txt │ │ ├── 30.txt │ │ ├── 31.txt │ │ ├── 32.txt │ │ ├── 33.txt │ │ ├── 34.txt │ │ ├── 35.txt │ │ ├── 36.txt │ │ ├── 37.txt │ │ ├── 38.txt │ │ ├── 39.txt │ │ ├── 4.txt │ │ ├── 40.txt │ │ ├── 5.txt │ │ ├── 6.txt │ │ ├── 7.txt │ │ ├── 8.txt │ │ └── 9.txt │ └── ts │ │ ├── 1.txt │ │ ├── 2.txt │ │ ├── 3.txt │ │ ├── 4.txt │ │ └── 5.txt ├── Unchecked-Send │ └── tf │ │ ├── 1.txt │ │ ├── 10.txt │ │ ├── 11.txt │ │ ├── 12.txt │ │ ├── 13.txt │ │ ├── 14.txt │ │ ├── 15.txt │ │ ├── 16.txt │ │ ├── 17.txt │ │ ├── 18.txt │ │ ├── 19.txt │ │ ├── 2.txt │ │ ├── 20.txt │ │ ├── 21.txt │ │ ├── 22.txt │ │ ├── 23.txt │ │ ├── 24.txt │ │ ├── 25.txt │ │ ├── 26.txt │ │ ├── 27.txt │ │ ├── 28.txt │ │ ├── 29.txt │ │ ├── 3.txt │ │ ├── 30.txt │ │ ├── 31.txt │ │ ├── 32.txt │ │ ├── 4.txt │ │ ├── 5.txt │ │ ├── 6.txt │ │ ├── 7.txt │ │ ├── 8.txt │ │ └── 9.txt ├── Unhandled-Exceptions │ └── tf │ │ ├── 1.txt │ │ ├── 10.txt │ │ ├── 11.txt │ │ ├── 12.txt │ │ ├── 13.txt │ │ ├── 14.txt │ │ ├── 15.txt │ │ ├── 16.txt │ │ ├── 17.txt │ │ ├── 18.txt │ │ ├── 19.txt │ │ ├── 2.txt │ │ ├── 20.txt │ │ ├── 21.txt │ │ ├── 22.txt │ │ ├── 23.txt │ │ ├── 24.txt │ │ ├── 25.txt │ │ ├── 26.txt │ │ ├── 27.txt │ │ ├── 28.txt │ │ ├── 29.txt │ │ ├── 3.txt │ │ ├── 30.txt │ │ ├── 31.txt │ │ ├── 32.txt │ │ ├── 33.txt │ │ ├── 34.txt │ │ ├── 35.txt │ │ ├── 36.txt │ │ ├── 37.txt │ │ ├── 38.txt │ │ ├── 39.txt │ │ ├── 4.txt │ │ ├── 40.txt │ │ ├── 41.txt │ │ ├── 42.txt │ │ ├── 43.txt │ │ ├── 44.txt │ │ ├── 45.txt │ │ ├── 46.txt │ │ ├── 47.txt │ │ ├── 48.txt │ │ ├── 5.txt │ │ ├── 6.txt │ │ ├── 7.txt │ │ ├── 8.txt │ │ └── 9.txt └── tx-origin │ └── tf │ ├── 1.txt │ ├── 10.txt │ ├── 11.txt │ ├── 12.txt │ ├── 13.txt │ ├── 14.txt │ ├── 15.txt │ ├── 16.txt │ ├── 17.txt │ ├── 18.txt │ ├── 19.txt │ ├── 2.txt │ ├── 20.txt │ ├── 21.txt │ ├── 22.txt │ ├── 23.txt │ ├── 24.txt │ ├── 25.txt │ ├── 26.txt │ ├── 27.txt │ ├── 28.txt │ ├── 29.txt │ ├── 3.txt │ ├── 30.txt │ ├── 31.txt │ ├── 32.txt │ ├── 33.txt │ ├── 34.txt │ ├── 35.txt │ ├── 36.txt │ ├── 37.txt │ ├── 38.txt │ ├── 39.txt │ ├── 4.txt │ ├── 40.txt │ ├── 5.txt │ ├── 6.txt │ ├── 7.txt │ ├── 8.txt │ └── 9.txt ├── code_trans.conf ├── contracts ├── 1.sol ├── 10.sol ├── 11.sol ├── 12.sol ├── 13.sol ├── 14.sol ├── 15.sol ├── 16.sol ├── 17.sol ├── 18.sol ├── 19.sol ├── 2.sol ├── 20.sol ├── 21.sol ├── 22.sol ├── 23.sol ├── 24.sol ├── 25.sol ├── 26.sol ├── 27.sol ├── 28.sol ├── 29.sol ├── 3.sol ├── 30.sol ├── 31.sol ├── 32.sol ├── 33.sol ├── 34.sol ├── 35.sol ├── 36.sol ├── 37.sol ├── 38.sol ├── 39.sol ├── 4.json ├── 4.sol ├── 40.sol ├── 41.sol ├── 42.sol ├── 43.sol ├── 44.sol ├── 45.sol ├── 46.sol ├── 47.sol ├── 48.sol ├── 49.sol ├── 5.sol ├── 50.sol ├── 6.sol ├── 7.sol ├── 8.sol └── 9.sol ├── evaluator.py ├── inject_file.py ├── inspection.py ├── performance.py ├── requirements.txt ├── sec_methods.conf ├── setup.py ├── solidifi.egg-info ├── PKG-INFO ├── SOURCES.txt ├── dependency_links.txt ├── entry_points.txt ├── requires.txt └── top_level.txt └── solidifi.py /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | ARG SOLC=0.5.12 3 | 4 | RUN apt-get update && apt-get install -y \ 5 | software-properties-common \ 6 | locales && \ 7 | apt-get install -y python3-pip python3.7 \ 8 | nano \ 9 | npm \ 10 | git && \ 11 | pip3 install --upgrade pip &&\ 12 | #pip3 install --upgrade setuptools && \ 13 | pip3 install matplotlib \ 14 | ijson \ 15 | numpy \ 16 | configparser \ 17 | pandas \ 18 | slither-analyzer \ 19 | mythril \ 20 | manticore &&\ 21 | npm install @smartdec/smartcheck -g 22 | 23 | 24 | # set correct locale 25 | RUN locale-gen en_US.UTF-8 26 | ENV LANG en_US.UTF-8 27 | ENV LANGUAGE en_US:en 28 | ENV LC_ALL en_US.UTF-8 29 | 30 | # install securify 31 | RUN apt-get update &&\ 32 | apt-get -y install\ 33 | wget\ 34 | gdebi\ 35 | openjdk-8-jdk &&\ 36 | #openjdk-8-jre 37 | # install souffle 38 | wget https://github.com/souffle-lang/souffle/releases/download/1.6.2/souffle_1.6.2-1_amd64.deb -O /tmp/souffle.deb &&\ 39 | gdebi --n /tmp/souffle.deb && \ 40 | # install graphviz 41 | apt-get update && apt-get -y install\ 42 | graphviz \ 43 | curl && \ 44 | # install the required solc vesion 45 | curl -L https://github.com/ethereum/solidity/releases/download/v$SOLC/solc-static-linux > /usr/bin/solc-$SOLC && \ 46 | chmod +x /usr/bin/solc-$SOLC && \ 47 | ln -s /usr/bin/solc-$SOLC /usr/local/bin/solc &&\ 48 | cd / && git clone https://github.com/eth-sri/securify.git && \ 49 | rm -rf /var/lib/apt/lists/* 50 | 51 | #RUN ./securify/gradlew jar 52 | WORKDIR /solidifi 53 | 54 | COPY . /solidifi 55 | 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The following license does not apply to the smart contracts in the contracts folder. 2 | We have obtained those contracts from Etherscan, as they are publicly available there, and retain their original licenses. 3 | 4 | 5 | MIT License 6 | 7 | Copyright (c) 2020 Univ of British Columbia (UBC) 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SolidiFI 2 | SolidiFI is an automated and systematic framework for evaluating smart contracts' static analysis tools 3 | 4 | For more details about SolidiFI, please reference the paper [How Effective are Smart Contract Analysis Tools? Evaluating Smart Contract Static Analysis Tools Using Bug Injection](http://blogs.ubc.ca/karthik/2020/05/22/how-effective-are-smart-contract-static-analysis-tools-evaluating-smart-contract-static-analysis-tools-using-bug-injection/) 5 | 6 | The dataset and the results of the paper are available [here](https://github.com/DependableSystemsLab/SolidiFI-benchmark) 7 | 8 | If you use SolidiFI, please cite this paper 9 | 10 | ``` 11 | @inproceedings{ghaleb2020effective, 12 | title={How Effective Are Smart Contract Analysis Tools? Evaluating Smart Contract Static Analysis Tools Using Bug Injection}, 13 | author={Ghaleb, Asem and Pattabiraman, Karthik}, 14 | booktitle={Proceedings of the 29th ACM SIGSOFT International Symposium on Software Testing and Analysis}, 15 | year={2020} 16 | } 17 | ``` 18 | ## Quick Start 19 | A docker container with required dependencies is available for easy use of SolidiFI. 20 | 21 | Download the docker image (WARNING: This can take some time.): 22 | ``` 23 | docker pull asemg/solidifi 24 | ``` 25 | 26 | Run the container: 27 | ``` 28 | docker run -i -t asemg/solidifi 29 | ``` 30 | ## Usage From Source 31 | 32 | SolidiFI requires Python 3.6+. 33 | 34 | ### 1. Clone source coode 35 | 36 | ``` 37 | git clone --recursive https://github.com/DependableSystemsLab/SolidiFI.git 38 | ``` 39 | 40 | ### 2. Install dependencies 41 | 42 | To use SolidiFI from your machine, please run the following command to install depedencies required for SolidiFI to work properly. 43 | 44 | ``` 45 | pip install --upgrade pip 46 | pip install -r requirements.txt 47 | pip install -e . 48 | curl -L https://github.com/ethereum/solidity/releases/download/v0.5.12/solc-static-linux > /usr/bin/solc-0.5.12 && \ 49 | chmod +x /usr/bin/solc-0.5.12 && \ 50 | ln -s /usr/bin/solc-0.5.12 /usr/local/bin/solc 51 | ``` 52 | 53 | ## Using SolidiFI to Inject Bugs into a Smart Contract 54 | SolidiFI can be used to inject bugs into a contract as follows 55 | 56 | ``` 57 | python3 solidify.py -i 58 | ``` 59 | For the Bug-type parameter, it can be one of the following 60 | [Re-entrancy, Timestamp-Dependency, Unchecked-Send, Unhandled-Exceptions, TOD, Overflow-Underflow, tx.origin] 61 | 62 | For example to inject Timestamp Dependency bugs into /solidifi/contracts/1.sol smart contract 63 | 64 | ``` 65 | python3 solidifi.py -i /solidifi/contracts/1.sol Timestamp-Dependency 66 | ``` 67 | 68 | The generated buggy contract along with the injection log will be stored under the "buggy/Timestamp-Dependency" folder. 69 | 70 | ## Tools Evaluation Using SolidiFI 71 | 72 | In case you want to to evaluate the analysis tools mentioned in the paper from scratch. You can run evaluator.py. 73 | 74 | This script will inject bugs of the different 7 bug types in the contracts dataset (stored in the folder "contracts"). Then it will scan the generated buggy contracts using the six analysis tools being evaluated, and finally, it will inspect the analysis reports of the tools for false negatives, false positives, and misidentified bugs. 75 | 76 | ``` 77 | python3 evaluator.py Oyente,Securify,Mythril,Smartcheck,Manticore,Slither 78 | ``` 79 | 80 | ## Extending the Set of The Bug Types 81 | 82 | SolidiFI is already configured to inject the bug types mentioned above. However, SolidiFI can be extended to inject other bugs. 83 | 84 | To configure SolidiFI to inject other bugs, update the configuration file named "bug_types.conf" by adding the following pattern for each bug. 85 | 86 | [] 87 | bug_type_id = 88 | bug_type = 89 | bug_type_dir = 90 | 91 | After updating the bugs configuration file, create a folder under "bugs" directory and name it by the name specified in "bug_type_dir" specifed in th configuration file. Inside this folder, create two subfolders, namely, "ts" and "tf" and put all non-block bug snippets under the "ts" folder" and the block bug snippets, written as functions or other blocks, under the folder "tf" 92 | -------------------------------------------------------------------------------- /__pycache__/inject_file.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DependableSystemsLab/SolidiFI/ebb02e3c511a3c93975822101cbbbdaa12a33da0/__pycache__/inject_file.cpython-38.pyc -------------------------------------------------------------------------------- /bug_types.conf: -------------------------------------------------------------------------------- 1 | [1] 2 | bug_type_id=1 3 | bug_type=Re-entrancy 4 | bug_type_dir=Re-entrancy 5 | 6 | [2] 7 | bug_type_id=2 8 | bug_type=Timestamp-Dependency 9 | bug_type_dir=Timestamp-Dependency 10 | 11 | [3] 12 | bug_type_id=3 13 | bug_type=Unchecked-Send 14 | bug_type_dir=Unchecked-Send 15 | 16 | [4] 17 | bug_type_id=4 18 | bug_type=Unhandled-Exceptions 19 | bug_type_dir=Unhandled-Exceptions 20 | 21 | [5] 22 | bug_type_id=5 23 | bug_type=TOD 24 | bug_type_dir=TOD 25 | 26 | [6] 27 | bug_type_id=6 28 | bug_type=Overflow-Underflow 29 | bug_type_dir=Overflow-Underflow 30 | 31 | [7] 32 | bug_type_id=7 33 | bug_type=tx.origin 34 | bug_type_dir=tx-origin 35 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/1.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) public lockTime_intou1; 2 | 3 | function increaseLockTime_intou1(uint _secondsToIncrease) public { 4 | lockTime_intou1[msg.sender] += _secondsToIncrease; //overflow 5 | } 6 | function withdraw_ovrflow1() public { 7 | require(now > lockTime_intou1[msg.sender]); 8 | uint transferValue_intou1 = 10; 9 | msg.sender.transfer(transferValue_intou1); 10 | } 11 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/10.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_intou10; 2 | 3 | function transfer_intou10(address _to, uint _value) public returns (bool) { 4 | require(balances_intou10[msg.sender] - _value >= 0); //bug 5 | balances_intou10[msg.sender] -= _value; //bug 6 | balances_intou10[_to] += _value; //bug 7 | return true; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/11.txt: -------------------------------------------------------------------------------- 1 | function bug_intou11() public{ 2 | uint8 vundflw =0; 3 | vundflw = vundflw -10; // underflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/12.txt: -------------------------------------------------------------------------------- 1 | function bug_intou12(uint8 p_intou12) public{ 2 | uint8 vundflw1=0; 3 | vundflw1 = vundflw1 + p_intou12; // overflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/13.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) public lockTime_intou13; 2 | 3 | function increaseLockTime_intou13(uint _secondsToIncrease) public { 4 | lockTime_intou13[msg.sender] += _secondsToIncrease; //overflow 5 | } 6 | function withdraw_intou13() public { 7 | require(now > lockTime_intou13[msg.sender]); 8 | uint transferValue_intou13 = 10; 9 | msg.sender.transfer(transferValue_intou13); 10 | } 11 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/14.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_intou14; 2 | 3 | function transfer_intou14(address _to, uint _value) public returns (bool) { 4 | require(balances_intou14[msg.sender] - _value >= 0); //bug 5 | balances_intou14[msg.sender] -= _value; //bug 6 | balances_intou14[_to] += _value; //bug 7 | return true; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/15.txt: -------------------------------------------------------------------------------- 1 | function bug_intou15() public{ 2 | uint8 vundflw =0; 3 | vundflw = vundflw -10; // underflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/16.txt: -------------------------------------------------------------------------------- 1 | function bug_intou16(uint8 p_intou16) public{ 2 | uint8 vundflw1=0; 3 | vundflw1 = vundflw1 + p_intou16; // overflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/17.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) public lockTime_intou17; 2 | 3 | function increaseLockTime_intou17(uint _secondsToIncrease) public { 4 | lockTime_intou17[msg.sender] += _secondsToIncrease; //overflow 5 | } 6 | function withdraw_intou17() public { 7 | require(now > lockTime_intou17[msg.sender]); 8 | uint transferValue_intou17 = 10; 9 | msg.sender.transfer(transferValue_intou17); 10 | } 11 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/18.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_intou18; 2 | 3 | function transfer_intou18(address _to, uint _value) public returns (bool) { 4 | require(balances_intou18[msg.sender] - _value >= 0); //bug 5 | balances_intou18[msg.sender] -= _value; //bug 6 | balances_intou18[_to] += _value; //bug 7 | return true; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/19.txt: -------------------------------------------------------------------------------- 1 | function bug_intou19() public{ 2 | uint8 vundflw =0; 3 | vundflw = vundflw -10; // underflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/2.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_intou2; 2 | 3 | function transfer_undrflow2(address _to, uint _value) public returns (bool) { 4 | require(balances_intou2[msg.sender] - _value >= 0); //bug 5 | balances_intou2[msg.sender] -= _value; //bug 6 | balances_intou2[_to] += _value; //bug 7 | return true; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/20.txt: -------------------------------------------------------------------------------- 1 | function bug_intou20(uint8 p_intou20) public{ 2 | uint8 vundflw1=0; 3 | vundflw1 = vundflw1 + p_intou20; // overflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/21.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) public lockTime_intou21; 2 | 3 | function increaseLockTime_intou21(uint _secondsToIncrease) public { 4 | lockTime_intou21[msg.sender] += _secondsToIncrease; //overflow 5 | } 6 | function withdraw_intou21() public { 7 | require(now > lockTime_intou21[msg.sender]); 8 | uint transferValue_intou21 = 10; 9 | msg.sender.transfer(transferValue_intou21); 10 | } 11 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/22.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_intou22; 2 | 3 | function transfer_intou22(address _to, uint _value) public returns (bool) { 4 | require(balances_intou22[msg.sender] - _value >= 0); //bug 5 | balances_intou22[msg.sender] -= _value; //bug 6 | balances_intou22[_to] += _value; //bug 7 | return true; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/23.txt: -------------------------------------------------------------------------------- 1 | function bug_intou23() public{ 2 | uint8 vundflw =0; 3 | vundflw = vundflw -10; // underflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/24.txt: -------------------------------------------------------------------------------- 1 | function bug_intou24(uint8 p_intou24) public{ 2 | uint8 vundflw1=0; 3 | vundflw1 = vundflw1 + p_intou24; // overflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/25.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) public lockTime_intou25; 2 | 3 | function increaseLockTime_intou25(uint _secondsToIncrease) public { 4 | lockTime_intou25[msg.sender] += _secondsToIncrease; //overflow 5 | } 6 | function withdraw_intou25() public { 7 | require(now > lockTime_intou25[msg.sender]); 8 | uint transferValue_intou25 = 10; 9 | msg.sender.transfer(transferValue_intou25); 10 | } 11 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/26.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_intou26; 2 | 3 | function transfer_intou26(address _to, uint _value) public returns (bool) { 4 | require(balances_intou26[msg.sender] - _value >= 0); //bug 5 | balances_intou26[msg.sender] -= _value; //bug 6 | balances_intou26[_to] += _value; //bug 7 | return true; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/27.txt: -------------------------------------------------------------------------------- 1 | function bug_intou27() public{ 2 | uint8 vundflw =0; 3 | vundflw = vundflw -10; // underflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/28.txt: -------------------------------------------------------------------------------- 1 | function bug_intou28(uint8 p_intou28) public{ 2 | uint8 vundflw1=0; 3 | vundflw1 = vundflw1 + p_intou28; // overflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/29.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) public lockTime_intou29; 2 | 3 | function increaseLockTime_intou29(uint _secondsToIncrease) public { 4 | lockTime_intou29[msg.sender] += _secondsToIncrease; //overflow 5 | } 6 | function withdraw_intou29() public { 7 | require(now > lockTime_intou29[msg.sender]); 8 | uint transferValue_intou29 = 10; 9 | msg.sender.transfer(transferValue_intou29); 10 | } 11 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/3.txt: -------------------------------------------------------------------------------- 1 | function bug_intou3() public{ 2 | uint8 vundflw =0; 3 | vundflw = vundflw -10; // underflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/30.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_intou30; 2 | 3 | function transfer_intou30(address _to, uint _value) public returns (bool) { 4 | require(balances_intou30[msg.sender] - _value >= 0); //bug 5 | balances_intou30[msg.sender] -= _value; //bug 6 | balances_intou30[_to] += _value; //bug 7 | return true; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/31.txt: -------------------------------------------------------------------------------- 1 | function bug_intou31() public{ 2 | uint8 vundflw =0; 3 | vundflw = vundflw -10; // underflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/32.txt: -------------------------------------------------------------------------------- 1 | function bug_intou32(uint8 p_intou32) public{ 2 | uint8 vundflw1=0; 3 | vundflw1 = vundflw1 + p_intou32; // overflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/33.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) public lockTime_intou33; 2 | 3 | function increaseLockTime_intou33(uint _secondsToIncrease) public { 4 | lockTime_intou33[msg.sender] += _secondsToIncrease; //overflow 5 | } 6 | function withdraw_intou33() public { 7 | require(now > lockTime_intou33[msg.sender]); 8 | uint transferValue_intou33 = 10; 9 | msg.sender.transfer(transferValue_intou33); 10 | } 11 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/34.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_intou34; 2 | 3 | function transfer_intou34(address _to, uint _value) public returns (bool) { 4 | require(balances_intou34[msg.sender] - _value >= 0); //bug 5 | balances_intou34[msg.sender] -= _value; //bug 6 | balances_intou34[_to] += _value; //bug 7 | return true; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/35.txt: -------------------------------------------------------------------------------- 1 | function bug_intou35() public{ 2 | uint8 vundflw =0; 3 | vundflw = vundflw -10; // underflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/36.txt: -------------------------------------------------------------------------------- 1 | function bug_intou36(uint8 p_intou36) public{ 2 | uint8 vundflw1=0; 3 | vundflw1 = vundflw1 + p_intou36; // overflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/37.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) public lockTime_intou37; 2 | 3 | function increaseLockTime_intou37(uint _secondsToIncrease) public { 4 | lockTime_intou37[msg.sender] += _secondsToIncrease; //overflow 5 | } 6 | function withdraw_intou37() public { 7 | require(now > lockTime_intou37[msg.sender]); 8 | uint transferValue_intou37 = 10; 9 | msg.sender.transfer(transferValue_intou37); 10 | } 11 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/38.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_intou38; 2 | 3 | function transfer_intou38(address _to, uint _value) public returns (bool) { 4 | require(balances_intou38[msg.sender] - _value >= 0); //bug 5 | balances_intou38[msg.sender] -= _value; //bug 6 | balances_intou38[_to] += _value; //bug 7 | return true; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/39.txt: -------------------------------------------------------------------------------- 1 | function bug_intou39() public{ 2 | uint8 vundflw =0; 3 | vundflw = vundflw -10; // underflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/4.txt: -------------------------------------------------------------------------------- 1 | function bug_intou4(uint8 p_intou4) public{ 2 | uint8 vundflw1=0; 3 | vundflw1 = vundflw1 + p_intou4; // overflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/40.txt: -------------------------------------------------------------------------------- 1 | function bug_intou40(uint8 p_intou40) public{ 2 | uint8 vundflw1=0; 3 | vundflw1 = vundflw1 + p_intou40; // overflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/5.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) public lockTime_intou5; 2 | 3 | function increaseLockTime_intou5(uint _secondsToIncrease) public { 4 | lockTime_intou5[msg.sender] += _secondsToIncrease; //overflow 5 | } 6 | function withdraw_intou5() public { 7 | require(now > lockTime_intou5[msg.sender]); 8 | uint transferValue_intou5 = 10; 9 | msg.sender.transfer(transferValue_intou5); 10 | } 11 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/6.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_intou6; 2 | 3 | function transfer_intou62(address _to, uint _value) public returns (bool) { 4 | require(balances_intou6[msg.sender] - _value >= 0); //bug 5 | balances_intou6[msg.sender] -= _value; //bug 6 | balances_intou6[_to] += _value; //bug 7 | return true; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/7.txt: -------------------------------------------------------------------------------- 1 | function bug_intou7() public{ 2 | uint8 vundflw =0; 3 | vundflw = vundflw -10; // underflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/8.txt: -------------------------------------------------------------------------------- 1 | function bug_intou8(uint8 p_intou8) public{ 2 | uint8 vundflw1=0; 3 | vundflw1 = vundflw1 + p_intou8; // overflow bug 4 | } 5 | -------------------------------------------------------------------------------- /bugs/Overflow-Underflow/tf/9.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) public lockTime_intou9; 2 | 3 | function increaseLockTime_intou9(uint _secondsToIncrease) public { 4 | lockTime_intou9[msg.sender] += _secondsToIncrease; //overflow 5 | } 6 | function withdraw_intou9() public { 7 | require(now > lockTime_intou9[msg.sender]); 8 | uint transferValue_intou9 = 10; 9 | msg.sender.transfer(transferValue_intou9); 10 | } 11 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/1.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_re_ent1; 2 | function withdraw_balances_re_ent1 () public { 3 | (bool success,) =msg.sender.call.value(balances_re_ent1[msg.sender ])(""); 4 | if (success) 5 | balances_re_ent1[msg.sender] = 0; 6 | } 7 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/10.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_re_ent10; 2 | function withdrawFunds_re_ent10 (uint256 _weiToWithdraw) public { 3 | require(balances_re_ent10[msg.sender] >= _weiToWithdraw); 4 | // limit the withdrawal 5 | require(msg.sender.send(_weiToWithdraw)); //bug 6 | balances_re_ent10[msg.sender] -= _weiToWithdraw; 7 | } 8 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/11.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) redeemableEther_re_ent11; 2 | function claimReward_re_ent11() public { 3 | // ensure there is a reward to give 4 | require(redeemableEther_re_ent11[msg.sender] > 0); 5 | uint transferValue_re_ent11 = redeemableEther_re_ent11[msg.sender]; 6 | msg.sender.transfer(transferValue_re_ent11); //bug 7 | redeemableEther_re_ent11[msg.sender] = 0; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/12.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) userBalance_re_ent12; 2 | function withdrawBalance_re_ent12() public{ 3 | // send userBalance[msg.sender] ethers to msg.sender 4 | // if mgs.sender is a contract, it will call its fallback function 5 | if( ! (msg.sender.send(userBalance_re_ent12[msg.sender]) ) ){ 6 | revert(); 7 | } 8 | userBalance_re_ent12[msg.sender] = 0; 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/13.txt: -------------------------------------------------------------------------------- 1 | bool not_called_re_ent13 = true; 2 | function bug_re_ent13() public{ 3 | require(not_called_re_ent13); 4 | (bool success,)=msg.sender.call.value(1 ether)(""); 5 | if( ! success ){ 6 | revert(); 7 | } 8 | not_called_re_ent13 = false; 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/14.txt: -------------------------------------------------------------------------------- 1 | uint256 counter_re_ent14 =0; 2 | function callme_re_ent14() public{ 3 | require(counter_re_ent14<=5); 4 | if( ! (msg.sender.send(10 ether) ) ){ 5 | revert(); 6 | } 7 | counter_re_ent14 += 1; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/15.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_re_ent15; 2 | function withdraw_balances_re_ent15 () public { 3 | if (msg.sender.send(balances_re_ent15[msg.sender ])) 4 | balances_re_ent15[msg.sender] = 0; 5 | } 6 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/16.txt: -------------------------------------------------------------------------------- 1 | address payable lastPlayer_re_ent16; 2 | uint jackpot_re_ent16; 3 | function buyTicket_re_ent16() public{ 4 | if (!(lastPlayer_re_ent16.send(jackpot_re_ent16))) 5 | revert(); 6 | lastPlayer_re_ent16 = msg.sender; 7 | jackpot_re_ent16 = address(this).balance; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/17.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_re_ent17; 2 | function withdrawFunds_re_ent17 (uint256 _weiToWithdraw) public { 3 | require(balances_re_ent17[msg.sender] >= _weiToWithdraw); 4 | // limit the withdrawal 5 | (bool success,)=msg.sender.call.value(_weiToWithdraw)(""); 6 | require(success); //bug 7 | balances_re_ent17[msg.sender] -= _weiToWithdraw; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/18.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) redeemableEther_re_ent18; 2 | function claimReward_re_ent18() public { 3 | // ensure there is a reward to give 4 | require(redeemableEther_re_ent18[msg.sender] > 0); 5 | uint transferValue_re_ent18 = redeemableEther_re_ent18[msg.sender]; 6 | msg.sender.transfer(transferValue_re_ent18); //bug 7 | redeemableEther_re_ent18[msg.sender] = 0; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/19.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) userBalance_re_ent19; 2 | function withdrawBalance_re_ent19() public{ 3 | // send userBalance[msg.sender] ethers to msg.sender 4 | // if mgs.sender is a contract, it will call its fallback function 5 | if( ! (msg.sender.send(userBalance_re_ent19[msg.sender]) ) ){ 6 | revert(); 7 | } 8 | userBalance_re_ent19[msg.sender] = 0; 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/2.txt: -------------------------------------------------------------------------------- 1 | address payable lastPlayer_re_ent2; 2 | uint jackpot_re_ent2; 3 | function buyTicket_re_ent2() public{ 4 | if (!(lastPlayer_re_ent2.send(jackpot_re_ent2))) 5 | revert(); 6 | lastPlayer_re_ent2 = msg.sender; 7 | jackpot_re_ent2 = address(this).balance; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/20.txt: -------------------------------------------------------------------------------- 1 | bool not_called_re_ent20 = true; 2 | function bug_re_ent20() public{ 3 | require(not_called_re_ent20); 4 | if( ! (msg.sender.send(1 ether) ) ){ 5 | revert(); 6 | } 7 | not_called_re_ent20 = false; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/21.txt: -------------------------------------------------------------------------------- 1 | uint256 counter_re_ent21 =0; 2 | function callme_re_ent21() public{ 3 | require(counter_re_ent21<=5); 4 | if( ! (msg.sender.send(10 ether) ) ){ 5 | revert(); 6 | } 7 | counter_re_ent21 += 1; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/22.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_re_ent21; 2 | function withdraw_balances_re_ent21 () public { 3 | (bool success,)= msg.sender.call.value(balances_re_ent21[msg.sender ])(""); 4 | if (success) 5 | balances_re_ent21[msg.sender] = 0; 6 | } 7 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/23.txt: -------------------------------------------------------------------------------- 1 | address payable lastPlayer_re_ent23; 2 | uint jackpot_re_ent23; 3 | function buyTicket_re_ent23() public{ 4 | if (!(lastPlayer_re_ent23.send(jackpot_re_ent23))) 5 | revert(); 6 | lastPlayer_re_ent23 = msg.sender; 7 | jackpot_re_ent23 = address(this).balance; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/24.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_re_ent24; 2 | function withdrawFunds_re_ent24 (uint256 _weiToWithdraw) public { 3 | require(balances_re_ent24[msg.sender] >= _weiToWithdraw); 4 | // limit the withdrawal 5 | require(msg.sender.send(_weiToWithdraw)); //bug 6 | balances_re_ent24[msg.sender] -= _weiToWithdraw; 7 | } 8 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/25.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) redeemableEther_re_ent25; 2 | function claimReward_re_ent25() public { 3 | // ensure there is a reward to give 4 | require(redeemableEther_re_ent25[msg.sender] > 0); 5 | uint transferValue_re_ent25 = redeemableEther_re_ent25[msg.sender]; 6 | msg.sender.transfer(transferValue_re_ent25); //bug 7 | redeemableEther_re_ent25[msg.sender] = 0; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/26.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) userBalance_re_ent26; 2 | function withdrawBalance_re_ent26() public{ 3 | // send userBalance[msg.sender] ethers to msg.sender 4 | // if mgs.sender is a contract, it will call its fallback function 5 | (bool success,)= msg.sender.call.value(userBalance_re_ent26[msg.sender])(""); 6 | if( ! success ){ 7 | revert(); 8 | } 9 | userBalance_re_ent26[msg.sender] = 0; 10 | } 11 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/27.txt: -------------------------------------------------------------------------------- 1 | bool not_called_re_ent27 = true; 2 | function bug_re_ent27() public{ 3 | require(not_called_re_ent27); 4 | if( ! (msg.sender.send(1 ether) ) ){ 5 | revert(); 6 | } 7 | not_called_re_ent27 = false; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/28.txt: -------------------------------------------------------------------------------- 1 | uint256 counter_re_ent28 =0; 2 | function callme_re_ent28() public{ 3 | require(counter_re_ent28<=5); 4 | if( ! (msg.sender.send(10 ether) ) ){ 5 | revert(); 6 | } 7 | counter_re_ent28 += 1; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/29.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_re_ent29; 2 | function withdraw_balances_re_ent29 () public { 3 | if (msg.sender.send(balances_re_ent29[msg.sender ])) 4 | balances_re_ent29[msg.sender] = 0; 5 | } 6 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/3.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_re_ent3; 2 | function withdrawFunds_re_ent3 (uint256 _weiToWithdraw) public { 3 | require(balances_re_ent3[msg.sender] >= _weiToWithdraw); 4 | // limit the withdrawal 5 | (bool success,)= msg.sender.call.value(_weiToWithdraw)(""); 6 | require(success); //bug 7 | balances_re_ent3[msg.sender] -= _weiToWithdraw; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/30.txt: -------------------------------------------------------------------------------- 1 | address payable lastPlayer_re_ent30; 2 | uint jackpot_re_ent30; 3 | function buyTicket_re_ent30() public{ 4 | if (!(lastPlayer_re_ent30.send(jackpot_re_ent30))) 5 | revert(); 6 | lastPlayer_re_ent30 = msg.sender; 7 | jackpot_re_ent30 = address(this).balance; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/31.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_re_ent31; 2 | function withdrawFunds_re_ent31 (uint256 _weiToWithdraw) public { 3 | require(balances_re_ent31[msg.sender] >= _weiToWithdraw); 4 | // limit the withdrawal 5 | require(msg.sender.send(_weiToWithdraw)); //bug 6 | balances_re_ent31[msg.sender] -= _weiToWithdraw; 7 | } 8 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/32.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) redeemableEther_re_ent32; 2 | function claimReward_re_ent32() public { 3 | // ensure there is a reward to give 4 | require(redeemableEther_re_ent32[msg.sender] > 0); 5 | uint transferValue_re_ent32 = redeemableEther_re_ent32[msg.sender]; 6 | msg.sender.transfer(transferValue_re_ent32); //bug 7 | redeemableEther_re_ent32[msg.sender] = 0; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/33.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) userBalance_re_ent33; 2 | function withdrawBalance_re_ent33() public{ 3 | // send userBalance[msg.sender] ethers to msg.sender 4 | // if mgs.sender is a contract, it will call its fallback function 5 | (bool success,)= msg.sender.call.value(userBalance_re_ent33[msg.sender])(""); 6 | if( ! success ){ 7 | revert(); 8 | } 9 | userBalance_re_ent33[msg.sender] = 0; 10 | } 11 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/34.txt: -------------------------------------------------------------------------------- 1 | bool not_called_re_ent34 = true; 2 | function bug_re_ent34() public{ 3 | require(not_called_re_ent34); 4 | if( ! (msg.sender.send(1 ether) ) ){ 5 | revert(); 6 | } 7 | not_called_re_ent34 = false; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/35.txt: -------------------------------------------------------------------------------- 1 | uint256 counter_re_ent35 =0; 2 | function callme_re_ent35() public{ 3 | require(counter_re_ent35<=5); 4 | if( ! (msg.sender.send(10 ether) ) ){ 5 | revert(); 6 | } 7 | counter_re_ent35 += 1; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/36.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_re_ent36; 2 | function withdraw_balances_re_ent36 () public { 3 | if (msg.sender.send(balances_re_ent36[msg.sender ])) 4 | balances_re_ent36[msg.sender] = 0; 5 | } 6 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/37.txt: -------------------------------------------------------------------------------- 1 | address payable lastPlayer_re_ent37; 2 | uint jackpot_re_ent37; 3 | function buyTicket_re_ent37() public{ 4 | if (!(lastPlayer_re_ent37.send(jackpot_re_ent37))) 5 | revert(); 6 | lastPlayer_re_ent37 = msg.sender; 7 | jackpot_re_ent37 = address(this).balance; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/38.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_re_ent38; 2 | function withdrawFunds_re_ent38 (uint256 _weiToWithdraw) public { 3 | require(balances_re_ent38[msg.sender] >= _weiToWithdraw); 4 | // limit the withdrawal 5 | require(msg.sender.send(_weiToWithdraw)); //bug 6 | balances_re_ent38[msg.sender] -= _weiToWithdraw; 7 | } 8 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/39.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) redeemableEther_re_ent39; 2 | function claimReward_re_ent39() public { 3 | // ensure there is a reward to give 4 | require(redeemableEther_re_ent39[msg.sender] > 0); 5 | uint transferValue_re_ent39 = redeemableEther_re_ent39[msg.sender]; 6 | msg.sender.transfer(transferValue_re_ent39); //bug 7 | redeemableEther_re_ent39[msg.sender] = 0; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/4.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) redeemableEther_re_ent4; 2 | function claimReward_re_ent4() public { 3 | // ensure there is a reward to give 4 | require(redeemableEther_re_ent4[msg.sender] > 0); 5 | uint transferValue_re_ent4 = redeemableEther_re_ent4[msg.sender]; 6 | msg.sender.transfer(transferValue_re_ent4); //bug 7 | redeemableEther_re_ent4[msg.sender] = 0; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/40.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) userBalance_re_ent40; 2 | function withdrawBalance_re_ent40() public{ 3 | // send userBalance[msg.sender] ethers to msg.sender 4 | // if mgs.sender is a contract, it will call its fallback function 5 | (bool success,)=msg.sender.call.value(userBalance_re_ent40[msg.sender])(""); 6 | if( ! success ){ 7 | revert(); 8 | } 9 | userBalance_re_ent40[msg.sender] = 0; 10 | } 11 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/41.txt: -------------------------------------------------------------------------------- 1 | bool not_called_re_ent41 = true; 2 | function bug_re_ent41() public{ 3 | require(not_called_re_ent41); 4 | if( ! (msg.sender.send(1 ether) ) ){ 5 | revert(); 6 | } 7 | not_called_re_ent41 = false; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/42.txt: -------------------------------------------------------------------------------- 1 | uint256 counter_re_ent42 =0; 2 | function callme_re_ent42() public{ 3 | require(counter_re_ent42<=5); 4 | if( ! (msg.sender.send(10 ether) ) ){ 5 | revert(); 6 | } 7 | counter_re_ent42 += 1; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/5.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) userBalance_re_ent5; 2 | function withdrawBalance_re_ent5() public{ 3 | // send userBalance[msg.sender] ethers to msg.sender 4 | // if mgs.sender is a contract, it will call its fallback function 5 | if( ! (msg.sender.send(userBalance_re_ent5[msg.sender]) ) ){ 6 | revert(); 7 | } 8 | userBalance_re_ent5[msg.sender] = 0; 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/6.txt: -------------------------------------------------------------------------------- 1 | bool not_called_re_ent6 = true; 2 | function bug_re_ent6() public{ 3 | require(not_called_re_ent6); 4 | if( ! (msg.sender.send(1 ether) ) ){ 5 | revert(); 6 | } 7 | not_called_re_ent6 = false; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/7.txt: -------------------------------------------------------------------------------- 1 | uint256 counter_re_ent7 =0; 2 | function callme_re_ent7() public{ 3 | require(counter_re_ent7<=5); 4 | if( ! (msg.sender.send(10 ether) ) ){ 5 | revert(); 6 | } 7 | counter_re_ent7 += 1; 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/8.txt: -------------------------------------------------------------------------------- 1 | mapping(address => uint) balances_re_ent8; 2 | function withdraw_balances_re_ent8 () public { 3 | (bool success,) = msg.sender.call.value(balances_re_ent8[msg.sender ])(""); 4 | if (success) 5 | balances_re_ent8[msg.sender] = 0; 6 | } 7 | -------------------------------------------------------------------------------- /bugs/Re-entrancy/tf/9.txt: -------------------------------------------------------------------------------- 1 | address payable lastPlayer_re_ent9; 2 | uint jackpot_re_ent9; 3 | function buyTicket_re_ent9() public{ 4 | (bool success,) = lastPlayer_re_ent9.call.value(jackpot_re_ent9)(""); 5 | if (!success) 6 | revert(); 7 | lastPlayer_re_ent9 = msg.sender; 8 | jackpot_re_ent9 = address(this).balance; 9 | } 10 | -------------------------------------------------------------------------------- /bugs/TOD/tf/1.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD1; 2 | function play_TOD1(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD1 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD1() payable public{ 11 | 12 | winner_TOD1.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/10.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD10 = false; 2 | address payable owner_TOD10; 3 | uint256 reward_TOD10; 4 | function setReward_TOD10() public payable { 5 | require (!claimed_TOD10); 6 | 7 | require(msg.sender == owner_TOD10); 8 | owner_TOD10.transfer(reward_TOD10); 9 | reward_TOD10 = msg.value; 10 | } 11 | 12 | function claimReward_TOD10(uint256 submission) public { 13 | require (!claimed_TOD10); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD10); 17 | claimed_TOD10 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/11.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD11; 2 | function play_TOD11(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD11 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD11() payable public{ 11 | 12 | winner_TOD11.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/12.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD12 = false; 2 | address payable owner_TOD12; 3 | uint256 reward_TOD12; 4 | function setReward_TOD12() public payable { 5 | require (!claimed_TOD12); 6 | 7 | require(msg.sender == owner_TOD12); 8 | owner_TOD12.transfer(reward_TOD12); 9 | reward_TOD12 = msg.value; 10 | } 11 | 12 | function claimReward_TOD12(uint256 submission) public { 13 | require (!claimed_TOD12); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD12); 17 | claimed_TOD12 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/13.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD13; 2 | function play_TOD13(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD13 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD13() payable public{ 11 | 12 | winner_TOD13.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/14.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD14 = false; 2 | address payable owner_TOD14; 3 | uint256 reward_TOD14; 4 | function setReward_TOD14() public payable { 5 | require (!claimed_TOD14); 6 | 7 | require(msg.sender == owner_TOD14); 8 | owner_TOD14.transfer(reward_TOD14); 9 | reward_TOD14 = msg.value; 10 | } 11 | 12 | function claimReward_TOD14(uint256 submission) public { 13 | require (!claimed_TOD14); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD14); 17 | claimed_TOD14 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/15.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD15; 2 | function play_TOD15(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD15 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD15() payable public{ 11 | 12 | winner_TOD15.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/16.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD16 = false; 2 | address payable owner_TOD16; 3 | uint256 reward_TOD16; 4 | function setReward_TOD16() public payable { 5 | require (!claimed_TOD16); 6 | 7 | require(msg.sender == owner_TOD16); 8 | owner_TOD16.transfer(reward_TOD16); 9 | reward_TOD16 = msg.value; 10 | } 11 | 12 | function claimReward_TOD16(uint256 submission) public { 13 | require (!claimed_TOD16); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD16); 17 | claimed_TOD16 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/17.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD17; 2 | function play_TOD17(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD17 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD17() payable public{ 11 | 12 | winner_TOD17.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/18.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD18 = false; 2 | address payable owner_TOD18; 3 | uint256 reward_TOD18; 4 | function setReward_TOD18() public payable { 5 | require (!claimed_TOD18); 6 | 7 | require(msg.sender == owner_TOD18); 8 | owner_TOD18.transfer(reward_TOD18); 9 | reward_TOD18 = msg.value; 10 | } 11 | 12 | function claimReward_TOD18(uint256 submission) public { 13 | require (!claimed_TOD18); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD18); 17 | claimed_TOD18 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/19.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD19; 2 | function play_TOD19(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD19 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD19() payable public{ 11 | 12 | winner_TOD19.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/2.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD2 = false; 2 | address payable owner_TOD2; 3 | uint256 reward_TOD2; 4 | function setReward_TOD2() public payable { 5 | require (!claimed_TOD2); 6 | 7 | require(msg.sender == owner_TOD2); 8 | owner_TOD2.transfer(reward_TOD2); 9 | reward_TOD2 = msg.value; 10 | } 11 | 12 | function claimReward_TOD2(uint256 submission) public { 13 | require (!claimed_TOD2); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD2); 17 | claimed_TOD2 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/20.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD20 = false; 2 | address payable owner_TOD20; 3 | uint256 reward_TOD20; 4 | function setReward_TOD20() public payable { 5 | require (!claimed_TOD20); 6 | 7 | require(msg.sender == owner_TOD20); 8 | owner_TOD20.transfer(reward_TOD20); 9 | reward_TOD20 = msg.value; 10 | } 11 | 12 | function claimReward_TOD20(uint256 submission) public { 13 | require (!claimed_TOD20); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD20); 17 | claimed_TOD20 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/21.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD21; 2 | function play_TOD21(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD21 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD21() payable public{ 11 | 12 | winner_TOD21.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/22.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD22 = false; 2 | address payable owner_TOD22; 3 | uint256 reward_TOD22; 4 | function setReward_TOD22() public payable { 5 | require (!claimed_TOD22); 6 | 7 | require(msg.sender == owner_TOD22); 8 | owner_TOD22.transfer(reward_TOD22); 9 | reward_TOD22 = msg.value; 10 | } 11 | 12 | function claimReward_TOD22(uint256 submission) public { 13 | require (!claimed_TOD22); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD22); 17 | claimed_TOD22 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/23.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD23; 2 | function play_TOD23(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD23 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD23() payable public{ 11 | 12 | winner_TOD23.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/24.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD24 = false; 2 | address payable owner_TOD24; 3 | uint256 reward_TOD24; 4 | function setReward_TOD24() public payable { 5 | require (!claimed_TOD24); 6 | 7 | require(msg.sender == owner_TOD24); 8 | owner_TOD24.transfer(reward_TOD24); 9 | reward_TOD24 = msg.value; 10 | } 11 | 12 | function claimReward_TOD24(uint256 submission) public { 13 | require (!claimed_TOD24); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD24); 17 | claimed_TOD24 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/25.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD25; 2 | function play_TOD25(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD25 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD25() payable public{ 11 | 12 | winner_TOD25.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/26.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD26 = false; 2 | address payable owner_TOD26; 3 | uint256 reward_TOD26; 4 | function setReward_TOD26() public payable { 5 | require (!claimed_TOD26); 6 | 7 | require(msg.sender == owner_TOD26); 8 | owner_TOD26.transfer(reward_TOD26); 9 | reward_TOD26 = msg.value; 10 | } 11 | 12 | function claimReward_TOD26(uint256 submission) public { 13 | require (!claimed_TOD26); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD26); 17 | claimed_TOD26 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/27.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD27; 2 | function play_TOD27(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD27 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD27() payable public{ 11 | 12 | winner_TOD27.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/28.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD28 = false; 2 | address payable owner_TOD28; 3 | uint256 reward_TOD28; 4 | function setReward_TOD28() public payable { 5 | require (!claimed_TOD28); 6 | 7 | require(msg.sender == owner_TOD28); 8 | owner_TOD28.transfer(reward_TOD28); 9 | reward_TOD28 = msg.value; 10 | } 11 | 12 | function claimReward_TOD28(uint256 submission) public { 13 | require (!claimed_TOD28); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD28); 17 | claimed_TOD28 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/29.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD29; 2 | function play_TOD29(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD29 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD29() payable public{ 11 | 12 | winner_TOD29.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/3.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD3; 2 | function play_TOD3(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD3 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD3() payable public{ 11 | 12 | winner_TOD3.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/30.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD30 = false; 2 | address payable owner_TOD30; 3 | uint256 reward_TOD30; 4 | function setReward_TOD30() public payable { 5 | require (!claimed_TOD30); 6 | 7 | require(msg.sender == owner_TOD30); 8 | owner_TOD30.transfer(reward_TOD30); 9 | reward_TOD30 = msg.value; 10 | } 11 | 12 | function claimReward_TOD30(uint256 submission) public { 13 | require (!claimed_TOD30); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD30); 17 | claimed_TOD30 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/31.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD31; 2 | function play_TOD31(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD31 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD31() payable public{ 11 | 12 | winner_TOD31.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/32.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD32 = false; 2 | address payable owner_TOD32; 3 | uint256 reward_TOD32; 4 | function setReward_TOD32() public payable { 5 | require (!claimed_TOD32); 6 | 7 | require(msg.sender == owner_TOD32); 8 | owner_TOD32.transfer(reward_TOD32); 9 | reward_TOD32 = msg.value; 10 | } 11 | 12 | function claimReward_TOD32(uint256 submission) public { 13 | require (!claimed_TOD32); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD32); 17 | claimed_TOD32 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/33.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD33; 2 | function play_TOD33(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD33 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD33() payable public{ 11 | 12 | winner_TOD33.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/34.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD34 = false; 2 | address payable owner_TOD34; 3 | uint256 reward_TOD34; 4 | function setReward_TOD34() public payable { 5 | require (!claimed_TOD34); 6 | 7 | require(msg.sender == owner_TOD34); 8 | owner_TOD34.transfer(reward_TOD34); 9 | reward_TOD34 = msg.value; 10 | } 11 | 12 | function claimReward_TOD34(uint256 submission) public { 13 | require (!claimed_TOD34); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD34); 17 | claimed_TOD34 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/35.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD35; 2 | function play_TOD35(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD35 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD35() payable public{ 11 | 12 | winner_TOD35.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/36.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD36 = false; 2 | address payable owner_TOD36; 3 | uint256 reward_TOD36; 4 | function setReward_TOD36() public payable { 5 | require (!claimed_TOD36); 6 | 7 | require(msg.sender == owner_TOD36); 8 | owner_TOD36.transfer(reward_TOD36); 9 | reward_TOD36 = msg.value; 10 | } 11 | 12 | function claimReward_TOD36(uint256 submission) public { 13 | require (!claimed_TOD36); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD36); 17 | claimed_TOD36 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/37.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD37; 2 | function play_TOD37(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD37 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD37() payable public{ 11 | 12 | winner_TOD37.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/38.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD38 = false; 2 | address payable owner_TOD38; 3 | uint256 reward_TOD38; 4 | function setReward_TOD38() public payable { 5 | require (!claimed_TOD38); 6 | 7 | require(msg.sender == owner_TOD38); 8 | owner_TOD38.transfer(reward_TOD38); 9 | reward_TOD38 = msg.value; 10 | } 11 | 12 | function claimReward_TOD38(uint256 submission) public { 13 | require (!claimed_TOD38); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD38); 17 | claimed_TOD38 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/39.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD39; 2 | function play_TOD39(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD39 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD39() payable public{ 11 | 12 | winner_TOD39.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/4.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD4 = false; 2 | address payable owner_TOD4; 3 | uint256 reward_TOD4; 4 | function setReward_TOD4() public payable { 5 | require (!claimed_TOD4); 6 | 7 | require(msg.sender == owner_TOD4); 8 | owner_TOD4.transfer(reward_TOD4); 9 | reward_TOD4 = msg.value; 10 | } 11 | 12 | function claimReward_TOD4(uint256 submission) public { 13 | require (!claimed_TOD4); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD4); 17 | claimed_TOD4 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/40.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD40 = false; 2 | address payable owner_TOD40; 3 | uint256 reward_TOD40; 4 | function setReward_TOD40() public payable { 5 | require (!claimed_TOD40); 6 | 7 | require(msg.sender == owner_TOD40); 8 | owner_TOD40.transfer(reward_TOD40); 9 | reward_TOD40 = msg.value; 10 | } 11 | 12 | function claimReward_TOD40(uint256 submission) public { 13 | require (!claimed_TOD40); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD40); 17 | claimed_TOD40 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/5.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD5; 2 | function play_TOD5(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD5 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD5() payable public{ 11 | 12 | winner_TOD5.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/6.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD6 = false; 2 | address payable owner_TOD6; 3 | uint256 reward_TOD6; 4 | function setReward_TOD6() public payable { 5 | require (!claimed_TOD6); 6 | 7 | require(msg.sender == owner_TOD6); 8 | owner_TOD6.transfer(reward_TOD6); 9 | reward_TOD6 = msg.value; 10 | } 11 | 12 | function claimReward_TOD6(uint256 submission) public { 13 | require (!claimed_TOD6); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD6); 17 | claimed_TOD6 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/7.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD7; 2 | function play_TOD7(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD7 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD7() payable public{ 11 | 12 | winner_TOD7.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/TOD/tf/8.txt: -------------------------------------------------------------------------------- 1 | bool claimed_TOD8 = false; 2 | address payable owner_TOD8; 3 | uint256 reward_TOD8; 4 | function setReward_TOD8() public payable { 5 | require (!claimed_TOD8); 6 | 7 | require(msg.sender == owner_TOD8); 8 | owner_TOD8.transfer(reward_TOD8); 9 | reward_TOD8 = msg.value; 10 | } 11 | 12 | function claimReward_TOD8(uint256 submission) public { 13 | require (!claimed_TOD8); 14 | require(submission < 10); 15 | 16 | msg.sender.transfer(reward_TOD8); 17 | claimed_TOD8 = true; 18 | } 19 | -------------------------------------------------------------------------------- /bugs/TOD/tf/9.txt: -------------------------------------------------------------------------------- 1 | address payable winner_TOD9; 2 | function play_TOD9(bytes32 guess) public{ 3 | 4 | if (keccak256(abi.encode(guess)) == keccak256(abi.encode('hello'))) { 5 | 6 | winner_TOD9 = msg.sender; 7 | } 8 | } 9 | 10 | function getReward_TOD9() payable public{ 11 | 12 | winner_TOD9.transfer(msg.value); 13 | } 14 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/1.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp1() view public returns (bool) { 2 | return block.timestamp >= 1546300800; 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/10.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp10; 2 | function play_tmstmp10(uint startTime) public { 3 | if (startTime + (5 * 1 days) == block.timestamp){ 4 | winner_tmstmp10 = msg.sender;}} 5 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/11.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp11; 2 | function play_tmstmp11(uint startTime) public { 3 | uint _vtime = block.timestamp; 4 | if (startTime + (5 * 1 days) == _vtime){ 5 | winner_tmstmp11 = msg.sender;}} 6 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/12.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp12 () public payable { 2 | uint pastBlockTime_tmstmp12; // Forces one bet per block 3 | require(msg.value == 10 ether); // must send 10 ether to play 4 | require(now != pastBlockTime_tmstmp12); // only 1 transaction per block //bug 5 | pastBlockTime_tmstmp12 = now; //bug 6 | if(now % 15 == 0) { // winner //bug 7 | msg.sender.transfer(address(this).balance); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/13.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp13() view public returns (bool) { 2 | return block.timestamp >= 1546300800; 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/14.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp14; 2 | function play_tmstmp14(uint startTime) public { 3 | if (startTime + (5 * 1 days) == block.timestamp){ 4 | winner_tmstmp14 = msg.sender;}} 5 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/15.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp15; 2 | function play_tmstmp15(uint startTime) public { 3 | uint _vtime = block.timestamp; 4 | if (startTime + (5 * 1 days) == _vtime){ 5 | winner_tmstmp15 = msg.sender;}} 6 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/16.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp16 () public payable { 2 | uint pastBlockTime_tmstmp16; // Forces one bet per block 3 | require(msg.value == 10 ether); // must send 10 ether to play 4 | require(now != pastBlockTime_tmstmp16); // only 1 transaction per block //bug 5 | pastBlockTime_tmstmp16 = now; //bug 6 | if(now % 15 == 0) { // winner //bug 7 | msg.sender.transfer(address(this).balance); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/17.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp17() view public returns (bool) { 2 | return block.timestamp >= 1546300800; 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/18.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp18; 2 | function play_tmstmp18(uint startTime) public { 3 | if (startTime + (5 * 1 days) == block.timestamp){ 4 | winner_tmstmp18 = msg.sender;}} 5 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/19.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp19; 2 | function play_tmstmp19(uint startTime) public { 3 | uint _vtime = block.timestamp; 4 | if (startTime + (5 * 1 days) == _vtime){ 5 | winner_tmstmp19 = msg.sender;}} 6 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/2.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp2; 2 | function play_tmstmp2(uint startTime) public { 3 | if (startTime + (5 * 1 days) == block.timestamp){ 4 | winner_tmstmp2 = msg.sender;}} 5 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/20.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp20 () public payable { 2 | uint pastBlockTime_tmstmp20; // Forces one bet per block 3 | require(msg.value == 10 ether); // must send 10 ether to play 4 | require(now != pastBlockTime_tmstmp20); // only 1 transaction per block //bug 5 | pastBlockTime_tmstmp20 = now; //bug 6 | if(now % 15 == 0) { // winner //bug 7 | msg.sender.transfer(address(this).balance); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/21.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp21() view public returns (bool) { 2 | return block.timestamp >= 1546300800; 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/22.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp22; 2 | function play_tmstmp22(uint startTime) public { 3 | if (startTime + (5 * 1 days) == block.timestamp){ 4 | winner_tmstmp22 = msg.sender;}} 5 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/23.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp23; 2 | function play_tmstmp23(uint startTime) public { 3 | uint _vtime = block.timestamp; 4 | if (startTime + (5 * 1 days) == _vtime){ 5 | winner_tmstmp23 = msg.sender;}} 6 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/24.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp24 () public payable { 2 | uint pastBlockTime_tmstmp24; // Forces one bet per block 3 | require(msg.value == 10 ether); // must send 10 ether to play 4 | require(now != pastBlockTime_tmstmp24); // only 1 transaction per block //bug 5 | pastBlockTime_tmstmp24 = now; //bug 6 | if(now % 15 == 0) { // winner //bug 7 | msg.sender.transfer(address(this).balance); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/25.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp25() view public returns (bool) { 2 | return block.timestamp >= 1546300800; 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/26.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp26; 2 | function play_tmstmp26(uint startTime) public { 3 | if (startTime + (5 * 1 days) == block.timestamp){ 4 | winner_tmstmp26 = msg.sender;}} 5 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/27.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp27; 2 | function play_tmstmp27(uint startTime) public { 3 | uint _vtime = block.timestamp; 4 | if (startTime + (5 * 1 days) == _vtime){ 5 | winner_tmstmp27 = msg.sender;}} 6 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/28.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp28 () public payable { 2 | uint pastBlockTime_tmstmp28; // Forces one bet per block 3 | require(msg.value == 10 ether); // must send 10 ether to play 4 | require(now != pastBlockTime_tmstmp28); // only 1 transaction per block //bug 5 | pastBlockTime_tmstmp28 = now; //bug 6 | if(now % 15 == 0) { // winner //bug 7 | msg.sender.transfer(address(this).balance); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/29.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp29() view public returns (bool) { 2 | return block.timestamp >= 1546300800; 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/3.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp3; 2 | function play_tmstmp3(uint startTime) public { 3 | uint _vtime = block.timestamp; 4 | if (startTime + (5 * 1 days) == _vtime){ 5 | winner_tmstmp3 = msg.sender;}} 6 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/30.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp30; 2 | function play_tmstmp30(uint startTime) public { 3 | if (startTime + (5 * 1 days) == block.timestamp){ 4 | winner_tmstmp30 = msg.sender;}} 5 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/31.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp31; 2 | function play_tmstmp31(uint startTime) public { 3 | uint _vtime = block.timestamp; 4 | if (startTime + (5 * 1 days) == _vtime){ 5 | winner_tmstmp31 = msg.sender;}} 6 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/32.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp32 () public payable { 2 | uint pastBlockTime_tmstmp32; // Forces one bet per block 3 | require(msg.value == 10 ether); // must send 10 ether to play 4 | require(now != pastBlockTime_tmstmp32); // only 1 transaction per block //bug 5 | pastBlockTime_tmstmp32 = now; //bug 6 | if(now % 15 == 0) { // winner //bug 7 | msg.sender.transfer(address(this).balance); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/33.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp33() view public returns (bool) { 2 | return block.timestamp >= 1546300800; 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/34.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp34; 2 | function play_tmstmp34(uint startTime) public { 3 | if (startTime + (5 * 1 days) == block.timestamp){ 4 | winner_tmstmp34 = msg.sender;}} 5 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/35.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp35; 2 | function play_tmstmp35(uint startTime) public { 3 | uint _vtime = block.timestamp; 4 | if (startTime + (5 * 1 days) == _vtime){ 5 | winner_tmstmp35 = msg.sender;}} 6 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/36.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp36 () public payable { 2 | uint pastBlockTime_tmstmp36; // Forces one bet per block 3 | require(msg.value == 10 ether); // must send 10 ether to play 4 | require(now != pastBlockTime_tmstmp36); // only 1 transaction per block //bug 5 | pastBlockTime_tmstmp36 = now; //bug 6 | if(now % 15 == 0) { // winner //bug 7 | msg.sender.transfer(address(this).balance); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/37.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp37() view public returns (bool) { 2 | return block.timestamp >= 1546300800; 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/38.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp38; 2 | function play_tmstmp38(uint startTime) public { 3 | if (startTime + (5 * 1 days) == block.timestamp){ 4 | winner_tmstmp38 = msg.sender;}} 5 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/39.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp39; 2 | function play_tmstmp39(uint startTime) public { 3 | uint _vtime = block.timestamp; 4 | if (startTime + (5 * 1 days) == _vtime){ 5 | winner_tmstmp39 = msg.sender;}} 6 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/4.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp4 () public payable { 2 | uint pastBlockTime_tmstmp4; // Forces one bet per block 3 | require(msg.value == 10 ether); // must send 10 ether to play 4 | require(now != pastBlockTime_tmstmp4); // only 1 transaction per block //bug 5 | pastBlockTime_tmstmp4 = now; //bug 6 | if(now % 15 == 0) { // winner //bug 7 | msg.sender.transfer(address(this).balance); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/40.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp40 () public payable { 2 | uint pastBlockTime_tmstmp40; // Forces one bet per block 3 | require(msg.value == 10 ether); // must send 10 ether to play 4 | require(now != pastBlockTime_tmstmp40); // only 1 transaction per block //bug 5 | pastBlockTime_tmstmp40 = now; //bug 6 | if(now % 15 == 0) { // winner //bug 7 | msg.sender.transfer(address(this).balance); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/5.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp5() view public returns (bool) { 2 | return block.timestamp >= 1546300800; 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/6.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp6; 2 | function play_tmstmp6(uint startTime) public { 3 | if (startTime + (5 * 1 days) == block.timestamp){ 4 | winner_tmstmp6 = msg.sender;}} 5 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/7.txt: -------------------------------------------------------------------------------- 1 | address winner_tmstmp7; 2 | function play_tmstmp7(uint startTime) public { 3 | uint _vtime = block.timestamp; 4 | if (startTime + (5 * 1 days) == _vtime){ 5 | winner_tmstmp7 = msg.sender;}} 6 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/8.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp8 () public payable { 2 | uint pastBlockTime_tmstmp8; // Forces one bet per block 3 | require(msg.value == 10 ether); // must send 10 ether to play 4 | require(now != pastBlockTime_tmstmp8); // only 1 transaction per block //bug 5 | pastBlockTime_tmstmp8 = now; //bug 6 | if(now % 15 == 0) { // winner //bug 7 | msg.sender.transfer(address(this).balance); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/tf/9.txt: -------------------------------------------------------------------------------- 1 | function bug_tmstmp9() view public returns (bool) { 2 | return block.timestamp >= 1546300800; 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/ts/1.txt: -------------------------------------------------------------------------------- 1 | uint256 bugv_tmstmp1 = block.timestamp; 2 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/ts/2.txt: -------------------------------------------------------------------------------- 1 | uint256 bugv_tmstmp2 = block.timestamp; 2 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/ts/3.txt: -------------------------------------------------------------------------------- 1 | uint256 bugv_tmstmp3 = block.timestamp; 2 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/ts/4.txt: -------------------------------------------------------------------------------- 1 | uint256 bugv_tmstmp4 = block.timestamp; 2 | -------------------------------------------------------------------------------- /bugs/Timestamp-Dependency/ts/5.txt: -------------------------------------------------------------------------------- 1 | uint256 bugv_tmstmp5 = block.timestamp; 2 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/1.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send1() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/10.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send10() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/11.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send11() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/12.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send12() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/13.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send13() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/14.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send14() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/15.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send15() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/16.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send16() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/17.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send17() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/18.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send18() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/19.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send19() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/2.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send2() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/20.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send20() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/21.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send21() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/22.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send22() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/23.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send23() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/24.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send24() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/25.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send25() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/26.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send26() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/27.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send27() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/28.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send28() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/29.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send29() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/3.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send3() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/30.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send30() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/31.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send31() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/32.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send32() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/4.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send4() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/5.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send5() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/6.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send6() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/7.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send7() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/8.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send8() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unchecked-Send/tf/9.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk_send9() payable public{ 2 | msg.sender.transfer(1 ether);} 3 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/1.txt: -------------------------------------------------------------------------------- 1 | function callnotchecked_unchk1(address payable callee) public { 2 | callee.call.value(2 ether); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/10.txt: -------------------------------------------------------------------------------- 1 | function cash_unchk10(uint roundIndex, uint subpotIndex,address payable winner_unchk10) public{ 2 | uint64 subpot_unchk10 = 10 ether; 3 | winner_unchk10.send(subpot_unchk10); //bug 4 | subpot_unchk10= 0; 5 | } 6 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/11.txt: -------------------------------------------------------------------------------- 1 | function my_func_unchk11(address payable dst) public payable{ 2 | dst.send(msg.value); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/12.txt: -------------------------------------------------------------------------------- 1 | function my_func_uncheck12(address payable dst) public payable{ 2 | dst.call.value(msg.value)(""); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/13.txt: -------------------------------------------------------------------------------- 1 | function callnotchecked_unchk13(address callee) public { 2 | callee.call.value(1 ether); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/14.txt: -------------------------------------------------------------------------------- 1 | function unhandledsend_unchk14(address payable callee) public { 2 | callee.send(5 ether); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/15.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk15(address payable addr) public 2 | {addr.send (42 ether); } 3 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/16.txt: -------------------------------------------------------------------------------- 1 | function UncheckedExternalCall_unchk16 () public 2 | { address payable addr_unchk16; 3 | if (! addr_unchk16.send (42 ether)) 4 | {// comment1; 5 | } 6 | else 7 | {//comment2; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/17.txt: -------------------------------------------------------------------------------- 1 | function withdrawBal_unchk17 () public{ 2 | uint64 Balances_unchk17 = 0; 3 | msg.sender.send(Balances_unchk17);} 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/18.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk18() public{ 2 | uint receivers_unchk18; 3 | address payable addr_unchk18; 4 | if (!addr_unchk18.send(42 ether)) 5 | {receivers_unchk18 +=1;} 6 | else 7 | {revert();} 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/19.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk19() public{ 2 | address payable addr_unchk19; 3 | if (!addr_unchk19.send (10 ether) || 1==1) 4 | {revert();} 5 | } 6 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/2.txt: -------------------------------------------------------------------------------- 1 | function unhandledsend_unchk2(address payable callee) public { 2 | callee.send(5 ether); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/20.txt: -------------------------------------------------------------------------------- 1 | bool public payedOut_unchk20 = false; 2 | address payable public winner_unchk20; 3 | uint public winAmount_unchk20; 4 | 5 | function sendToWinner_unchk20() public { 6 | require(!payedOut_unchk20); 7 | winner_unchk20.send(winAmount_unchk20); 8 | payedOut_unchk20 = true; 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/21.txt: -------------------------------------------------------------------------------- 1 | bool public payedOut_unchk21 = false; 2 | 3 | function withdrawLeftOver_unchk21() public { 4 | require(payedOut_unchk21); 5 | msg.sender.send(address(this).balance); 6 | } 7 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/22.txt: -------------------------------------------------------------------------------- 1 | function cash_unchk22(uint roundIndex, uint subpotIndex, address payable winner_unchk22)public{ 2 | uint64 subpot_unchk22 = 10 ether; 3 | winner_unchk22.send(subpot_unchk22); //bug 4 | subpot_unchk22= 0; 5 | } 6 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/23.txt: -------------------------------------------------------------------------------- 1 | function my_func_unchk23(address payable dst) public payable{ 2 | dst.send(msg.value); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/24.txt: -------------------------------------------------------------------------------- 1 | function my_func_uncheck24(address payable dst) public payable{ 2 | dst.call.value(msg.value)(""); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/25.txt: -------------------------------------------------------------------------------- 1 | function callnotchecked_unchk25(address payable callee) public { 2 | callee.call.value(1 ether); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/26.txt: -------------------------------------------------------------------------------- 1 | function unhandledsend_unchk26(address payable callee) public { 2 | callee.send(5 ether); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/27.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk27(address payable addr) public 2 | {addr.send (42 ether); } 3 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/28.txt: -------------------------------------------------------------------------------- 1 | function UncheckedExternalCall_unchk28 () public 2 | { address payable addr_unchk28; 3 | if (! addr_unchk28.send (42 ether)) 4 | {// comment1; 5 | } 6 | else 7 | {//comment2; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/29.txt: -------------------------------------------------------------------------------- 1 | function withdrawBal_unchk29 () public{ 2 | uint Balances_unchk29 = 0; 3 | msg.sender.send(Balances_unchk29);} 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/3.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk3(address payable addr) public 2 | {addr.send (42 ether); } 3 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/30.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk30() public{ 2 | uint receivers_unchk30; 3 | address payable addr_unchk30; 4 | if (!addr_unchk30.send(42 ether)) 5 | {receivers_unchk30 +=1;} 6 | else 7 | {revert();} 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/31.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk31() public{ 2 | address payable addr_unchk31; 3 | if (!addr_unchk31.send (10 ether) || 1==1) 4 | {revert();} 5 | } 6 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/32.txt: -------------------------------------------------------------------------------- 1 | bool public payedOut_unchk32 = false; 2 | address payable public winner_unchk32; 3 | uint public winAmount_unchk32; 4 | 5 | function sendToWinner_unchk32() public { 6 | require(!payedOut_unchk32); 7 | winner_unchk32.send(winAmount_unchk32); 8 | payedOut_unchk32 = true; 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/33.txt: -------------------------------------------------------------------------------- 1 | bool public payedOut_unchk33 = false; 2 | 3 | function withdrawLeftOver_unchk33() public { 4 | require(payedOut_unchk33); 5 | msg.sender.send(address(this).balance); 6 | } 7 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/34.txt: -------------------------------------------------------------------------------- 1 | function cash_unchk34(uint roundIndex, uint subpotIndex, address payable winner_unchk34) public{ 2 | uint64 subpot_unchk34 = 10 ether; 3 | winner_unchk34.send(subpot_unchk34); //bug 4 | subpot_unchk34= 0; 5 | } 6 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/35.txt: -------------------------------------------------------------------------------- 1 | function my_func_unchk35(address payable dst) public payable{ 2 | dst.send(msg.value); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/36.txt: -------------------------------------------------------------------------------- 1 | function my_func_uncheck36(address payable dst) public payable{ 2 | dst.call.value(msg.value)(""); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/37.txt: -------------------------------------------------------------------------------- 1 | function callnotchecked_unchk37(address payable callee) public { 2 | callee.call.value(1 ether); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/38.txt: -------------------------------------------------------------------------------- 1 | function unhandledsend_unchk38(address payable callee) public { 2 | callee.send(5 ether); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/39.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk39(address payable addr) public 2 | {addr.send (4 ether); } 3 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/4.txt: -------------------------------------------------------------------------------- 1 | function UncheckedExternalCall_unchk4 () public 2 | { address payable addr_unchk4; 3 | if (! addr_unchk4.send (42 ether)) 4 | {// comment1; 5 | } 6 | else 7 | {//comment2; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/40.txt: -------------------------------------------------------------------------------- 1 | function UncheckedExternalCall_unchk40 () public 2 | { address payable addr_unchk40; 3 | if (! addr_unchk40.send (2 ether)) 4 | {// comment1; 5 | } 6 | else 7 | {//comment2; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/41.txt: -------------------------------------------------------------------------------- 1 | function withdrawBal_unchk41 () public{ 2 | uint64 Balances_unchk41 = 0; 3 | msg.sender.send(Balances_unchk41);} 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/42.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk42() public{ 2 | uint receivers_unchk42; 3 | address payable addr_unchk42; 4 | if (!addr_unchk42.send(42 ether)) 5 | {receivers_unchk42 +=1;} 6 | else 7 | {revert();} 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/43.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk43() public{ 2 | address payable addr_unchk43; 3 | if (!addr_unchk43.send (10 ether) || 1==1) 4 | {revert();} 5 | } 6 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/44.txt: -------------------------------------------------------------------------------- 1 | bool public payedOut_unchk44 = false; 2 | address payable public winner_unchk44; 3 | uint public winAmount_unchk44; 4 | 5 | function sendToWinner_unchk44() public { 6 | require(!payedOut_unchk44); 7 | winner_unchk44.send(winAmount_unchk44); 8 | payedOut_unchk44 = true; 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/45.txt: -------------------------------------------------------------------------------- 1 | bool public payedOut_unchk45 = false; 2 | 3 | function withdrawLeftOver_unchk45() public { 4 | require(payedOut_unchk45); 5 | msg.sender.send(address(this).balance); 6 | } 7 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/46.txt: -------------------------------------------------------------------------------- 1 | function cash_unchk46(uint roundIndex, uint subpotIndex, address payable winner_unchk46) public{ 2 | uint64 subpot_unchk46 = 3 ether; 3 | winner_unchk46.send(subpot_unchk46); //bug 4 | subpot_unchk46= 0; 5 | } 6 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/47.txt: -------------------------------------------------------------------------------- 1 | function my_func_unchk47(address payable dst) public payable{ 2 | dst.send(msg.value); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/48.txt: -------------------------------------------------------------------------------- 1 | function my_func_uncheck48(address payable dst) public payable{ 2 | dst.call.value(msg.value)(""); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/5.txt: -------------------------------------------------------------------------------- 1 | function withdrawBal_unchk5 () public{ 2 | uint64 Balances_unchk5 = 0; 3 | msg.sender.send(Balances_unchk5);} 4 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/6.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk6() public{ 2 | uint receivers_unchk6; 3 | address payable addr_unchk6; 4 | if (!addr_unchk6.send(42 ether)) 5 | {receivers_unchk6 +=1;} 6 | else 7 | {revert();} 8 | } 9 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/7.txt: -------------------------------------------------------------------------------- 1 | function bug_unchk7() public{ 2 | address payable addr_unchk7; 3 | if (!addr_unchk7.send (10 ether) || 1==1) 4 | {revert();} 5 | } -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/8.txt: -------------------------------------------------------------------------------- 1 | bool public payedOut_unchk8 = false; 2 | address payable public winner_unchk8; 3 | uint public winAmount_unchk8; 4 | 5 | function sendToWinner_unchk8() public { 6 | require(!payedOut_unchk8); 7 | winner_unchk8.send(winAmount_unchk8); 8 | payedOut_unchk8 = true; 9 | } 10 | -------------------------------------------------------------------------------- /bugs/Unhandled-Exceptions/tf/9.txt: -------------------------------------------------------------------------------- 1 | bool public payedOut_unchk9 = false; 2 | 3 | function withdrawLeftOver_unchk9() public { 4 | require(payedOut_unchk9); 5 | msg.sender.send(address(this).balance); 6 | } 7 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/1.txt: -------------------------------------------------------------------------------- 1 | 2 | function sendto_txorigin1(address payable receiver, uint amount,address owner_txorigin1) public { 3 | require (tx.origin == owner_txorigin1); 4 | receiver.transfer(amount); 5 | } 6 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/10.txt: -------------------------------------------------------------------------------- 1 | function withdrawAll_txorigin10(address payable _recipient,address owner_txorigin10) public { 2 | require(tx.origin == owner_txorigin10); 3 | _recipient.transfer(address(this).balance); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/11.txt: -------------------------------------------------------------------------------- 1 | function transferTo_txorigin11(address to, uint amount,address owner_txorigin11) public { 2 | require(tx.origin == owner_txorigin11); 3 | to.call.value(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/12.txt: -------------------------------------------------------------------------------- 1 | function bug_txorigin12(address owner_txorigin12) public{ 2 | require(tx.origin == owner_txorigin12); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/13.txt: -------------------------------------------------------------------------------- 1 | function sendto_txorigin13(address payable receiver, uint amount,address owner_txorigin13) public { 2 | require (tx.origin == owner_txorigin13); 3 | receiver.transfer(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/14.txt: -------------------------------------------------------------------------------- 1 | function withdrawAll_txorigin14(address payable _recipient,address owner_txorigin14) public { 2 | require(tx.origin == owner_txorigin14); 3 | _recipient.transfer(address(this).balance); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/15.txt: -------------------------------------------------------------------------------- 1 | function transferTo_txorigin15(address to, uint amount,address owner_txorigin15) public { 2 | require(tx.origin == owner_txorigin15); 3 | to.call.value(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/16.txt: -------------------------------------------------------------------------------- 1 | function bug_txorigin16(address owner_txorigin16) public{ 2 | require(tx.origin == owner_txorigin16); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/17.txt: -------------------------------------------------------------------------------- 1 | function sendto_txorigin17(address payable receiver, uint amount,address owner_txorigin17) public { 2 | require (tx.origin == owner_txorigin17); 3 | receiver.transfer(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/18.txt: -------------------------------------------------------------------------------- 1 | function withdrawAll_txorigin18(address payable _recipient,address owner_txorigin18) public { 2 | require(tx.origin == owner_txorigin18); 3 | _recipient.transfer(address(this).balance); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/19.txt: -------------------------------------------------------------------------------- 1 | function transferTo_txorigin19(address to, uint amount,address owner_txorigin19) public { 2 | require(tx.origin == owner_txorigin19); 3 | to.call.value(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/2.txt: -------------------------------------------------------------------------------- 1 | 2 | function withdrawAll_txorigin2(address payable _recipient,address owner_txorigin2) public { 3 | require(tx.origin == owner_txorigin2); 4 | _recipient.transfer(address(this).balance); 5 | } 6 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/20.txt: -------------------------------------------------------------------------------- 1 | function bug_txorigin20(address owner_txorigin20) public{ 2 | require(tx.origin == owner_txorigin20); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/21.txt: -------------------------------------------------------------------------------- 1 | function sendto_txorigin21(address payable receiver, uint amount,address owner_txorigin21) public { 2 | require (tx.origin == owner_txorigin21); 3 | receiver.transfer(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/22.txt: -------------------------------------------------------------------------------- 1 | function withdrawAll_txorigin22(address payable _recipient,address owner_txorigin22) public { 2 | require(tx.origin == owner_txorigin22); 3 | _recipient.transfer(address(this).balance); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/23.txt: -------------------------------------------------------------------------------- 1 | function transferTo_txorigin23(address to, uint amount,address owner_txorigin23) public { 2 | require(tx.origin == owner_txorigin23); 3 | to.call.value(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/24.txt: -------------------------------------------------------------------------------- 1 | function bug_txorigin24( address owner_txorigin24) public{ 2 | require(tx.origin == owner_txorigin24); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/25.txt: -------------------------------------------------------------------------------- 1 | function sendto_txorigin25(address payable receiver, uint amount,address owner_txorigin25) public { 2 | require (tx.origin == owner_txorigin25); 3 | receiver.transfer(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/26.txt: -------------------------------------------------------------------------------- 1 | function withdrawAll_txorigin26(address payable _recipient,address owner_txorigin26) public { 2 | require(tx.origin == owner_txorigin26); 3 | _recipient.transfer(address(this).balance); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/27.txt: -------------------------------------------------------------------------------- 1 | function transferTo_txorigin27(address to, uint amount,address owner_txorigin27) public { 2 | require(tx.origin == owner_txorigin27); 3 | to.call.value(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/28.txt: -------------------------------------------------------------------------------- 1 | function bug_txorigin28( address owner_txorigin28) public{ 2 | require(tx.origin == owner_txorigin28); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/29.txt: -------------------------------------------------------------------------------- 1 | function sendto_txorigin29(address payable receiver, uint amount,address owner_txorigin29) public { 2 | require (tx.origin == owner_txorigin29); 3 | receiver.transfer(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/3.txt: -------------------------------------------------------------------------------- 1 | function transferTo_txorigin3(address to, uint amount,address owner_txorigin3) public { 2 | require(tx.origin == owner_txorigin3); 3 | to.call.value(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/30.txt: -------------------------------------------------------------------------------- 1 | function withdrawAll_txorigin30(address payable _recipient,address owner_txorigin30) public { 2 | require(tx.origin == owner_txorigin30); 3 | _recipient.transfer(address(this).balance); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/31.txt: -------------------------------------------------------------------------------- 1 | function transferTo_txorigin31(address to, uint amount,address owner_txorigin31) public { 2 | require(tx.origin == owner_txorigin31); 3 | to.call.value(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/32.txt: -------------------------------------------------------------------------------- 1 | function bug_txorigin32( address owner_txorigin32) public{ 2 | require(tx.origin == owner_txorigin32); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/33.txt: -------------------------------------------------------------------------------- 1 | function sendto_txorigin33(address payable receiver, uint amount,address owner_txorigin33) public { 2 | require (tx.origin == owner_txorigin33); 3 | receiver.transfer(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/34.txt: -------------------------------------------------------------------------------- 1 | function withdrawAll_txorigin34(address payable _recipient,address owner_txorigin34) public { 2 | require(tx.origin == owner_txorigin34); 3 | _recipient.transfer(address(this).balance); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/35.txt: -------------------------------------------------------------------------------- 1 | function transferTo_txorigin35(address to, uint amount,address owner_txorigin35) public { 2 | require(tx.origin == owner_txorigin35); 3 | to.call.value(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/36.txt: -------------------------------------------------------------------------------- 1 | function bug_txorigin36( address owner_txorigin36) public{ 2 | require(tx.origin == owner_txorigin36); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/37.txt: -------------------------------------------------------------------------------- 1 | function sendto_txorigin37(address payable receiver, uint amount,address owner_txorigin37) public { 2 | require (tx.origin == owner_txorigin37); 3 | receiver.transfer(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/38.txt: -------------------------------------------------------------------------------- 1 | function withdrawAll_txorigin38(address payable _recipient,address owner_txorigin38) public { 2 | require(tx.origin == owner_txorigin38); 3 | _recipient.transfer(address(this).balance); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/39.txt: -------------------------------------------------------------------------------- 1 | function transferTo_txorigin39(address to, uint amount,address owner_txorigin39) public { 2 | require(tx.origin == owner_txorigin39); 3 | to.call.value(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/4.txt: -------------------------------------------------------------------------------- 1 | function bug_txorigin4(address owner_txorigin4) public{ 2 | require(tx.origin == owner_txorigin4); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/40.txt: -------------------------------------------------------------------------------- 1 | function bug_txorigin40(address owner_txorigin40) public{ 2 | require(tx.origin == owner_txorigin40); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/5.txt: -------------------------------------------------------------------------------- 1 | function sendto_txorigin5(address payable receiver, uint amount,address owner_txorigin5) public { 2 | require (tx.origin == owner_txorigin5); 3 | receiver.transfer(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/6.txt: -------------------------------------------------------------------------------- 1 | function withdrawAll_txorigin6(address payable _recipient,address owner_txorigin6) public { 2 | require(tx.origin == owner_txorigin6); 3 | _recipient.transfer(address(this).balance); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/7.txt: -------------------------------------------------------------------------------- 1 | function transferTo_txorigin7(address to, uint amount,address owner_txorigin7) public { 2 | require(tx.origin == owner_txorigin7); 3 | to.call.value(amount); 4 | } 5 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/8.txt: -------------------------------------------------------------------------------- 1 | function bug_txorigin8(address owner_txorigin8) public{ 2 | require(tx.origin == owner_txorigin8); 3 | } 4 | -------------------------------------------------------------------------------- /bugs/tx-origin/tf/9.txt: -------------------------------------------------------------------------------- 1 | function sendto_txorigin9(address payable receiver, uint amount,address owner_txorigin9) public { 2 | require (tx.origin == owner_txorigin9); 3 | receiver.transfer(amount); 4 | } 5 | -------------------------------------------------------------------------------- /code_trans.conf: -------------------------------------------------------------------------------- 1 | [1] 2 | bug_type=tx.origin 3 | current_snippet=msg.sender\s{0,}==\s{0,}owner 4 | bug_snippet=tx.origin = owner 5 | 6 | [2] 7 | bug_type=Overflow-Underflow 8 | current_snippet= bytes32 9 | bug_snippet=bytes8 10 | 11 | [3] 12 | bug_type=Overflow-Underflow 13 | current_snippet=uint256 14 | bug_snippet=uint8 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /contracts/1.sol: -------------------------------------------------------------------------------- 1 | /** 2 | * Source Code first verified at https://etherscan.io on Tuesday, May 7, 2019 3 | (UTC) */ 4 | 5 | pragma solidity >=0.4.22 <0.6.0; 6 | contract EIP20Interface { 7 | /* This is a slight change to the ERC20 base standard. 8 | function totalSupply() constant returns (uint256 supply); 9 | is replaced with: 10 | uint256 public totalSupply; 11 | This automatically creates a getter function for the totalSupply. 12 | This is moved to the base contract since public getter functions are not 13 | currently recognised as an implementation of the matching abstract 14 | function by the compiler. 15 | */ 16 | /// total amount of tokens 17 | uint256 public totalSupply; 18 | 19 | /// @param _owner The address from which the balance will be retrieved 20 | /// @return The balance 21 | function balanceOf(address _owner) public view returns (uint256 balance); 22 | 23 | /// @notice send `_value` token to `_to` from `msg.sender` 24 | /// @param _to The address of the recipient 25 | /// @param _value The amount of token to be transferred 26 | /// @return Whether the transfer was successful or not 27 | function transfer(address _to, uint256 _value) public returns (bool success); 28 | 29 | /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` 30 | /// @param _from The address of the sender 31 | /// @param _to The address of the recipient 32 | /// @param _value The amount of token to be transferred 33 | /// @return Whether the transfer was successful or not 34 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); 35 | 36 | /// @notice `msg.sender` approves `_spender` to spend `_value` tokens 37 | /// @param _spender The address of the account able to transfer the tokens 38 | /// @param _value The amount of tokens to be approved for transfer 39 | /// @return Whether the approval was successful or not 40 | function approve(address _spender, uint256 _value) public returns (bool success); 41 | 42 | /// @param _owner The address of the account owning tokens 43 | /// @param _spender The address of the account able to transfer the tokens 44 | /// @return Amount of remaining tokens allowed to spent 45 | function allowance(address _owner, address _spender) public view returns (uint256 remaining); 46 | 47 | // solhint-disable-next-line no-simple-event-func-name 48 | event Transfer(address indexed _from, address indexed _to, uint256 _value); 49 | event Approval(address indexed _owner, address indexed _spender, uint256 _value); 50 | } 51 | 52 | contract HotDollarsToken is EIP20Interface { 53 | uint256 constant private MAX_UINT256 = 2**256 - 1; 54 | mapping (address => uint256) public balances; 55 | mapping (address => mapping (address => uint256)) public allowed; 56 | /* 57 | NOTE: 58 | The following variables are OPTIONAL vanities. One does not have to include them. 59 | They allow one to customise the token contract & in no way influences the core functionality. 60 | Some wallets/interfaces might not even bother to look at this information. 61 | */ 62 | string public name; //fancy name: eg Simon Bucks 63 | uint8 public decimals; //How many decimals to show. 64 | string public symbol; //An identifier: eg SBX 65 | 66 | constructor() public { 67 | totalSupply = 3 * 1e28; 68 | name = "HotDollars Token"; 69 | decimals = 18; 70 | symbol = "HDS"; 71 | balances[msg.sender] = totalSupply; 72 | } 73 | 74 | function transfer(address _to, uint256 _value) public returns (bool success) { 75 | require(balances[msg.sender] >= _value); 76 | balances[msg.sender] -= _value; 77 | balances[_to] += _value; 78 | emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars 79 | return true; 80 | } 81 | 82 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { 83 | uint256 allowance = allowed[_from][msg.sender]; 84 | require(balances[_from] >= _value && allowance >= _value); 85 | balances[_to] += _value; 86 | balances[_from] -= _value; 87 | if (allowance < MAX_UINT256) { 88 | allowed[_from][msg.sender] -= _value; 89 | } 90 | emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars 91 | return true; 92 | } 93 | 94 | function balanceOf(address _owner) public view returns (uint256 balance) { 95 | return balances[_owner]; 96 | } 97 | 98 | function approve(address _spender, uint256 _value) public returns (bool success) { 99 | allowed[msg.sender][_spender] = _value; 100 | emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars 101 | return true; 102 | } 103 | 104 | function allowance(address _owner, address _spender) public view returns (uint256 remaining) { 105 | return allowed[_owner][_spender]; 106 | } 107 | } -------------------------------------------------------------------------------- /contracts/10.sol: -------------------------------------------------------------------------------- 1 | /** 2 | * Source Code first verified at https://etherscan.io on Friday, April 26, 2019 3 | (UTC) */ 4 | 5 | pragma solidity >=0.4.21 < 0.6.0; 6 | 7 | contract DocumentSigner { 8 | mapping(bytes32=>string) public docs; 9 | mapping(bytes32=>address[]) public signers; 10 | 11 | modifier validDoc(bytes32 _docHash) { 12 | require(bytes(docs[_docHash]).length != 0, "Document is not submitted"); 13 | _; 14 | } 15 | 16 | event Sign(bytes32 indexed _doc, address indexed _signer); 17 | event NewDocument(bytes32 _docHash); 18 | 19 | function submitDocument(string memory _doc) public { 20 | bytes32 _docHash = getHash(_doc); 21 | if(bytes(docs[_docHash]).length == 0) { 22 | docs[_docHash] = _doc; 23 | emit NewDocument(_docHash); 24 | } 25 | } 26 | 27 | function signDocument(bytes32 _docHash) public validDoc(_docHash){ 28 | address[] storage _signers = signers[_docHash]; 29 | for(uint i = 0; i < _signers.length; i++) { 30 | if(_signers[i] == msg.sender) return; 31 | } 32 | _signers.push(msg.sender); 33 | } 34 | 35 | function getDetail(bytes32 _docHash) public validDoc(_docHash) view returns(string memory _doc, address[] memory _signers) { 36 | _doc = docs[_docHash]; 37 | _signers = signers[_docHash]; 38 | } 39 | 40 | function getHash(string memory _doc) public pure returns(bytes32) { 41 | return keccak256(abi.encodePacked(_doc)); 42 | } 43 | } -------------------------------------------------------------------------------- /contracts/13.sol: -------------------------------------------------------------------------------- 1 | /** 2 | * Source Code first verified at https://etherscan.io on Thursday, April 25, 2019 3 | (UTC) */ 4 | 5 | pragma solidity >=0.4.22 <0.6.0; 6 | 7 | interface tokenRecipient { 8 | function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external; 9 | } 10 | 11 | contract BitCash { 12 | // Public variables of the token 13 | string public name; 14 | string public symbol; 15 | uint8 public decimals = 18; 16 | // 18 decimals is the strongly suggested default, avoid changing it 17 | uint256 public totalSupply; 18 | 19 | // This creates an array with all balances 20 | mapping (address => uint256) public balanceOf; 21 | mapping (address => mapping (address => uint256)) public allowance; 22 | 23 | // This generates a public event on the blockchain that will notify clients 24 | event Transfer(address indexed from, address indexed to, uint256 value); 25 | 26 | // This generates a public event on the blockchain that will notify clients 27 | event Approval(address indexed _owner, address indexed _spender, uint256 _value); 28 | 29 | // This notifies clients about the amount burnt 30 | event Burn(address indexed from, uint256 value); 31 | 32 | /** 33 | * Constructor function 34 | * 35 | * Initializes contract with initial supply tokens to the creator of the contract 36 | */ 37 | constructor( 38 | uint256 initialSupply, 39 | string memory tokenName, 40 | string memory tokenSymbol 41 | ) public { 42 | totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount 43 | balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens 44 | name = tokenName; // Set the name for display purposes 45 | symbol = tokenSymbol; // Set the symbol for display purposes 46 | } 47 | 48 | /** 49 | * Internal transfer, only can be called by this contract 50 | */ 51 | function _transfer(address _from, address _to, uint _value) internal { 52 | // Prevent transfer to 0x0 address. Use burn() instead 53 | require(_to != address(0x0)); 54 | // Check if the sender has enough 55 | require(balanceOf[_from] >= _value); 56 | // Check for overflows 57 | require(balanceOf[_to] + _value >= balanceOf[_to]); 58 | // Save this for an assertion in the future 59 | uint previousBalances = balanceOf[_from] + balanceOf[_to]; 60 | // Subtract from the sender 61 | balanceOf[_from] -= _value; 62 | // Add the same to the recipient 63 | balanceOf[_to] += _value; 64 | emit Transfer(_from, _to, _value); 65 | // Asserts are used to use static analysis to find bugs in your code. They should never fail 66 | assert(balanceOf[_from] + balanceOf[_to] == previousBalances); 67 | } 68 | 69 | /** 70 | * Transfer tokens 71 | * 72 | * Send `_value` tokens to `_to` from your account 73 | * 74 | * @param _to The address of the recipient 75 | * @param _value the amount to send 76 | */ 77 | function transfer(address _to, uint256 _value) public returns (bool success) { 78 | _transfer(msg.sender, _to, _value); 79 | return true; 80 | } 81 | 82 | /** 83 | * Transfer tokens from other address 84 | * 85 | * Send `_value` tokens to `_to` on behalf of `_from` 86 | * 87 | * @param _from The address of the sender 88 | * @param _to The address of the recipient 89 | * @param _value the amount to send 90 | */ 91 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { 92 | require(_value <= allowance[_from][msg.sender]); // Check allowance 93 | allowance[_from][msg.sender] -= _value; 94 | _transfer(_from, _to, _value); 95 | return true; 96 | } 97 | 98 | /** 99 | * Set allowance for other address 100 | * 101 | * Allows `_spender` to spend no more than `_value` tokens on your behalf 102 | * 103 | * @param _spender The address authorized to spend 104 | * @param _value the max amount they can spend 105 | */ 106 | function approve(address _spender, uint256 _value) public 107 | returns (bool success) { 108 | allowance[msg.sender][_spender] = _value; 109 | emit Approval(msg.sender, _spender, _value); 110 | return true; 111 | } 112 | 113 | /** 114 | * Set allowance for other address and notify 115 | * 116 | * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it 117 | * 118 | * @param _spender The address authorized to spend 119 | * @param _value the max amount they can spend 120 | * @param _extraData some extra information to send to the approved contract 121 | */ 122 | function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) 123 | public 124 | returns (bool success) { 125 | tokenRecipient spender = tokenRecipient(_spender); 126 | if (approve(_spender, _value)) { 127 | spender.receiveApproval(msg.sender, _value, address(this), _extraData); 128 | return true; 129 | } 130 | } 131 | 132 | /** 133 | * Destroy tokens 134 | * 135 | * Remove `_value` tokens from the system irreversibly 136 | * 137 | * @param _value the amount of money to burn 138 | */ 139 | function burn(uint256 _value) public returns (bool success) { 140 | require(balanceOf[msg.sender] >= _value); // Check if the sender has enough 141 | balanceOf[msg.sender] -= _value; // Subtract from the sender 142 | totalSupply -= _value; // Updates totalSupply 143 | emit Burn(msg.sender, _value); 144 | return true; 145 | } 146 | 147 | /** 148 | * Destroy tokens from other account 149 | * 150 | * Remove `_value` tokens from the system irreversibly on behalf of `_from`. 151 | * 152 | * @param _from the address of the sender 153 | * @param _value the amount of money to burn 154 | */ 155 | function burnFrom(address _from, uint256 _value) public returns (bool success) { 156 | require(balanceOf[_from] >= _value); // Check if the targeted balance is enough 157 | require(_value <= allowance[_from][msg.sender]); // Check allowance 158 | balanceOf[_from] -= _value; // Subtract from the targeted balance 159 | allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance 160 | totalSupply -= _value; // Update totalSupply 161 | emit Burn(_from, _value); 162 | return true; 163 | } 164 | } -------------------------------------------------------------------------------- /contracts/14.sol: -------------------------------------------------------------------------------- 1 | /** 2 | * Source Code first verified at https://etherscan.io on Friday, April 26, 2019 3 | (UTC) */ 4 | 5 | pragma solidity ^0.5.1; 6 | 7 | library SafeMath { 8 | 9 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 10 | 11 | if (a == 0) { 12 | return 0; 13 | } 14 | 15 | uint256 c = a * b; 16 | require(c / a == b); 17 | 18 | return c; 19 | } 20 | 21 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 22 | 23 | require(b > 0); 24 | uint256 c = a / b; 25 | 26 | return c; 27 | } 28 | 29 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 30 | require(b <= a); 31 | uint256 c = a - b; 32 | 33 | return c; 34 | } 35 | 36 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 37 | uint256 c = a + b; 38 | require(c >= a); 39 | 40 | return c; 41 | } 42 | 43 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 44 | require(b != 0); 45 | return a % b; 46 | } 47 | } 48 | 49 | interface IERC20 { 50 | function totalSupply() external view returns (uint256); 51 | 52 | function balanceOf(address who) external view returns (uint256); 53 | 54 | function transfer(address to, uint256 value) external returns (bool); 55 | 56 | function transferFrom(address from, address to, uint256 value) external returns (bool); 57 | 58 | function approve(address spender, uint256 value) external returns (bool); 59 | 60 | function allowance(address owner, address spender) external view returns (uint256); 61 | 62 | 63 | event Transfer(address indexed from, address indexed to, uint256 value); 64 | event Approval(address indexed owner, address indexed spender, uint256 value); 65 | event Burn(address indexed from, uint256 value); 66 | } 67 | 68 | 69 | contract ERC20 is IERC20 { 70 | 71 | using SafeMath for uint256; 72 | uint8 constant DECIMALS = 18; 73 | uint256 private _totalSupply; 74 | string private _name; 75 | string private _symbol; 76 | 77 | mapping (address => uint256) private _balances; 78 | mapping (address => mapping (address => uint256)) private _allowed; 79 | 80 | 81 | function totalSupply() public view returns (uint256) { 82 | return _totalSupply; 83 | } 84 | 85 | function balanceOf(address owner) public view returns (uint256) { 86 | return _balances[owner]; 87 | } 88 | 89 | function transfer(address to, uint256 value) public returns (bool) { 90 | _transfer(msg.sender, to, value); 91 | return true; 92 | } 93 | 94 | function transferFrom(address from, address to, uint256 value) public returns (bool) { 95 | _transfer(from, to, value); 96 | _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); 97 | return true; 98 | } 99 | 100 | function approve(address spender, uint256 value) public returns (bool) { 101 | _approve(msg.sender, spender, value); 102 | return true; 103 | } 104 | 105 | function allowance(address owner, address spender) public view returns (uint256) { 106 | return _allowed[owner][spender]; 107 | } 108 | 109 | function burn(uint256 value) public { 110 | _burn(msg.sender, value); 111 | } 112 | 113 | function _mint(address account, uint256 value) internal { 114 | require(account != address(0)); 115 | _totalSupply = _totalSupply.add(value); 116 | _balances[account] = _balances[account].add(value); 117 | emit Transfer(address(0), account, value); 118 | } 119 | 120 | function _transfer(address from, address to, uint256 value) internal { 121 | require(to != address(0)); 122 | 123 | _balances[from] = _balances[from].sub(value); 124 | _balances[to] = _balances[to].add(value); 125 | emit Transfer(from, to, value); 126 | 127 | } 128 | 129 | function _approve(address owner, address spender, uint256 value) internal { 130 | require(spender != address(0)); 131 | require(owner != address(0)); 132 | 133 | _allowed[owner][spender] = value; 134 | emit Approval(owner, spender, value); 135 | } 136 | 137 | function _burn(address account, uint256 value) internal { 138 | require(account != address(0)); 139 | 140 | _totalSupply = _totalSupply.sub(value); 141 | _balances[account] = _balances[account].sub(value); 142 | emit Transfer(account, address(0), value); 143 | } 144 | } 145 | 146 | contract ERC20Detailed is IERC20 { 147 | string private _name; 148 | string private _symbol; 149 | uint8 private _decimals; 150 | 151 | constructor (string memory name, string memory symbol, uint8 decimals) public { 152 | _name = name; 153 | _symbol = symbol; 154 | _decimals = decimals; 155 | } 156 | 157 | /** 158 | * @return the name of the token. 159 | */ 160 | function name() public view returns (string memory) { 161 | return _name; 162 | } 163 | 164 | /** 165 | * @return the symbol of the token. 166 | */ 167 | function symbol() public view returns (string memory) { 168 | return _symbol; 169 | } 170 | 171 | /** 172 | * @return the number of decimals of the token. 173 | */ 174 | function decimals() public view returns (uint8) { 175 | return _decimals; 176 | } 177 | } 178 | 179 | contract SaveWon is ERC20, ERC20Detailed { 180 | uint8 public constant DECIMALS = 18; 181 | uint256 public constant INITIAL_SUPPLY = 50000000000 * (10 ** uint256(DECIMALS)); 182 | 183 | /** 184 | * @dev Constructor that gives msg.sender all of existing tokens. 185 | */ 186 | constructor () public ERC20Detailed("SaveWon", "SVW", DECIMALS) { 187 | _mint(msg.sender, INITIAL_SUPPLY); 188 | } 189 | } -------------------------------------------------------------------------------- /contracts/15.sol: -------------------------------------------------------------------------------- 1 | /** 2 | * Source Code first verified at https://etherscan.io on Tuesday, April 30, 2019 3 | (UTC) */ 4 | 5 | pragma solidity ^0.5.7; 6 | 7 | interface tokenRecipient { 8 | function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external; 9 | } 10 | 11 | contract MD{ 12 | // Public variables of the token 13 | string public name; 14 | string public symbol; 15 | uint8 public decimals = 18; 16 | // 18 decimals is the strongly suggested default, avoid changing it 17 | uint256 public totalSupply; 18 | 19 | // This creates an array with all balances 20 | mapping (address => uint256) public balanceOf; 21 | mapping (address => mapping (address => uint256)) public allowance; 22 | 23 | // This generates a public event on the blockchain that will notify clients 24 | event Transfer(address indexed from, address indexed to, uint256 value); 25 | 26 | // This generates a public event on the blockchain that will notify clients 27 | event Approval(address indexed _owner, address indexed _spender, uint256 _value); 28 | 29 | // This notifies clients about the amount burnt 30 | event Burn(address indexed from, uint256 value); 31 | 32 | /** 33 | * Constructor function 34 | * 35 | * Initializes contract with initial supply tokens to the creator of the contract 36 | */ 37 | constructor( 38 | uint256 initialSupply, 39 | string memory tokenName, 40 | string memory tokenSymbol 41 | ) public { 42 | totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount 43 | balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens 44 | name = tokenName; // Set the name for display purposes 45 | symbol = tokenSymbol; // Set the symbol for display purposes 46 | } 47 | 48 | /** 49 | * Internal transfer, only can be called by this contract 50 | */ 51 | function _transfer(address _from, address _to, uint _value) internal { 52 | // Prevent transfer to 0x0 address. Use burn() instead 53 | require(_to != address(0x0)); 54 | // Check if the sender has enough 55 | require(balanceOf[_from] >= _value); 56 | // Check for overflows 57 | require(balanceOf[_to] + _value >= balanceOf[_to]); 58 | // Save this for an assertion in the future 59 | uint previousBalances = balanceOf[_from] + balanceOf[_to]; 60 | // Subtract from the sender 61 | balanceOf[_from] -= _value; 62 | // Add the same to the recipient 63 | balanceOf[_to] += _value; 64 | emit Transfer(_from, _to, _value); 65 | // Asserts are used to use static analysis to find bugs in your code. They should never fail 66 | assert(balanceOf[_from] + balanceOf[_to] == previousBalances); 67 | } 68 | 69 | /** 70 | * Transfer tokens 71 | * 72 | * Send `_value` tokens to `_to` from your account 73 | * 74 | * @param _to The address of the recipient 75 | * @param _value the amount to send 76 | */ 77 | function transfer(address _to, uint256 _value) public returns (bool success) { 78 | _transfer(msg.sender, _to, _value); 79 | return true; 80 | } 81 | 82 | /** 83 | * Transfer tokens from other address 84 | * 85 | * Send `_value` tokens to `_to` on behalf of `_from` 86 | * 87 | * @param _from The address of the sender 88 | * @param _to The address of the recipient 89 | * @param _value the amount to send 90 | */ 91 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { 92 | require(_value <= allowance[_from][msg.sender]); // Check allowance 93 | allowance[_from][msg.sender] -= _value; 94 | _transfer(_from, _to, _value); 95 | return true; 96 | } 97 | 98 | /** 99 | * Set allowance for other address 100 | * 101 | * Allows `_spender` to spend no more than `_value` tokens on your behalf 102 | * 103 | * @param _spender The address authorized to spend 104 | * @param _value the max amount they can spend 105 | */ 106 | function approve(address _spender, uint256 _value) public 107 | returns (bool success) { 108 | allowance[msg.sender][_spender] = _value; 109 | emit Approval(msg.sender, _spender, _value); 110 | return true; 111 | } 112 | 113 | /** 114 | * Set allowance for other address and notify 115 | * 116 | * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it 117 | * 118 | * @param _spender The address authorized to spend 119 | * @param _value the max amount they can spend 120 | * @param _extraData some extra information to send to the approved contract 121 | */ 122 | function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) 123 | public 124 | returns (bool success) { 125 | tokenRecipient spender = tokenRecipient(_spender); 126 | if (approve(_spender, _value)) { 127 | spender.receiveApproval(msg.sender, _value, address(this), _extraData); 128 | return true; 129 | } 130 | } 131 | 132 | /** 133 | * Destroy tokens 134 | * 135 | * Remove `_value` tokens from the system irreversibly 136 | * 137 | * @param _value the amount of money to burn 138 | */ 139 | function burn(uint256 _value) public returns (bool success) { 140 | require(balanceOf[msg.sender] >= _value); // Check if the sender has enough 141 | balanceOf[msg.sender] -= _value; // Subtract from the sender 142 | totalSupply -= _value; // Updates totalSupply 143 | emit Burn(msg.sender, _value); 144 | return true; 145 | } 146 | 147 | /** 148 | * Destroy tokens from other account 149 | * 150 | * Remove `_value` tokens from the system irreversibly on behalf of `_from`. 151 | * 152 | * @param _from the address of the sender 153 | * @param _value the amount of money to burn 154 | */ 155 | function burnFrom(address _from, uint256 _value) public returns (bool success) { 156 | require(balanceOf[_from] >= _value); // Check if the targeted balance is enough 157 | require(_value <= allowance[_from][msg.sender]); // Check allowance 158 | balanceOf[_from] -= _value; // Subtract from the targeted balance 159 | allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance 160 | totalSupply -= _value; // Update totalSupply 161 | emit Burn(_from, _value); 162 | return true; 163 | } 164 | } -------------------------------------------------------------------------------- /contracts/2.sol: -------------------------------------------------------------------------------- 1 | /** 2 | * Source Code first verified at https://etherscan.io on Tuesday, May 7, 2019 3 | (UTC) */ 4 | 5 | pragma solidity ^0.5.1; 6 | 7 | contract CareerOnToken { 8 | event Transfer(address indexed _from, address indexed _to, uint256 _value); 9 | event Approval(address indexed a_owner, address indexed _spender, uint256 _value); 10 | event OwnerChang(address indexed _old,address indexed _new,uint256 _coin_change); 11 | 12 | uint256 public totalSupply; 13 | string public name; //名称,例如"My test token" 14 | uint8 public decimals; //返回token使用的小数点后几位。比如如果设置为3,就是支持0.001表示. 15 | string public symbol; //token简称,like MTT 16 | address public owner; 17 | mapping (address => uint256) public balances; 18 | mapping (address => mapping (address => uint256)) public allowed; 19 | 20 | //如果通过函数setPauseStatus设置这个变量为TRUE,则所有转账交易都会失败 21 | bool isTransPaused=false; 22 | 23 | constructor( 24 | uint256 _initialAmount, 25 | uint8 _decimalUnits) public 26 | { 27 | owner=msg.sender;//记录合约的owner 28 | if(_initialAmount<=0){ 29 | totalSupply = 100000000000000000; // 设置初始总量 30 | balances[owner]=totalSupply; 31 | }else{ 32 | totalSupply = _initialAmount; // 设置初始总量 33 | balances[owner]=_initialAmount; 34 | } 35 | if(_decimalUnits<=0){ 36 | decimals=2; 37 | }else{ 38 | decimals = _decimalUnits; 39 | } 40 | name = "CareerOn Chain Token"; 41 | symbol = "COT"; 42 | } 43 | 44 | 45 | function transfer( 46 | address _to, 47 | uint256 _value) public returns (bool success) 48 | { 49 | assert(_to!=address(this) && 50 | !isTransPaused && 51 | balances[msg.sender] >= _value && 52 | balances[_to] + _value > balances[_to] 53 | ); 54 | 55 | balances[msg.sender] -= _value;//从消息发送者账户中减去token数量_value 56 | balances[_to] += _value;//往接收账户增加token数量_value 57 | if(msg.sender==owner){ 58 | emit Transfer(address(this), _to, _value);//触发转币交易事件 59 | }else{ 60 | emit Transfer(msg.sender, _to, _value);//触发转币交易事件 61 | } 62 | return true; 63 | } 64 | 65 | 66 | function transferFrom( 67 | address _from, 68 | address _to, 69 | uint256 _value) public returns (bool success) 70 | { 71 | assert(_to!=address(this) && 72 | !isTransPaused && 73 | balances[msg.sender] >= _value && 74 | balances[_to] + _value > balances[_to] && 75 | allowed[_from][msg.sender] >= _value 76 | ); 77 | 78 | balances[_to] += _value;//接收账户增加token数量_value 79 | balances[_from] -= _value; //支出账户_from减去token数量_value 80 | allowed[_from][msg.sender] -= _value;//消息发送者可以从账户_from中转出的数量减少_value 81 | if(_from==owner){ 82 | emit Transfer(address(this), _to, _value);//触发转币交易事件 83 | }else{ 84 | emit Transfer(_from, _to, _value);//触发转币交易事件 85 | } 86 | return true; 87 | } 88 | 89 | function approve(address _spender, uint256 _value) public returns (bool success) 90 | { 91 | assert(msg.sender!=_spender && _value>0); 92 | allowed[msg.sender][_spender] = _value; 93 | emit Approval(msg.sender, _spender, _value); 94 | return true; 95 | } 96 | 97 | function allowance( 98 | address _owner, 99 | address _spender) public view returns (uint256 remaining) 100 | { 101 | return allowed[_owner][_spender];//允许_spender从_owner中转出的token数 102 | } 103 | 104 | //以下为本代币协议的特殊逻辑 105 | //转移协议所有权并将附带的代币一并转移过去 106 | function changeOwner(address newOwner) public{ 107 | assert(msg.sender==owner && msg.sender!=newOwner); 108 | balances[newOwner]=balances[owner]; 109 | balances[owner]=0; 110 | owner=newOwner; 111 | emit OwnerChang(msg.sender,newOwner,balances[owner]);//触发合约所有权的转移事件 112 | } 113 | 114 | //isPaused为true则暂停所有转账交易 115 | function setPauseStatus(bool isPaused)public{ 116 | assert(msg.sender==owner); 117 | isTransPaused=isPaused; 118 | } 119 | 120 | //修改合约名字 121 | function changeContractName(string memory _newName,string memory _newSymbol) public { 122 | assert(msg.sender==owner); 123 | name=_newName; 124 | symbol=_newSymbol; 125 | } 126 | 127 | 128 | function () external payable { 129 | revert(); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /contracts/26.sol: -------------------------------------------------------------------------------- 1 | /** 2 | *Submitted for verification at Etherscan.io on 2019-09-23 3 | */ 4 | 5 | pragma solidity ^0.5.2; 6 | 7 | library SafeMath { 8 | 9 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 10 | uint256 c = a + b; 11 | require(c >= a, "SafeMath: addition overflow"); 12 | return c; 13 | } 14 | 15 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 16 | require(b <= a, "SafeMath: subtraction overflow"); 17 | uint256 c = a - b; 18 | return c; 19 | } 20 | 21 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 22 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 23 | // benefit is lost if 'b' is also tested. 24 | // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 25 | if (a == 0) { 26 | return 0; 27 | } 28 | 29 | uint256 c = a * b; 30 | require(c / a == b, "SafeMath: multiplication overflow"); 31 | 32 | return c; 33 | } 34 | 35 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 36 | // Solidity only automatically asserts when dividing by 0 37 | require(b > 0, "SafeMath: division by zero"); 38 | uint256 c = a / b; 39 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 40 | 41 | return c; 42 | } 43 | 44 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 45 | require(b != 0, "SafeMath: modulo by zero"); 46 | return a % b; 47 | } 48 | } 49 | 50 | interface IERC20 { 51 | function totalSupply() external view returns (uint256); 52 | function balanceOf(address account) external view returns (uint256); 53 | function transfer(address recipient, uint256 amount) external returns (bool); 54 | function allowance(address owner, address spender) external view returns (uint256); 55 | function approve(address spender, uint256 amount) external returns (bool); 56 | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); 57 | event Transfer(address indexed from, address indexed to, uint256 value); 58 | event Approval(address indexed owner, address indexed spender, uint256 value); 59 | } 60 | 61 | contract UBBCToken is IERC20 { 62 | using SafeMath for uint256; 63 | mapping (address => uint256) private _balances; 64 | mapping (address => mapping (address => uint256)) private _allowances; 65 | uint256 private _totalSupply; 66 | string private _name; 67 | string private _symbol; 68 | uint8 private _decimals; 69 | constructor() public { 70 | _name = "UBBC Token"; 71 | _symbol = "UBBC"; 72 | _decimals = 18; 73 | _totalSupply = 260000000 ether; 74 | _balances[0x0e475cd2c1f8222868cf85B4f97D7EB70fB3ffD3] = _totalSupply; 75 | } 76 | event Transfer(address sender, address to, uint256 value); 77 | 78 | event Approval(address owner, address spender, uint256 value); 79 | 80 | function name() public view returns (string memory) { 81 | return _name; 82 | } 83 | 84 | function symbol() public view returns (string memory) { 85 | return _symbol; 86 | } 87 | function decimals() public view returns (uint8) { 88 | return _decimals; 89 | } 90 | 91 | function totalSupply() public view returns (uint256) { 92 | return _totalSupply; 93 | } 94 | 95 | function balanceOf(address account) public view returns (uint256) { 96 | return _balances[account]; 97 | } 98 | 99 | function transfer(address recipient, uint256 amount) public returns (bool) { 100 | _transfer(msg.sender, recipient, amount); 101 | return true; 102 | } 103 | 104 | function allowance(address owner, address spender) public view returns (uint256) { 105 | return _allowances[owner][spender]; 106 | } 107 | 108 | function approve(address spender, uint256 value) public returns (bool) { 109 | _approve(msg.sender, spender, value); 110 | return true; 111 | } 112 | 113 | function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { 114 | _transfer(sender, recipient, amount); 115 | _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount)); 116 | return true; 117 | } 118 | 119 | function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { 120 | _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); 121 | return true; 122 | } 123 | 124 | function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { 125 | _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue)); 126 | return true; 127 | } 128 | 129 | function _transfer(address sender, address recipient, uint256 amount) internal { 130 | require(sender != address(0), "ERC20: transfer from the zero address"); 131 | require(recipient != address(0), "ERC20: transfer to the zero address"); 132 | 133 | _balances[sender] = _balances[sender].sub(amount); 134 | _balances[recipient] = _balances[recipient].add(amount); 135 | emit Transfer(sender, recipient, amount); 136 | } 137 | 138 | function _approve(address owner, address spender, uint256 value) internal { 139 | require(owner != address(0), "ERC20: approve from the zero address"); 140 | require(spender != address(0), "ERC20: approve to the zero address"); 141 | _allowances[owner][spender] = value; 142 | emit Approval(owner, spender, value); 143 | } 144 | function () payable external{ 145 | revert(); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /contracts/3.sol: -------------------------------------------------------------------------------- 1 | /** 2 | * Source Code first verified at https://etherscan.io on Tuesday, May 7, 2019 3 | (UTC) */ 4 | 5 | pragma solidity ^0.5.1; 6 | 7 | contract CareerOnToken { 8 | event Transfer(address indexed _from, address indexed _to, uint256 _value); 9 | event Approval(address indexed a_owner, address indexed _spender, uint256 _value); 10 | event OwnerChang(address indexed _old,address indexed _new,uint256 _coin_change); 11 | 12 | uint256 public totalSupply; 13 | string public name; //名称,例如"My test token" 14 | uint8 public decimals; //返回token使用的小数点后几位。比如如果设置为3,就是支持0.001表示. 15 | string public symbol; //token简称,like MTT 16 | address public owner; 17 | 18 | mapping (address => uint256) internal balances; 19 | mapping (address => mapping (address => uint256)) internal allowed; 20 | 21 | //如果通过函数setPauseStatus设置这个变量为TRUE,则所有转账交易都会失败 22 | bool isTransPaused=false; 23 | 24 | constructor( 25 | uint256 _initialAmount, 26 | uint8 _decimalUnits) public 27 | { 28 | owner=msg.sender;//记录合约的owner 29 | if(_initialAmount<=0){ 30 | totalSupply = 100000000000000000; // 设置初始总量 31 | balances[owner]=totalSupply; 32 | }else{ 33 | totalSupply = _initialAmount; // 设置初始总量 34 | balances[owner]=_initialAmount; 35 | } 36 | if(_decimalUnits<=0){ 37 | decimals=2; 38 | }else{ 39 | decimals = _decimalUnits; 40 | } 41 | name = "CareerOn Chain Token"; 42 | symbol = "COT"; 43 | } 44 | 45 | 46 | function transfer( 47 | address _to, 48 | uint256 _value) public returns (bool success) 49 | { 50 | assert(_to!=address(this) && 51 | !isTransPaused && 52 | balances[msg.sender] >= _value && 53 | balances[_to] + _value > balances[_to] 54 | ); 55 | 56 | balances[msg.sender] -= _value;//从消息发送者账户中减去token数量_value 57 | balances[_to] += _value;//往接收账户增加token数量_value 58 | if(msg.sender==owner){ 59 | emit Transfer(address(this), _to, _value);//触发转币交易事件 60 | }else{ 61 | emit Transfer(msg.sender, _to, _value);//触发转币交易事件 62 | } 63 | return true; 64 | } 65 | 66 | 67 | function transferFrom( 68 | address _from, 69 | address _to, 70 | uint256 _value) public returns (bool success) 71 | { 72 | assert(_to!=address(this) && 73 | !isTransPaused && 74 | balances[msg.sender] >= _value && 75 | balances[_to] + _value > balances[_to] && 76 | allowed[_from][msg.sender] >= _value 77 | ); 78 | 79 | balances[_to] += _value;//接收账户增加token数量_value 80 | balances[_from] -= _value; //支出账户_from减去token数量_value 81 | allowed[_from][msg.sender] -= _value;//消息发送者可以从账户_from中转出的数量减少_value 82 | if(_from==owner){ 83 | emit Transfer(address(this), _to, _value);//触发转币交易事件 84 | }else{ 85 | emit Transfer(_from, _to, _value);//触发转币交易事件 86 | } 87 | return true; 88 | } 89 | 90 | function approve(address _spender, uint256 _value) public returns (bool success) 91 | { 92 | assert(msg.sender!=_spender && _value>0); 93 | allowed[msg.sender][_spender] = _value; 94 | emit Approval(msg.sender, _spender, _value); 95 | return true; 96 | } 97 | 98 | function allowance( 99 | address _owner, 100 | address _spender) public view returns (uint256 remaining) 101 | { 102 | return allowed[_owner][_spender];//允许_spender从_owner中转出的token数 103 | } 104 | 105 | function balanceOf(address accountAddr) public view returns (uint256) { 106 | return balances[accountAddr]; 107 | } 108 | 109 | //以下为本代币协议的特殊逻辑 110 | //转移协议所有权并将附带的代币一并转移过去 111 | function changeOwner(address newOwner) public{ 112 | assert(msg.sender==owner && msg.sender!=newOwner); 113 | balances[newOwner]=balances[owner]; 114 | balances[owner]=0; 115 | owner=newOwner; 116 | emit OwnerChang(msg.sender,newOwner,balances[owner]);//触发合约所有权的转移事件 117 | } 118 | 119 | //isPaused为true则暂停所有转账交易 120 | function setPauseStatus(bool isPaused)public{ 121 | assert(msg.sender==owner); 122 | isTransPaused=isPaused; 123 | } 124 | 125 | //修改合约名字 126 | function changeContractName(string memory _newName,string memory _newSymbol) public { 127 | assert(msg.sender==owner); 128 | name=_newName; 129 | symbol=_newSymbol; 130 | } 131 | 132 | 133 | function () external payable { 134 | revert(); 135 | } 136 | } -------------------------------------------------------------------------------- /contracts/32.sol: -------------------------------------------------------------------------------- 1 | /** 2 | * Source Code first verified at https://etherscan.io on Thursday, May 9, 2019 3 | (UTC) */ 4 | 5 | pragma solidity ^0.5.7; 6 | /** 7 | * ███████╗ ██████╗ ██████╗ █████╗ ███╗ ███╗ 8 | * ██╔════╝██╔════╝ ██╔══██╗██╔══██╗████╗ ████║ 9 | * █████╗ ██║ ███╗██████╔╝███████║██╔████╔██║ 10 | * ██╔══╝ ██║ ██║██╔══██╗██╔══██║██║╚██╔╝██║ 11 | * ███████╗╚██████╔╝██║ ██║██║ ██║██║ ╚═╝ ██║ 12 | * ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ 13 | */ 14 | 15 | /** 16 | * @title SafeMath 17 | * @dev Unsigned math operations with safety checks that revert on error. 18 | */ 19 | library SafeMath { 20 | 21 | /** 22 | * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). 23 | */ 24 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 25 | require(b <= a, "SafeMath: subtraction overflow"); 26 | uint256 c = a - b; 27 | 28 | return c; 29 | } 30 | 31 | /** 32 | * @dev Adds two unsigned integers, reverts on overflow. 33 | */ 34 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 35 | uint256 c = a + b; 36 | require(c >= a, "SafeMath: addition overflow"); 37 | 38 | return c; 39 | } 40 | 41 | } 42 | 43 | /** 44 | * Token contract interface for external use 45 | */ 46 | contract ERC20TokenInterface { 47 | 48 | function balanceOf(address _owner) public view returns (uint256 value); 49 | function transfer(address _to, uint256 _value) public returns (bool success); 50 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); 51 | function approve(address _spender, uint256 _value) public returns (bool success); 52 | function allowance(address _owner, address _spender) public view returns (uint256 remaining); 53 | 54 | } 55 | 56 | /** 57 | * @title Token definition 58 | * @dev Define token paramters including ERC20 ones 59 | */ 60 | contract ERC20Token is ERC20TokenInterface { 61 | using SafeMath for uint256; 62 | uint256 public totalSupply; 63 | mapping (address => uint256) balances; //A mapping of all balances per address 64 | mapping (address => mapping (address => uint256)) allowed; //A mapping of all allowances 65 | 66 | /** 67 | * @dev Get the balance of an specified address. 68 | * @param _owner The address to be query. 69 | */ 70 | function balanceOf(address _owner) public view returns (uint256 value) { 71 | return balances[_owner]; 72 | } 73 | 74 | /** 75 | * @dev transfer token to a specified address 76 | * @param _to The address to transfer to. 77 | * @param _value The amount to be transferred. 78 | */ 79 | function transfer(address _to, uint256 _value) public returns (bool success) { 80 | balances[msg.sender] = balances[msg.sender].sub(_value); 81 | balances[_to] = balances[_to].add(_value); 82 | emit Transfer(msg.sender, _to, _value); 83 | return true; 84 | } 85 | 86 | /** 87 | * @dev transfer token from an address to another specified address using allowance 88 | * @param _from The address where token comes. 89 | * @param _to The address to transfer to. 90 | * @param _value The amount to be transferred. 91 | */ 92 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { 93 | allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); 94 | balances[_from] = balances[_from].sub(_value); 95 | balances[_to] = balances[_to].add(_value); 96 | emit Transfer(_from, _to, _value); 97 | return true; 98 | } 99 | 100 | /** 101 | * @dev Assign allowance to an specified address to use the owner balance 102 | * @param _spender The address to be allowed to spend. 103 | * @param _value The amount to be allowed. 104 | */ 105 | function approve(address _spender, uint256 _value) public returns (bool success) { 106 | allowed[msg.sender][_spender] = _value; 107 | emit Approval(msg.sender, _spender, _value); 108 | return true; 109 | } 110 | 111 | /** 112 | * @dev Get the allowance of an specified address to use another address balance. 113 | * @param _owner The address of the owner of the tokens. 114 | * @param _spender The address of the allowed spender. 115 | */ 116 | function allowance(address _owner, address _spender) public view returns (uint256 remaining) { 117 | return allowed[_owner][_spender]; 118 | } 119 | 120 | /** 121 | * @dev Log Events 122 | */ 123 | event Transfer(address indexed _from, address indexed _to, uint256 _value); 124 | event Approval(address indexed _owner, address indexed _spender, uint256 _value); 125 | } 126 | 127 | /** 128 | * @title Asset 129 | * @dev Initial supply creation 130 | */ 131 | contract AsseteGram is ERC20Token { 132 | string public name = 'Electronic Gram'; 133 | uint8 public decimals = 3; 134 | string public symbol = 'eGram'; 135 | string public version = '2'; 136 | 137 | constructor() public { 138 | address initialOwner = 0xac775cD446889ac167da466692449ece5439fc12; 139 | totalSupply = 180000000 * (10**uint256(decimals)); //initial token creation 140 | balances[initialOwner] = totalSupply; 141 | emit Transfer(address(0), initialOwner, balances[initialOwner]); 142 | } 143 | 144 | /** 145 | *@dev Function to handle callback calls 146 | */ 147 | function() external { 148 | revert(); 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /contracts/33.sol: -------------------------------------------------------------------------------- 1 | /** 2 | *Submitted for verification at Etherscan.io on 2019-09-27 3 | */ 4 | 5 | pragma solidity >=0.5.11; 6 | 7 | contract Owned { 8 | address public owner; 9 | address public newOwner; 10 | 11 | event OwnershipTransferred(address indexed _from, address indexed _to); 12 | 13 | constructor() public { 14 | owner = msg.sender; 15 | } 16 | 17 | modifier onlyOwner { 18 | require(msg.sender == owner || msg.sender == address(this)); 19 | _; 20 | } 21 | 22 | function transferOwnership(address _newOwner) public onlyOwner { 23 | newOwner = _newOwner; 24 | } 25 | } 26 | 27 | library SafeMath { 28 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 29 | if (a == 0) { 30 | return 0; 31 | } 32 | uint256 c = a * b; 33 | assert(c / a == b); 34 | return c; 35 | } 36 | 37 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 38 | uint256 c = a / b; 39 | return c; 40 | } 41 | 42 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 43 | assert(b <= a); 44 | return a - b; 45 | } 46 | 47 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 48 | uint256 c = a + b; 49 | assert(c >= a); 50 | return c; 51 | } 52 | 53 | function ceil(uint256 a, uint256 m) internal pure returns (uint256) { 54 | uint256 c = add(a,m); 55 | uint256 d = sub(c,1); 56 | return mul(div(d,m),m); 57 | } 58 | } 59 | 60 | contract Token{ 61 | function balanceOf(address who) external view returns (uint256); 62 | function transferFrom(address from, address to, uint256 value) external returns (bool); 63 | function transfer(address to, uint256 value) external returns (bool); 64 | } 65 | 66 | contract Staking is Owned{ 67 | Token public token; 68 | bool lock; 69 | uint256 public minstakeTokens; 70 | uint256 private basePercent = 200; 71 | using SafeMath for uint256; 72 | uint256 public stakeTime = 1814400; // 3 weeks = 3*7*24*60*60 OR 1 week = 604800 secs, 3 weeks = 3*604800 = 1,814,400 73 | uint public stakePercentage = 30; 74 | event stakingstarted(address staker, uint256 tokens, uint256 time); 75 | event tokensRedeemed(address staker, uint256 stakedTokens, uint256 reward); 76 | 77 | struct stake{ 78 | uint256 time; 79 | bool redeem; 80 | uint256 tokens; 81 | } 82 | mapping(address => stake) staker; 83 | 84 | 85 | constructor(address tokenContractAddress) public{ 86 | token = Token(tokenContractAddress); 87 | owner = msg.sender; 88 | minstakeTokens = 500 * 10 ** uint(10); 89 | } 90 | 91 | function startStaking(uint256 stakeTokens) public{ 92 | require(stakeTokens >= minstakeTokens); 93 | require(token.balanceOf(msg.sender) >= stakeTokens + findOnePercent(stakeTokens)); 94 | require(token.transferFrom(msg.sender, address(this), stakeTokens + findOnePercent(stakeTokens))); 95 | staker[msg.sender].time = now; 96 | staker[msg.sender].tokens = staker[msg.sender].tokens + stakeTokens; 97 | emit stakingstarted(msg.sender, staker[msg.sender].tokens, staker[msg.sender].time); 98 | } 99 | 100 | function redeem() public{ 101 | require(!lock); 102 | require(!staker[msg.sender].redeem); 103 | require(staker[msg.sender].time + stakeTime <= now); 104 | require(token.transfer(msg.sender,staker[msg.sender].tokens)); 105 | require(token.transferFrom(owner, msg.sender ,staker[msg.sender].tokens * stakePercentage * 100 / 10000)); 106 | emit tokensRedeemed(msg.sender, staker[msg.sender].tokens, staker[msg.sender].tokens * stakePercentage * 100 / 10000); 107 | staker[msg.sender].redeem = true; 108 | staker[msg.sender].tokens = 0; 109 | } 110 | 111 | function changeStakeTokens(uint256 _NewTokensThreshold) public onlyOwner{ 112 | minstakeTokens = _NewTokensThreshold * 10 ** uint(10); 113 | } 114 | 115 | function changeStakeTime(uint256 _newStakeTime) public onlyOwner{ 116 | stakeTime = _newStakeTime; 117 | } 118 | 119 | function changeStakingPercentage(uint _newStakePercentage) public onlyOwner{ 120 | stakePercentage = _newStakePercentage; 121 | 122 | } 123 | 124 | function lockWithdrawals() public onlyOwner{ 125 | lock = true; 126 | } 127 | 128 | function findOnePercent(uint256 value) private view returns (uint256) { 129 | uint256 roundValue = value.ceil(basePercent); 130 | uint256 onePercent = roundValue.mul(basePercent).div(10000); 131 | return onePercent; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /contracts/39.sol: -------------------------------------------------------------------------------- 1 | /** 2 | *Submitted for verification at Etherscan.io on 2019-09-26 3 | */ 4 | 5 | pragma solidity ^0.5.10; 6 | 7 | contract TAMCContract { 8 | mapping (address => uint256) public balanceOf; 9 | 10 | string public name = "TAMC"; 11 | string public symbol = "TAMC"; 12 | uint8 public decimals = 18; 13 | uint256 public totalSupply = 1000000000 * (uint256(10) ** decimals); 14 | 15 | event Transfer(address indexed from, address indexed to, uint256 value); 16 | 17 | constructor() public { 18 | balanceOf[msg.sender] = totalSupply; 19 | emit Transfer(address(0), msg.sender, totalSupply); 20 | } 21 | 22 | function transfer(address to, uint256 value) public returns (bool success) { 23 | require(balanceOf[msg.sender] >= value); 24 | balanceOf[msg.sender] -= value; 25 | balanceOf[to] += value; 26 | emit Transfer(msg.sender, to, value); 27 | return true; 28 | } 29 | 30 | event Approval(address indexed owner, address indexed spender, uint256 value); 31 | 32 | mapping(address => mapping(address => uint256)) public allowance; 33 | 34 | function approve(address spender, uint256 value) 35 | public 36 | returns (bool success) 37 | { 38 | allowance[msg.sender][spender] = value; 39 | emit Approval(msg.sender, spender, value); 40 | return true; 41 | } 42 | 43 | function transferFrom(address from, address to, uint256 value) 44 | public 45 | returns (bool success) 46 | { 47 | require(value <= balanceOf[from]); 48 | require(value <= allowance[from][msg.sender]); 49 | 50 | balanceOf[from] -= value; 51 | balanceOf[to] += value; 52 | allowance[from][msg.sender] -= value; 53 | emit Transfer(from, to, value); 54 | return true; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /contracts/4.sol: -------------------------------------------------------------------------------- 1 | /** 2 | * Source Code first verified at https://etherscan.io on Tuesday, May 7, 2019 3 | (UTC) */ 4 | 5 | pragma solidity >= 0.5.0 < 0.6.0; 6 | 7 | 8 | /** 9 | * @title PHO token - for Game coin sale 10 | * @author Willy Lee 11 | */ 12 | 13 | 14 | /** 15 | * @title ERC20 Standard Interface 16 | */ 17 | interface IERC20 { 18 | function totalSupply() external view returns (uint256); 19 | function balanceOf(address who) external view returns (uint256); 20 | function transfer(address to, uint256 value) external returns (bool); 21 | event Transfer(address indexed from, address indexed to, uint256 value); 22 | } 23 | 24 | 25 | /** 26 | * @title Token implementation 27 | */ 28 | contract PHO is IERC20 { 29 | string public name = "PHO"; 30 | string public symbol = "PHO"; 31 | uint8 public decimals = 18; 32 | 33 | uint256 saleAmount; 34 | uint256 evtAmount; 35 | uint256 teamAmount; 36 | 37 | uint256 _totalSupply; 38 | mapping(address => uint256) balances; 39 | 40 | address public owner; 41 | address public sale; 42 | address public evt; 43 | address public team; 44 | 45 | modifier isOwner { 46 | require(owner == msg.sender); 47 | _; 48 | } 49 | 50 | constructor() public { 51 | owner = msg.sender; 52 | sale = 0x071F73f4D0befd4406901AACE6D5FFD6D297c561; 53 | evt = 0x76535ca5BF1d33434A302e5A464Df433BB1F80F6; 54 | team = 0xD7EC5D8697e4c83Dc33D781d19dc2910fB165D5C; 55 | 56 | saleAmount = toWei(1000000000); //1,000,000,000 57 | evtAmount = toWei(200000000); // 200,000,000 58 | teamAmount = toWei(800000000); // 800,000,000 59 | _totalSupply = toWei(2000000000); //2,000,000,000 60 | 61 | require(_totalSupply == saleAmount + evtAmount + teamAmount ); 62 | 63 | balances[owner] = _totalSupply; 64 | emit Transfer(address(0), owner, balances[owner]); 65 | 66 | transfer(sale, saleAmount); 67 | transfer(evt, evtAmount); 68 | transfer(team, teamAmount); 69 | require(balances[owner] == 0); 70 | } 71 | 72 | function totalSupply() public view returns (uint) { 73 | return _totalSupply; 74 | } 75 | 76 | function balanceOf(address who) public view returns (uint256) { 77 | return balances[who]; 78 | } 79 | 80 | function transfer(address to, uint256 value) public returns (bool success) { 81 | require(msg.sender != to); 82 | require(value > 0); 83 | 84 | require( balances[msg.sender] >= value ); 85 | require( balances[to] + value >= balances[to] ); 86 | 87 | if(msg.sender == team) { 88 | require(now >= 1589036400); // 800M lock to 2020-05-10 89 | if(balances[msg.sender] - value < toWei(600000000)) 90 | require(now >= 1620572400); // 10M lock to 2021-05-10 91 | if(balances[msg.sender] - value < toWei(400000000)) 92 | require(now >= 1652108400); // 10M lock to 2022-05-10 93 | if(balances[msg.sender] - value < toWei(200000000)) 94 | require(now >= 1683644400); // 10M lock to 2023-05-10 95 | } 96 | 97 | balances[msg.sender] -= value; 98 | balances[to] += value; 99 | 100 | emit Transfer(msg.sender, to, value); 101 | return true; 102 | } 103 | 104 | function burnCoins(uint256 value) public { 105 | require(balances[msg.sender] >= value); 106 | require(_totalSupply >= value); 107 | 108 | balances[msg.sender] -= value; 109 | _totalSupply -= value; 110 | 111 | emit Transfer(msg.sender, address(0), value); 112 | } 113 | 114 | 115 | /** @dev private function 116 | */ 117 | 118 | function toWei(uint256 value) private view returns (uint256) { 119 | return value * (10 ** uint256(decimals)); 120 | } 121 | } -------------------------------------------------------------------------------- /contracts/42.sol: -------------------------------------------------------------------------------- 1 | /** 2 | *Submitted for verification at Etherscan.io on 2019-09-24 3 | */ 4 | 5 | pragma solidity ^0.5.11; 6 | 7 | contract Owned { 8 | address public owner; 9 | address public newOwner; 10 | 11 | event OwnershipTransferred(address indexed _from, address indexed _to); 12 | 13 | constructor() public { 14 | owner = msg.sender; 15 | } 16 | 17 | modifier onlyOwner { 18 | require(msg.sender == owner || msg.sender == address(this)); 19 | _; 20 | } 21 | 22 | function transferOwnership(address _newOwner) public onlyOwner { 23 | newOwner = _newOwner; 24 | } 25 | } 26 | 27 | library SafeMath { 28 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 29 | if (a == 0) { 30 | return 0; 31 | } 32 | uint256 c = a * b; 33 | assert(c / a == b); 34 | return c; 35 | } 36 | 37 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 38 | uint256 c = a / b; 39 | return c; 40 | } 41 | 42 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 43 | assert(b <= a); 44 | return a - b; 45 | } 46 | 47 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 48 | uint256 c = a + b; 49 | assert(c >= a); 50 | return c; 51 | } 52 | 53 | function ceil(uint256 a, uint256 m) internal pure returns (uint256) { 54 | uint256 c = add(a,m); 55 | uint256 d = sub(c,1); 56 | return mul(div(d,m),m); 57 | } 58 | } 59 | 60 | contract Token{ 61 | function balanceOf(address who) external view returns (uint256); 62 | function transferFrom(address from, address to, uint256 value) external returns (bool); 63 | function transfer(address to, uint256 value) external returns (bool); 64 | } 65 | 66 | contract Staking is Owned{ 67 | Token public token; 68 | bool lock; 69 | uint256 public stakeTokens; 70 | uint256 private basePercent = 200; 71 | using SafeMath for uint256; 72 | uint256 public stakeTime = 1814400; // 3 weeks = 3*7*24*60*60 OR 1 week = 604800 secs, 3 weeks = 3*604800 = 1,814,400 73 | uint public stakePercentage = 30; 74 | event stakingstarted(address staker, uint256 tokens, uint256 time); 75 | event tokensRedeemed(address staker, uint256 stakedTokens, uint256 reward); 76 | 77 | struct stake{ 78 | uint256 time; 79 | bool redeem; 80 | uint256 tokens; 81 | } 82 | mapping(address => stake) staker; 83 | 84 | 85 | constructor(address tokenContractAddress) public{ 86 | token = Token(tokenContractAddress); 87 | owner = msg.sender; 88 | stakeTokens = 500 * 10 ** uint(10); 89 | } 90 | 91 | function startStaking() public{ 92 | require(token.balanceOf(msg.sender) >= stakeTokens + findOnePercent(stakeTokens)); 93 | require(token.transferFrom(msg.sender, address(this), stakeTokens + findOnePercent(stakeTokens))); 94 | staker[msg.sender].time = now; 95 | staker[msg.sender].tokens = staker[msg.sender].tokens + stakeTokens; 96 | emit stakingstarted(msg.sender, staker[msg.sender].tokens, staker[msg.sender].time); 97 | } 98 | 99 | function redeem() public{ 100 | require(!lock); 101 | require(!staker[msg.sender].redeem); 102 | require(staker[msg.sender].time + stakeTime <= now); 103 | require(token.transfer(msg.sender,staker[msg.sender].tokens)); 104 | require(token.transferFrom(owner, msg.sender ,staker[msg.sender].tokens * stakePercentage * 100 / 10000)); 105 | emit tokensRedeemed(msg.sender, staker[msg.sender].tokens, staker[msg.sender].tokens * stakePercentage * 100 / 10000); 106 | staker[msg.sender].redeem = true; 107 | staker[msg.sender].tokens = 0; 108 | } 109 | 110 | function changeStakeTokens(uint256 _NewTokensThreshold) public onlyOwner{ 111 | stakeTokens = _NewTokensThreshold * 10 ** uint(10); 112 | } 113 | 114 | function changeStakeTime(uint256 _newStakeTime) public onlyOwner{ 115 | stakeTime = _newStakeTime; 116 | } 117 | 118 | function changeStakingPercentage(uint _newStakePercentage) public onlyOwner{ 119 | stakePercentage = _newStakePercentage; 120 | 121 | } 122 | 123 | function lockWithdrawals() public onlyOwner{ 124 | lock = true; 125 | } 126 | 127 | function findOnePercent(uint256 value) private view returns (uint256) { 128 | uint256 roundValue = value.ceil(basePercent); 129 | uint256 onePercent = roundValue.mul(basePercent).div(10000); 130 | return onePercent; 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /contracts/45.sol: -------------------------------------------------------------------------------- 1 | /** 2 | *Submitted for verification at Etherscan.io on 2019-09-24 3 | */ 4 | 5 | pragma solidity ^0.5.11; 6 | 7 | contract StockBet { 8 | 9 | event GameCreated(uint bet); 10 | event GameOpened(uint256 initialPrice); 11 | event GameClosed(); 12 | event OracleSet(address oracle); 13 | event FinalPriceSet(uint256 finalPrice); 14 | event PlayerBet(address player, uint guess); 15 | 16 | event PlayersWin(uint result, uint256 splitJackpot); 17 | event OwnerWins(address owner); 18 | 19 | enum State { 20 | SETUP, PRICE_SET, OPEN, CLOSED, PLAYERS_WIN, OWNER_WIN 21 | } 22 | 23 | enum PaidStatus { 24 | UNDEFINED, 25 | NOT_PAID, 26 | PAID 27 | } 28 | 29 | struct Guess { 30 | mapping (address => PaidStatus) players; 31 | uint guesses_number; 32 | } 33 | 34 | address payable public owner; 35 | address public oracle; 36 | State public state; 37 | 38 | mapping (uint => Guess) public guesses; 39 | 40 | uint256 public bet; 41 | uint256 splitJackpot; 42 | uint public result; 43 | uint256 public initialPrice; 44 | uint256 public finalPrice; 45 | 46 | uint constant UP = 1; 47 | uint constant DOWN = 0; 48 | 49 | 50 | // ----------MODIFIERS-------------------- 51 | modifier byPlayer(){ 52 | require(msg.sender != oracle); 53 | _; 54 | } 55 | 56 | modifier byOwner(){ 57 | require(msg.sender == owner); 58 | _; 59 | } 60 | 61 | modifier byOracle(){ 62 | require(msg.sender == oracle); 63 | _; 64 | } 65 | 66 | modifier inState(State expected) { 67 | require(state == expected); 68 | _; 69 | } 70 | // ------------------------------------- 71 | 72 | 73 | constructor(uint256 _bet) public { 74 | require(_bet > 0); 75 | 76 | owner = msg.sender; 77 | state = State.SETUP; 78 | bet = _bet; 79 | 80 | emit GameCreated(bet); 81 | } 82 | 83 | function setOracle(address _oracle) public payable byOwner inState(State.SETUP) { 84 | oracle = _oracle; 85 | 86 | emit OracleSet(oracle); 87 | } 88 | 89 | function setInitialPrice(uint256 _value) public payable byOracle inState(State.SETUP) { 90 | initialPrice = _value; 91 | state = State.OPEN; 92 | 93 | emit GameOpened(initialPrice); 94 | } 95 | 96 | function closeGame() public byOwner inState(State.OPEN){ 97 | state = State.CLOSED; 98 | 99 | emit GameClosed(); 100 | } 101 | 102 | function betUp() public payable byPlayer inState(State.OPEN){ 103 | require(msg.value == (bet*0.001 ether)); 104 | 105 | guesses[UP].guesses_number++; 106 | guesses[UP].players[msg.sender] = PaidStatus.NOT_PAID; 107 | 108 | emit PlayerBet(msg.sender, UP); 109 | } 110 | 111 | function betDown() public payable byPlayer inState(State.OPEN){ 112 | require(msg.value == (bet*0.001 ether)); 113 | 114 | guesses[DOWN].guesses_number++; 115 | guesses[DOWN].players[msg.sender] = PaidStatus.NOT_PAID; 116 | 117 | emit PlayerBet(msg.sender, DOWN); 118 | } 119 | 120 | 121 | function setFinalPrice(uint256 _value) public payable byOracle inState(State.CLOSED) { 122 | // require(isValidNumber(_result)); 123 | 124 | finalPrice = _value; 125 | 126 | emit FinalPriceSet(finalPrice); 127 | 128 | if(finalPrice > initialPrice){ 129 | result = UP; 130 | }else{ 131 | result = DOWN; 132 | } 133 | 134 | 135 | if(guesses[result].guesses_number > 0){ 136 | state = State.PLAYERS_WIN; 137 | splitJackpot = getBalance()/guesses[result].guesses_number; 138 | emit PlayersWin(result, splitJackpot); 139 | }else{ 140 | state = State.OWNER_WIN; 141 | emit OwnerWins(owner); 142 | } 143 | } 144 | 145 | function collectOwnerWinnings() public byOwner inState(State.OWNER_WIN){ 146 | selfdestruct(owner); 147 | } 148 | 149 | function collectPlayerWinnings() public byPlayer inState(State.PLAYERS_WIN){ 150 | if(guesses[result].players[msg.sender] == PaidStatus.NOT_PAID){ 151 | guesses[result].players[msg.sender] = PaidStatus.PAID; 152 | msg.sender.transfer(splitJackpot); 153 | } else revert(); 154 | } 155 | 156 | function getBalance() private view returns (uint256){ 157 | return address(this).balance; 158 | } 159 | 160 | } 161 | -------------------------------------------------------------------------------- /contracts/46.sol: -------------------------------------------------------------------------------- 1 | /** 2 | *Submitted for verification at Etherscan.io on 2019-09-24 3 | */ 4 | 5 | pragma solidity >=0.4.21 <0.6.0; 6 | 7 | contract ProofOfExistence { 8 | 9 | enum BlockchainIdentification {Ixxo,Ethereum,Gochain} 10 | 11 | struct FileExistenceStruct { 12 | uint256 date; 13 | address filesender; 14 | string fileHash; 15 | string filePathHash; 16 | address contractAddress; 17 | bytes32 QRCodeHash; 18 | BlockchainIdentification identifier; 19 | } 20 | 21 | mapping(address => FileExistenceStruct[]) fileExistenceProofs; 22 | 23 | 24 | /** 25 | *@dev function to set the Proof of existence for a file 26 | */ 27 | function SetFileExistenceProof(address dappBoxOrigin, string memory _fileHash, string memory _filePathHash, address _contractAddress ,BlockchainIdentification _identifier) public returns (bytes32) 28 | { 29 | FileExistenceStruct memory newInfo; 30 | uint256 _date = now; 31 | bytes32 QRCodeHash = generateQRCodeForFile(dappBoxOrigin,_fileHash,_filePathHash,_contractAddress ,_identifier); 32 | newInfo.date = _date; 33 | newInfo.filesender = dappBoxOrigin; 34 | newInfo.fileHash = _fileHash; 35 | newInfo.filePathHash = _filePathHash; 36 | newInfo.contractAddress = _contractAddress; 37 | newInfo.identifier = _identifier; 38 | newInfo.QRCodeHash = QRCodeHash; 39 | 40 | fileExistenceProofs[dappBoxOrigin].push(newInfo); 41 | return QRCodeHash; 42 | } 43 | 44 | 45 | /** 46 | *@dev function to get the Proof of existence for a file 47 | */ 48 | function GetFileExistenceProof(address dappBoxOrigin,string memory fileHash, string memory filePathHash) public view returns(uint256,address,address,BlockchainIdentification,bytes32) { 49 | 50 | for(uint i = 0 ; i < fileExistenceProofs[dappBoxOrigin].length ; i++) 51 | { 52 | 53 | bool res = compareStrings(fileHash,fileExistenceProofs[dappBoxOrigin][i].fileHash) && 54 | compareStrings(filePathHash,fileExistenceProofs[dappBoxOrigin][i].filePathHash); 55 | if(res == true ) 56 | { 57 | return( fileExistenceProofs[dappBoxOrigin][i].date, 58 | fileExistenceProofs[dappBoxOrigin][i].filesender, 59 | fileExistenceProofs[dappBoxOrigin][i].contractAddress, 60 | fileExistenceProofs[dappBoxOrigin][i].identifier, 61 | fileExistenceProofs[dappBoxOrigin][i].QRCodeHash); 62 | } 63 | } 64 | } 65 | 66 | 67 | /** 68 | *@dev function to compare strings 69 | */ 70 | function compareStrings(string memory a, string memory b) internal pure returns (bool) 71 | { 72 | if(bytes(a).length != bytes(b).length) { 73 | return false; 74 | } else { 75 | return keccak256(abi.encode(a)) == keccak256(abi.encode(b)); 76 | } 77 | } 78 | 79 | /** 80 | *@dev function to generate QR code string 81 | */ 82 | function generateQRCodeForFile(address dappBoxOrigin, string memory _fileHash, string memory filePath, address _contractAddress ,BlockchainIdentification _identifier ) internal pure returns (bytes32) 83 | { 84 | bytes32 QRCodeHash; 85 | QRCodeHash = keccak256(abi.encodePacked(dappBoxOrigin, _fileHash,filePath,_contractAddress,_identifier)); 86 | return QRCodeHash; 87 | } 88 | 89 | 90 | /** 91 | *@dev function to retreive QR code in string format 92 | */ 93 | 94 | function getQRCode(address dappBoxOrigin, string memory fileHash, string memory filePathHash ) public view returns(bytes32) { 95 | uint256 len = fileExistenceProofs[dappBoxOrigin].length; 96 | for(uint i = 0 ; i < len ; i++) 97 | { 98 | 99 | bool res = compareStrings(fileHash,fileExistenceProofs[dappBoxOrigin][i].fileHash) && 100 | compareStrings(filePathHash,fileExistenceProofs[dappBoxOrigin][i].filePathHash); 101 | if(res == true ) 102 | { 103 | return fileExistenceProofs[dappBoxOrigin][i].QRCodeHash; 104 | } 105 | 106 | } 107 | } 108 | 109 | 110 | /** 111 | *@dev function to get proof of existence using QR code 112 | */ 113 | function searchExistenceProoUsngQRf(address dappBoxOrigin,bytes32 QRCodeHash) public view returns(uint256,address,address,BlockchainIdentification,bytes32) { 114 | uint256 len = fileExistenceProofs[dappBoxOrigin].length; 115 | for(uint i = 0 ; i < len ; i++) 116 | { 117 | if(QRCodeHash == fileExistenceProofs[dappBoxOrigin][i].QRCodeHash) 118 | { 119 | return( fileExistenceProofs[dappBoxOrigin][i].date, 120 | fileExistenceProofs[dappBoxOrigin][i].filesender, 121 | fileExistenceProofs[dappBoxOrigin][i].contractAddress, 122 | fileExistenceProofs[dappBoxOrigin][i].identifier, 123 | fileExistenceProofs[dappBoxOrigin][i].QRCodeHash); 124 | } 125 | } 126 | } 127 | 128 | 129 | } 130 | -------------------------------------------------------------------------------- /contracts/49.sol: -------------------------------------------------------------------------------- 1 | /** 2 | *Submitted for verification at Etherscan.io on 2019-09-23 3 | */ 4 | 5 | pragma solidity ^0.5.11; 6 | 7 | contract TAMC { 8 | mapping (address => uint256) public balanceOf; 9 | 10 | string public name = "TAMC"; 11 | string public symbol = "TAMC"; 12 | uint8 public decimals = 18; 13 | uint256 public totalSupply = 1000000000 * (uint256(10) ** decimals); 14 | 15 | event Transfer(address indexed from, address indexed to, uint256 value); 16 | 17 | constructor() public { 18 | balanceOf[msg.sender] = totalSupply; 19 | emit Transfer(address(0), msg.sender, totalSupply); 20 | } 21 | 22 | function transfer(address to, uint256 value) public returns (bool success) { 23 | require(balanceOf[msg.sender] >= value); 24 | balanceOf[msg.sender] -= value; 25 | balanceOf[to] += value; 26 | emit Transfer(msg.sender, to, value); 27 | return true; 28 | } 29 | 30 | event Approval(address indexed owner, address indexed spender, uint256 value); 31 | 32 | mapping(address => mapping(address => uint256)) public allowance; 33 | 34 | function approve(address spender, uint256 value) 35 | public 36 | returns (bool success) 37 | { 38 | allowance[msg.sender][spender] = value; 39 | emit Approval(msg.sender, spender, value); 40 | return true; 41 | } 42 | 43 | function transferFrom(address from, address to, uint256 value) 44 | public 45 | returns (bool success) 46 | { 47 | require(value <= balanceOf[from]); 48 | require(value <= allowance[from][msg.sender]); 49 | 50 | balanceOf[from] -= value; 51 | balanceOf[to] += value; 52 | allowance[from][msg.sender] -= value; 53 | emit Transfer(from, to, value); 54 | return true; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /contracts/50.sol: -------------------------------------------------------------------------------- 1 | /** 2 | *Submitted for verification at Etherscan.io on 2019-09-23 3 | */ 4 | 5 | pragma solidity ^0.5.11; 6 | 7 | contract digitalNotary 8 | { 9 | 10 | address payable private manager; 11 | 12 | bool private contractactive; 13 | 14 | uint private hashfee; 15 | 16 | uint private changehashownerfee; 17 | 18 | struct HashRegistration 19 | { 20 | address owner; 21 | uint registrationtime; 22 | } 23 | 24 | mapping(bytes32 => HashRegistration[]) HashList; 25 | 26 | uint private HashListLength; 27 | 28 | event RegisterHashEvent(address indexed msgsender, bytes32 indexed hash, uint timestamp); 29 | 30 | event ChangeHashOwnershipEvent(address indexed msgsender, address indexed newowner, bytes32 indexed hash, uint timestamp); 31 | 32 | constructor() public 33 | { 34 | 35 | manager = msg.sender; 36 | 37 | contractactive = true; 38 | 39 | hashfee = 5000000000000000; 40 | 41 | changehashownerfee = 25000000000000000; 42 | 43 | HashListLength = 0; 44 | 45 | } 46 | 47 | modifier onlyManager() 48 | { 49 | require(msg.sender == manager); 50 | _; 51 | } 52 | 53 | 54 | function gethashfee() external view returns(uint) 55 | { 56 | return hashfee; 57 | } 58 | 59 | function sethashfee(uint newfee) external onlyManager 60 | { 61 | require(newfee >= 0); 62 | 63 | hashfee = newfee; 64 | } 65 | 66 | function getchangehashownerfee() external view returns(uint) 67 | { 68 | return changehashownerfee; 69 | } 70 | 71 | function setchangehashownerfee(uint newfee) external onlyManager 72 | { 73 | require(newfee >= 0); 74 | 75 | changehashownerfee = newfee; 76 | } 77 | 78 | function getcontractactive() external view returns (bool) 79 | { 80 | return contractactive; 81 | } 82 | 83 | function setcontractactive(bool contactive) external onlyManager 84 | { 85 | contractactive = contactive; 86 | } 87 | 88 | function getmanager() external view returns(address) 89 | { 90 | return manager; 91 | } 92 | 93 | function setmanager(address payable newmngr) external onlyManager 94 | { 95 | require(newmngr.balance > 0); 96 | manager = newmngr; 97 | } 98 | 99 | function getcontractbalance() public view returns(uint) 100 | { 101 | 102 | return address(this).balance; 103 | } 104 | 105 | function transfercontractbalance() external onlyManager 106 | { 107 | uint cb = address(this).balance; 108 | 109 | require(cb > 0); 110 | 111 | manager.transfer(cb); 112 | } 113 | 114 | function getHashOwnersCount(bytes32 hash) public view returns(uint) 115 | { 116 | return HashList[hash].length; 117 | } 118 | 119 | function getNumberofHashesRegistered() external view returns(uint) 120 | { 121 | return HashListLength; 122 | } 123 | 124 | function getHashDetails(bytes32 hash,uint indx) external view returns (address,uint) 125 | { 126 | 127 | uint owncount = getHashOwnersCount(hash); 128 | require(owncount > 0); 129 | require(indx < owncount); 130 | 131 | return (HashList[hash][indx].owner,HashList[hash][indx].registrationtime); 132 | } 133 | 134 | function registerHash(bytes32 hash) external payable 135 | { 136 | 137 | require(contractactive == true); 138 | require(getHashOwnersCount(hash) == 0); 139 | require(msg.value == hashfee); 140 | 141 | HashRegistration memory thisregistration; 142 | thisregistration.owner = msg.sender; 143 | thisregistration.registrationtime = now; 144 | 145 | HashList[hash].push(thisregistration); 146 | 147 | HashListLength++; 148 | 149 | emit RegisterHashEvent(thisregistration.owner, hash, thisregistration.registrationtime); 150 | 151 | } 152 | 153 | function changeHashOwnership(bytes32 hash, address newowner) external payable 154 | { 155 | 156 | require(contractactive == true); 157 | uint owncount = getHashOwnersCount(hash); 158 | require(owncount > 0); 159 | require(msg.sender == HashList[hash][owncount - 1].owner); 160 | require(msg.value == changehashownerfee); 161 | 162 | HashRegistration memory thisregistration; 163 | thisregistration.owner = newowner; 164 | thisregistration.registrationtime = now; 165 | 166 | HashList[hash].push(thisregistration); 167 | 168 | emit ChangeHashOwnershipEvent(msg.sender, thisregistration.owner, hash, thisregistration.registrationtime); 169 | } 170 | 171 | function () external 172 | { 173 | 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /contracts/6.sol: -------------------------------------------------------------------------------- 1 | /** 2 | * Source Code first verified at https://etherscan.io on Tuesday, May 7, 2019 3 | (UTC) */ 4 | 5 | pragma solidity ^0.5.8; 6 | 7 | contract Ownable 8 | { 9 | bool private stopped; 10 | address private _owner; 11 | address private _master; 12 | 13 | event Stopped(); 14 | event Started(); 15 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 16 | event MasterRoleTransferred(address indexed previousMaster, address indexed newMaster); 17 | 18 | constructor () internal 19 | { 20 | stopped = false; 21 | _owner = msg.sender; 22 | _master = msg.sender; 23 | emit OwnershipTransferred(address(0), _owner); 24 | emit MasterRoleTransferred(address(0), _master); 25 | } 26 | 27 | function owner() public view returns (address) 28 | { 29 | return _owner; 30 | } 31 | 32 | function master() public view returns (address) 33 | { 34 | return _master; 35 | } 36 | 37 | modifier onlyOwner() 38 | { 39 | require(isOwner()); 40 | _; 41 | } 42 | 43 | modifier onlyMaster() 44 | { 45 | require(isMaster() || isOwner()); 46 | _; 47 | } 48 | 49 | modifier onlyWhenNotStopped() 50 | { 51 | require(!isStopped()); 52 | _; 53 | } 54 | 55 | function isOwner() public view returns (bool) 56 | { 57 | return msg.sender == _owner; 58 | } 59 | 60 | function isMaster() public view returns (bool) 61 | { 62 | return msg.sender == _master; 63 | } 64 | 65 | function transferOwnership(address newOwner) external onlyOwner 66 | { 67 | _transferOwnership(newOwner); 68 | } 69 | 70 | function transferMasterRole(address newMaster) external onlyOwner 71 | { 72 | _transferMasterRole(newMaster); 73 | } 74 | 75 | function isStopped() public view returns (bool) 76 | { 77 | return stopped; 78 | } 79 | 80 | function stop() public onlyOwner 81 | { 82 | _stop(); 83 | } 84 | 85 | function start() public onlyOwner 86 | { 87 | _start(); 88 | } 89 | 90 | function _transferOwnership(address newOwner) internal 91 | { 92 | require(newOwner != address(0)); 93 | emit OwnershipTransferred(_owner, newOwner); 94 | _owner = newOwner; 95 | } 96 | 97 | function _transferMasterRole(address newMaster) internal 98 | { 99 | require(newMaster != address(0)); 100 | emit MasterRoleTransferred(_master, newMaster); 101 | _master = newMaster; 102 | } 103 | 104 | function _stop() internal 105 | { 106 | emit Stopped(); 107 | stopped = true; 108 | } 109 | 110 | function _start() internal 111 | { 112 | emit Started(); 113 | stopped = false; 114 | } 115 | } 116 | 117 | contract ChannelWallet is Ownable 118 | { 119 | mapping(string => address) private addressMap; 120 | 121 | event SetAddress(string channelId, address _address); 122 | event UpdateAddress(string from, string to); 123 | event DeleteAddress(string account); 124 | 125 | function version() external pure returns(string memory) 126 | { 127 | return '0.0.1'; 128 | } 129 | 130 | function getAddress(string calldata channelId) external view returns (address) 131 | { 132 | return addressMap[channelId]; 133 | } 134 | 135 | function setAddress(string calldata channelId, address _address) external onlyMaster onlyWhenNotStopped 136 | { 137 | require(bytes(channelId).length > 0); 138 | 139 | addressMap[channelId] = _address; 140 | 141 | emit SetAddress(channelId, _address); 142 | } 143 | 144 | function updateChannel(string calldata from, string calldata to, address _address) external onlyMaster onlyWhenNotStopped 145 | { 146 | require(bytes(from).length > 0); 147 | require(bytes(to).length > 0); 148 | require(addressMap[to] == address(0)); 149 | 150 | addressMap[to] = _address; 151 | 152 | addressMap[from] = address(0); 153 | 154 | emit UpdateAddress(from, to); 155 | } 156 | 157 | function deleteChannel(string calldata channelId) external onlyMaster onlyWhenNotStopped 158 | { 159 | require(bytes(channelId).length > 0); 160 | 161 | addressMap[channelId] = address(0); 162 | 163 | emit DeleteAddress(channelId); 164 | } 165 | } -------------------------------------------------------------------------------- /contracts/7.sol: -------------------------------------------------------------------------------- 1 | /** 2 | * Source Code first verified at https://etherscan.io on Tuesday, May 7, 2019 3 | (UTC) */ 4 | 5 | pragma solidity ^0.5.8; 6 | 7 | contract Ownable 8 | { 9 | bool private stopped; 10 | address private _owner; 11 | address private _master; 12 | 13 | event Stopped(); 14 | event Started(); 15 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 16 | event MasterRoleTransferred(address indexed previousMaster, address indexed newMaster); 17 | 18 | constructor () internal 19 | { 20 | stopped = false; 21 | _owner = msg.sender; 22 | _master = msg.sender; 23 | emit OwnershipTransferred(address(0), _owner); 24 | emit MasterRoleTransferred(address(0), _master); 25 | } 26 | 27 | function owner() public view returns (address) 28 | { 29 | return _owner; 30 | } 31 | 32 | function master() public view returns (address) 33 | { 34 | return _master; 35 | } 36 | 37 | modifier onlyOwner() 38 | { 39 | require(isOwner()); 40 | _; 41 | } 42 | 43 | modifier onlyMaster() 44 | { 45 | require(isMaster() || isOwner()); 46 | _; 47 | } 48 | 49 | modifier onlyWhenNotStopped() 50 | { 51 | require(!isStopped()); 52 | _; 53 | } 54 | 55 | function isOwner() public view returns (bool) 56 | { 57 | return msg.sender == _owner; 58 | } 59 | 60 | function isMaster() public view returns (bool) 61 | { 62 | return msg.sender == _master; 63 | } 64 | 65 | function transferOwnership(address newOwner) external onlyOwner 66 | { 67 | _transferOwnership(newOwner); 68 | } 69 | 70 | function transferMasterRole(address newMaster) external onlyOwner 71 | { 72 | _transferMasterRole(newMaster); 73 | } 74 | 75 | function isStopped() public view returns (bool) 76 | { 77 | return stopped; 78 | } 79 | 80 | function stop() public onlyOwner 81 | { 82 | _stop(); 83 | } 84 | 85 | function start() public onlyOwner 86 | { 87 | _start(); 88 | } 89 | 90 | function _transferOwnership(address newOwner) internal 91 | { 92 | require(newOwner != address(0)); 93 | emit OwnershipTransferred(_owner, newOwner); 94 | _owner = newOwner; 95 | } 96 | 97 | function _transferMasterRole(address newMaster) internal 98 | { 99 | require(newMaster != address(0)); 100 | emit MasterRoleTransferred(_master, newMaster); 101 | _master = newMaster; 102 | } 103 | 104 | function _stop() internal 105 | { 106 | emit Stopped(); 107 | stopped = true; 108 | } 109 | 110 | function _start() internal 111 | { 112 | emit Started(); 113 | stopped = false; 114 | } 115 | } 116 | 117 | contract AccountWallet is Ownable 118 | { 119 | mapping(string => string) private btc; 120 | mapping(string => address) private eth; 121 | 122 | event SetAddress(string account, string btcAddress, address ethAddress); 123 | event UpdateAddress(string from, string to); 124 | event DeleteAddress(string account); 125 | 126 | function version() external pure returns(string memory) 127 | { 128 | return '1.0.0'; 129 | } 130 | 131 | function getAddress(string calldata account) external view returns (string memory, address) 132 | { 133 | return (btc[account], eth[account]); 134 | } 135 | 136 | function setAddress(string calldata account, string calldata btcAddress, address ethAddress) external onlyMaster onlyWhenNotStopped 137 | { 138 | require(bytes(account).length > 0); 139 | 140 | btc[account] = btcAddress; 141 | eth[account] = ethAddress; 142 | 143 | emit SetAddress(account, btcAddress, ethAddress); 144 | } 145 | 146 | function updateAccount(string calldata from, string calldata to) external onlyMaster onlyWhenNotStopped 147 | { 148 | require(bytes(from).length > 0); 149 | require(bytes(to).length > 0); 150 | 151 | btc[to] = btc[from]; 152 | eth[to] = eth[from]; 153 | 154 | btc[from] = ''; 155 | eth[from] = address(0); 156 | 157 | emit UpdateAddress(from, to); 158 | } 159 | 160 | function deleteAccount(string calldata account) external onlyMaster onlyWhenNotStopped 161 | { 162 | require(bytes(account).length > 0); 163 | 164 | btc[account] = ''; 165 | eth[account] = address(0); 166 | 167 | emit DeleteAddress(account); 168 | } 169 | } -------------------------------------------------------------------------------- /inject_file.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import sys 4 | def update(filename, offset, text): 5 | fro = open(filename, "rb") 6 | frw = open(filename, "r+b") 7 | fro.seek(offset-2, 0) 8 | frw.seek(offset-2, 0) 9 | fStr = fro.read() 10 | fro.close() 11 | 12 | frw.write(text) 13 | frw.write(fStr[:]) 14 | 15 | frw.truncate() 16 | frw.close() 17 | 18 | def preprocess_json_file(filename): 19 | import re 20 | fh = open(filename, 'r+b' ) 21 | data = fh.read() 22 | 23 | for item in re.finditer(b'{' , data ) : 24 | start = item.start() 25 | break 26 | for item in re.finditer(b'}' , data ) : 27 | end= item.end() 28 | 29 | fh.seek(0) 30 | fh.write(data[start:end]) 31 | fh.truncate() 32 | fh.close() 33 | 34 | def get_pattern_offset(filename, pattern): 35 | import re 36 | locs = [] 37 | p1=pattern.replace('(', '\(') 38 | p2=p1.replace(')', '\)') 39 | p3=p2.replace('.', '\.') 40 | p4=p3.replace('[', '\[') 41 | p5=p4.replace(']', '\]') 42 | p6=p5.replace('+', '\+') 43 | p7=p6.replace('*', '\*') 44 | p8=p7.replace('|', '\|') 45 | pat = re.compile( p8.encode(), re.MULTILINE ) 46 | fh = open(filename, 'rb' ) 47 | data = fh.read() 48 | for item in re.finditer(pat, data) : 49 | locs.append(item.start()) 50 | locs.append(item.end()) 51 | 52 | if len(locs)==2: 53 | current_line = 0 54 | fh.seek(0) 55 | while fh.tell() < locs[1]: 56 | fh.readline() 57 | current_line += 1 58 | fh.close() 59 | locs.append(current_line) 60 | 61 | return locs 62 | else: 63 | fh.close() 64 | return None 65 | 66 | def get_pattern_all_offsets(filename, pattern): 67 | import re 68 | locs = [] 69 | 70 | pat = re.compile( pattern.encode(), re.MULTILINE ) 71 | fh = open(filename, 'rb' ) 72 | data = fh.read() 73 | for item in re.finditer(pat, data) : 74 | current_line = 0 75 | fh.seek(0) 76 | while fh.tell() <= item.start(): 77 | fh.readline() 78 | current_line += 1 79 | locs.append({"soffset":item.start(), "eoffset":item.end(), "line":current_line}) 80 | 81 | fh.close() 82 | return locs 83 | 84 | def get_snippet_at_offset(filename, offset, length): 85 | fr = open(filename, "rb") 86 | fr.seek(offset,0) 87 | snippet = fr.read(length) 88 | fr.close() 89 | return snippet.decode() 90 | 91 | def get_line_at_offset(filename, offset): 92 | current_line = 0 93 | fh = open(filename, "r", encoding="utf-8", errors="ignore") 94 | fh.seek(0) 95 | while fh.tell() <= offset: 96 | fh.readline() 97 | current_line += 1 98 | fh.close() 99 | return current_line 100 | 101 | def get_lines_between_offsets(filename, soffset,eoffset): 102 | current_line = 0 103 | lines = [] 104 | fh = open(filename, "r") 105 | fh.seek(0) 106 | while fh.tell() < soffset: 107 | fh.readline() 108 | current_line += 1 109 | 110 | lines.append(current_line) 111 | while fh.tell() < eoffset: 112 | fh.readline() 113 | current_line += 1 114 | lines.append(current_line) 115 | fh.close() 116 | return lines 117 | 118 | 119 | def get_snippet_at_line(filename, lineno): 120 | current_line = 0 121 | fr = open(filename, "r", encoding="utf-8", errors="ignore") 122 | fr.seek(0) 123 | while current_line = new_injected_loc: 132 | locs[i]['loc']= locs[i]['loc'] + bug_snip_len 133 | 134 | return locs 135 | 136 | def printUsage(prog): 137 | print("%s " % prog) 138 | 139 | if __name__ == "__main__": 140 | if 1 != len(sys.argv): 141 | if sys.argv[1] in ('--help', '-h'): 142 | printUsage(sys.argv[0]) 143 | print(get_pattern_all_offsets("5.sol","msg.sender==owner")) 144 | -------------------------------------------------------------------------------- /performance.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import matplotlib.pyplot as plt 4 | import numpy as np 5 | import matplotlib as mpl 6 | import solidifi 7 | import os 8 | 9 | bug_types = ['Re-entrancy','Timestamp-Dependency','Unchecked-Send','Unhandled-Exceptions','TOD','Overflow-Underflow','tx.origin'] 10 | # x axis values 11 | x = [ i for i in range(1,51)] 12 | # corresponding y axis values 13 | time_v = [] 14 | rounds = [i for i in range(1,6)] 15 | 16 | for cs in x: 17 | time_avg=0 18 | iter_avg=0 19 | for bug_type in bug_types: 20 | iter_avg=0 21 | for iter in rounds: 22 | time = solidifi.interior_main("-i" ,"contracts/"+str(cs)+".sol" ,bug_type) 23 | iter_avg=iter_avg+float(time) 24 | time_avg=time_avg+round(np.average(iter_avg),3) 25 | time_v.append(round(time_avg,3)) 26 | 27 | # plotting the points 28 | y_pos = np.arange(len(x)) 29 | plt.bar(x, time_v, align='center', width = 0.7, alpha=0.5) 30 | 31 | 32 | for a,b in zip(x, time_v): 33 | plt.text(a-(len(str(b))/5)/2, b+0.01, str(b), size=9) 34 | plt.subplots_adjust(bottom= 0.1, top = 0.9, hspace=0.5) 35 | 36 | plt.plot([0, 51], [0.15,0.15], "k--") 37 | 38 | 39 | plt.xticks(np.arange(0, 51, step=5)) 40 | 41 | 42 | # naming the x axis 43 | plt.xlabel('Contracts') 44 | # naming the y axis 45 | plt.ylabel('Runtime (Sec)') 46 | mpl.rcParams.update({'font.size': 51}) 47 | 48 | 49 | plt.savefig('runtime.eps', dpi=600) 50 | # function to show the plot 51 | plt.show() 52 | 53 | print("Average time = {0}".format(round(np.average(time_v),3))) 54 | print("Maximum time = {0}".format(round(np.max(time_v),3))) -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | matplotlib 2 | ijson 3 | numpy 4 | configparser 5 | pandas 6 | -e . -------------------------------------------------------------------------------- /sec_methods.conf: -------------------------------------------------------------------------------- 1 | [1] 2 | bug_type=Unhandled-Exceptions 3 | sec_meth_pattern=if(.*?)\s(.*?)revert 4 | snip_to_remove= 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | 3 | from setuptools import find_packages 4 | 5 | setup( 6 | name='solidifi', 7 | version='0.0.1', 8 | packages=find_packages(), 9 | install_requires=[ 10 | 'matplotlib', 11 | 'ijson', 12 | 'numpy', 13 | 'configparser', 14 | 'pandas' 15 | ], 16 | entry_points={ 17 | 'console_scripts': [ 18 | 'solidifi = solidifi.__main__:main' 19 | ] 20 | } 21 | ) -------------------------------------------------------------------------------- /solidifi.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: solidifi 3 | Version: 0.0.1 4 | Summary: UNKNOWN 5 | Home-page: UNKNOWN 6 | Author: UNKNOWN 7 | Author-email: UNKNOWN 8 | License: UNKNOWN 9 | Description: UNKNOWN 10 | Platform: UNKNOWN 11 | -------------------------------------------------------------------------------- /solidifi.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | solidifi.egg-info/PKG-INFO 2 | solidifi.egg-info/SOURCES.txt 3 | solidifi.egg-info/dependency_links.txt 4 | solidifi.egg-info/entry_points.txt 5 | solidifi.egg-info/requires.txt 6 | solidifi.egg-info/top_level.txt -------------------------------------------------------------------------------- /solidifi.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /solidifi.egg-info/entry_points.txt: -------------------------------------------------------------------------------- 1 | [console_scripts] 2 | solidifi = solidifi.__main__:main 3 | 4 | -------------------------------------------------------------------------------- /solidifi.egg-info/requires.txt: -------------------------------------------------------------------------------- 1 | matplotlib 2 | ijson 3 | numpy 4 | configparser 5 | pandas 6 | -------------------------------------------------------------------------------- /solidifi.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | 2 | --------------------------------------------------------------------------------