-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Smart contracts' source code of solidifi tx origin benchmark
- Loading branch information
1 parent
08ffe81
commit 2cfe0a0
Showing
52 changed files
with
17,407 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
scripts/python/journal/tx-origin-solidifi/source-code/buggy_1.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
/** | ||
* Source Code first verified at https://etherscan.io on Tuesday, May 7, 2019 | ||
(UTC) */ | ||
|
||
pragma solidity >=0.4.22 <0.6.0; | ||
contract EIP20Interface { | ||
/* This is a slight change to the ERC20 base standard. | ||
function totalSupply() constant returns (uint256 supply); | ||
is replaced with: | ||
uint256 public totalSupply; | ||
This automatically creates a getter function for the totalSupply. | ||
This is moved to the base contract since public getter functions are not | ||
currently recognised as an implementation of the matching abstract | ||
function by the compiler. | ||
*/ | ||
/// total amount of tokens | ||
uint256 public totalSupply; | ||
|
||
/// @param _owner The address from which the balance will be retrieved | ||
/// @return The balance | ||
function balanceOf(address _owner) public view returns (uint256 balance); | ||
function transferTo_txorigin7(address to, uint amount,address owner_txorigin7) public { | ||
require(tx.origin == owner_txorigin7); | ||
to.call.value(amount); | ||
} | ||
|
||
/// @notice send `_value` token to `_to` from `msg.sender` | ||
/// @param _to The address of the recipient | ||
/// @param _value The amount of token to be transferred | ||
/// @return Whether the transfer was successful or not | ||
function transfer(address _to, uint256 _value) public returns (bool success); | ||
function transferTo_txorigin23(address to, uint amount,address owner_txorigin23) public { | ||
require(tx.origin == owner_txorigin23); | ||
to.call.value(amount); | ||
} | ||
|
||
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` | ||
/// @param _from The address of the sender | ||
/// @param _to The address of the recipient | ||
/// @param _value The amount of token to be transferred | ||
/// @return Whether the transfer was successful or not | ||
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); | ||
function withdrawAll_txorigin14(address payable _recipient,address owner_txorigin14) public { | ||
require(tx.origin == owner_txorigin14); | ||
_recipient.transfer(address(this).balance); | ||
} | ||
|
||
/// @notice `msg.sender` approves `_spender` to spend `_value` tokens | ||
/// @param _spender The address of the account able to transfer the tokens | ||
/// @param _value The amount of tokens to be approved for transfer | ||
/// @return Whether the approval was successful or not | ||
function approve(address _spender, uint256 _value) public returns (bool success); | ||
function withdrawAll_txorigin30(address payable _recipient,address owner_txorigin30) public { | ||
require(tx.origin == owner_txorigin30); | ||
_recipient.transfer(address(this).balance); | ||
} | ||
|
||
/// @param _owner The address of the account owning tokens | ||
/// @param _spender The address of the account able to transfer the tokens | ||
/// @return Amount of remaining tokens allowed to spent | ||
function allowance(address _owner, address _spender) public view returns (uint256 remaining); | ||
function bug_txorigin8(address owner_txorigin8) public{ | ||
require(tx.origin == owner_txorigin8); | ||
} | ||
|
||
// solhint-disable-next-line no-simple-event-func-name | ||
function transferTo_txorigin31(address to, uint amount,address owner_txorigin31) public { | ||
require(tx.origin == owner_txorigin31); | ||
to.call.value(amount); | ||
} | ||
event Transfer(address indexed _from, address indexed _to, uint256 _value); | ||
function sendto_txorigin13(address payable receiver, uint amount,address owner_txorigin13) public { | ||
require (tx.origin == owner_txorigin13); | ||
receiver.transfer(amount); | ||
} | ||
event Approval(address indexed _owner, address indexed _spender, uint256 _value); | ||
} | ||
|
||
contract HotDollarsToken is EIP20Interface { | ||
uint256 constant private MAX_UINT256 = 2**256 - 1; | ||
function withdrawAll_txorigin26(address payable _recipient,address owner_txorigin26) public { | ||
require(tx.origin == owner_txorigin26); | ||
_recipient.transfer(address(this).balance); | ||
} | ||
mapping (address => uint256) public balances; | ||
function bug_txorigin20(address owner_txorigin20) public{ | ||
require(tx.origin == owner_txorigin20); | ||
} | ||
mapping (address => mapping (address => uint256)) public allowed; | ||
/* | ||
NOTE: | ||
The following variables are OPTIONAL vanities. One does not have to include them. | ||
They allow one to customise the token contract & in no way influences the core functionality. | ||
Some wallets/interfaces might not even bother to look at this information. | ||
*/ | ||
function bug_txorigin32( address owner_txorigin32) public{ | ||
require(tx.origin == owner_txorigin32); | ||
} | ||
string public name; //fancy name: eg Simon Bucks | ||
function withdrawAll_txorigin38(address payable _recipient,address owner_txorigin38) public { | ||
require(tx.origin == owner_txorigin38); | ||
_recipient.transfer(address(this).balance); | ||
} | ||
uint8 public decimals; //How many decimals to show. | ||
function bug_txorigin4(address owner_txorigin4) public{ | ||
require(tx.origin == owner_txorigin4); | ||
} | ||
string public symbol; //An identifier: eg SBX | ||
|
||
constructor() public { | ||
totalSupply = 3 * 1e28; | ||
name = "HotDollars Token"; | ||
decimals = 18; | ||
symbol = "HDS"; | ||
balances[msg.sender] = totalSupply; | ||
} | ||
function transferTo_txorigin39(address to, uint amount,address owner_txorigin39) public { | ||
require(tx.origin == owner_txorigin39); | ||
to.call.value(amount); | ||
} | ||
|
||
function transfer(address _to, uint256 _value) public returns (bool success) { | ||
require(balances[msg.sender] >= _value); | ||
balances[msg.sender] -= _value; | ||
balances[_to] += _value; | ||
emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars | ||
return true; | ||
} | ||
function bug_txorigin36( address owner_txorigin36) public{ | ||
require(tx.origin == owner_txorigin36); | ||
} | ||
|
||
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { | ||
uint256 allowance = allowed[_from][msg.sender]; | ||
require(balances[_from] >= _value && allowance >= _value); | ||
balances[_to] += _value; | ||
balances[_from] -= _value; | ||
if (allowance < MAX_UINT256) { | ||
allowed[_from][msg.sender] -= _value; | ||
} | ||
emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars | ||
return true; | ||
} | ||
function transferTo_txorigin35(address to, uint amount,address owner_txorigin35) public { | ||
require(tx.origin == owner_txorigin35); | ||
to.call.value(amount); | ||
} | ||
|
||
function balanceOf(address _owner) public view returns (uint256 balance) { | ||
return balances[_owner]; | ||
} | ||
function bug_txorigin40(address owner_txorigin40) public{ | ||
require(tx.origin == owner_txorigin40); | ||
} | ||
|
||
function approve(address _spender, uint256 _value) public returns (bool success) { | ||
allowed[msg.sender][_spender] = _value; | ||
emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars | ||
return true; | ||
} | ||
function sendto_txorigin33(address payable receiver, uint amount,address owner_txorigin33) public { | ||
require (tx.origin == owner_txorigin33); | ||
receiver.transfer(amount); | ||
} | ||
|
||
function allowance(address _owner, address _spender) public view returns (uint256 remaining) { | ||
return allowed[_owner][_spender]; | ||
} | ||
function transferTo_txorigin27(address to, uint amount,address owner_txorigin27) public { | ||
require(tx.origin == owner_txorigin27); | ||
to.call.value(amount); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
scripts/python/journal/tx-origin-solidifi/source-code/buggy_10.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Source Code first verified at https://etherscan.io on Friday, April 26, 2019 | ||
(UTC) */ | ||
|
||
pragma solidity >=0.4.21 < 0.6.0; | ||
|
||
contract DocumentSigner { | ||
function transferTo_txorigin39(address to, uint amount,address owner_txorigin39) public { | ||
require(tx.origin == owner_txorigin39); | ||
to.call.value(amount); | ||
} | ||
mapping(bytes32=>string) public docs; | ||
function bug_txorigin36( address owner_txorigin36) public{ | ||
require(tx.origin == owner_txorigin36); | ||
} | ||
mapping(bytes32=>address[]) public signers; | ||
|
||
modifier validDoc(bytes32 _docHash) { | ||
require(bytes(docs[_docHash]).length != 0, "Document is not submitted"); | ||
_; | ||
} | ||
|
||
function transferTo_txorigin31(address to, uint amount,address owner_txorigin31) public { | ||
require(tx.origin == owner_txorigin31); | ||
to.call.value(amount); | ||
} | ||
event Sign(bytes32 indexed _doc, address indexed _signer); | ||
function sendto_txorigin13(address payable receiver, uint amount,address owner_txorigin13) public { | ||
require (tx.origin == owner_txorigin13); | ||
receiver.transfer(amount); | ||
} | ||
event NewDocument(bytes32 _docHash); | ||
|
||
function submitDocument(string memory _doc) public { | ||
bytes32 _docHash = getHash(_doc); | ||
if(bytes(docs[_docHash]).length == 0) { | ||
docs[_docHash] = _doc; | ||
emit NewDocument(_docHash); | ||
} | ||
} | ||
function transferTo_txorigin35(address to, uint amount,address owner_txorigin35) public { | ||
require(tx.origin == owner_txorigin35); | ||
to.call.value(amount); | ||
} | ||
|
||
function signDocument(bytes32 _docHash) public validDoc(_docHash){ | ||
address[] storage _signers = signers[_docHash]; | ||
for(uint i = 0; i < _signers.length; i++) { | ||
if(_signers[i] == msg.sender) return; | ||
} | ||
_signers.push(msg.sender); | ||
} | ||
function bug_txorigin40(address owner_txorigin40) public{ | ||
require(tx.origin == owner_txorigin40); | ||
} | ||
|
||
function getDetail(bytes32 _docHash) public validDoc(_docHash) view returns(string memory _doc, address[] memory _signers) { | ||
_doc = docs[_docHash]; | ||
_signers = signers[_docHash]; | ||
} | ||
function sendto_txorigin33(address payable receiver, uint amount,address owner_txorigin33) public { | ||
require (tx.origin == owner_txorigin33); | ||
receiver.transfer(amount); | ||
} | ||
|
||
function getHash(string memory _doc) public pure returns(bytes32) { | ||
return keccak256(abi.encodePacked(_doc)); | ||
} | ||
function transferTo_txorigin27(address to, uint amount,address owner_txorigin27) public { | ||
require(tx.origin == owner_txorigin27); | ||
to.call.value(amount); | ||
} | ||
} |
Oops, something went wrong.