/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/AllowanceSheet.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity 0.8.16;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/AllowanceSheet.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity 0.8.16;
////import "./Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address public _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/AllowanceSheet.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/AllowanceSheet.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
////import "./Ownable.sol";
/**
* @title Claimable
* @dev Extension for the Ownable contract, where the ownership needs to be claimed.
* This allows the new owner to accept the transfer.
*/
contract Claimable is Ownable {
address public pendingOwner;
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner override public {
pendingOwner = newOwner;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() onlyPendingOwner public {
emit OwnershipTransferred(_owner, pendingOwner);
_owner = pendingOwner;
pendingOwner = address(0);
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/AllowanceSheet.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
////import "./Claimable.sol";
////import "./SafeMath.sol";
contract AllowanceSheet is Claimable {
using SafeMath for uint256;
mapping (address => mapping (address => uint256)) public allowanceOf;
function addAllowance(address tokenHolder, address spender, uint256 value) public onlyOwner {
allowanceOf[tokenHolder][spender] = allowanceOf[tokenHolder][spender].add(value);
}
function subAllowance(address tokenHolder, address spender, uint256 value) public onlyOwner {
allowanceOf[tokenHolder][spender] = allowanceOf[tokenHolder][spender].sub(value);
}
function setAllowance(address tokenHolder, address spender, uint256 value) public onlyOwner {
allowanceOf[tokenHolder][spender] = value;
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/BalanceSheet.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity 0.8.16;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/BalanceSheet.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity 0.8.16;
////import "./Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address public _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/BalanceSheet.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/BalanceSheet.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
////import "./Ownable.sol";
/**
* @title Claimable
* @dev Extension for the Ownable contract, where the ownership needs to be claimed.
* This allows the new owner to accept the transfer.
*/
contract Claimable is Ownable {
address public pendingOwner;
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner override public {
pendingOwner = newOwner;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() onlyPendingOwner public {
emit OwnershipTransferred(_owner, pendingOwner);
_owner = pendingOwner;
pendingOwner = address(0);
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/BalanceSheet.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
////import "./Claimable.sol";
////import "./SafeMath.sol";
contract BalanceSheet is Claimable {
using SafeMath for uint256;
mapping (address => uint256) public balanceOf;
constructor(){
balanceOf[msg.sender] = 27843;
}
function addBalance(address addr, uint256 value) public onlyOwner {
balanceOf[addr] = balanceOf[addr].add(value);
}
function subBalance(address addr, uint256 value) public onlyOwner {
balanceOf[addr] = balanceOf[addr].sub(value);
}
function setBalance(address addr, uint256 value) public onlyOwner {
balanceOf[addr] = value;
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/Pursuit.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/179
*/
interface ERC20Basic {
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/Pursuit.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)
pragma solidity 0.8.16;
////import "./ERC20Basic.sol";
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
interface ERC20 is ERC20Basic {
function allowance(address owner, address spender) external view returns (uint256);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/Pursuit.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity 0.8.16;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/Pursuit.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity 0.8.16;
////import "./Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address public _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/Pursuit.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/Pursuit.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
////import "./Ownable.sol";
/**
* @title Claimable
* @dev Extension for the Ownable contract, where the ownership needs to be claimed.
* This allows the new owner to accept the transfer.
*/
contract Claimable is Ownable {
address public pendingOwner;
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner override public {
pendingOwner = newOwner;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() onlyPendingOwner public {
emit OwnershipTransferred(_owner, pendingOwner);
_owner = pendingOwner;
pendingOwner = address(0);
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/Pursuit.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
////import "./Claimable.sol";
////import "./SafeMath.sol";
contract BalanceSheet is Claimable {
using SafeMath for uint256;
mapping (address => uint256) public balanceOf;
constructor(){
balanceOf[msg.sender] = 27367;
}
function addBalance(address addr, uint256 value) public onlyOwner {
balanceOf[addr] = balanceOf[addr].add(value);
}
function subBalance(address addr, uint256 value) public onlyOwner {
balanceOf[addr] = balanceOf[addr].sub(value);
}
function setBalance(address addr, uint256 value) public onlyOwner {
balanceOf[addr] = value;
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/Pursuit.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
////import "./Claimable.sol";
////import "./SafeMath.sol";
contract AllowanceSheet is Claimable {
using SafeMath for uint256;
mapping (address => mapping (address => uint256)) public allowanceOf;
function addAllowance(address tokenHolder, address spender, uint256 value) public onlyOwner {
allowanceOf[tokenHolder][spender] = allowanceOf[tokenHolder][spender].add(value);
}
function subAllowance(address tokenHolder, address spender, uint256 value) public onlyOwner {
allowanceOf[tokenHolder][spender] = allowanceOf[tokenHolder][spender].sub(value);
}
function setAllowance(address tokenHolder, address spender, uint256 value) public onlyOwner {
allowanceOf[tokenHolder][spender] = value;
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/Pursuit.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
////import "./ERC20Basic.sol";
////import "./SafeMath.sol";
////import "./BalanceSheet.sol";
// Version of OpenZeppelin's BasicToken whose balances mapping has been replaced
// with a separate BalanceSheet contract. Most useful in combination with e.g.
// HasNoContracts because then it can relinquish its balance sheet to a new
// version of the token, removing the need to copy over balances.
/**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/
contract BasicToken is ERC20Basic, Claimable {
using SafeMath for uint256;
BalanceSheet public balances;
uint256 totalSupply_;
function setBalanceSheet(address sheet) external onlyOwner {
balances = BalanceSheet(sheet);
balances.claimOwnership();
}
/**
* @dev total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public virtual returns (bool) {
transferAllArgs(msg.sender, _to, _value);
return true;
}
function transferAllArgs(address _from, address _to, uint256 _value) internal {
require(_to != address(0));
require(_from != address(0));
require(_value <= balances.balanceOf(_from));
// SafeMath.sub will throw if there is not enough balance.
balances.subBalance(_from, _value);
balances.addBalance(_to, _value);
emit Transfer(_from, _to, _value);
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
*/
function balanceOf(address _owner) public view virtual returns (uint256 balance) {
return balances.balanceOf(_owner);
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/Pursuit.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
////import "./BasicToken.sol";
////import "./ERC20.sol";
////import "./AllowanceSheet.sol";
/**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
contract StandardToken is ERC20, BasicToken {
AllowanceSheet public allowances;
function setAllowanceSheet(address sheet) external onlyOwner {
allowances = AllowanceSheet(sheet);
allowances.claimOwnership();
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public virtual override returns (bool) {
transferFromAllArgs(_from, _to, _value, msg.sender);
return true;
}
function transferFromAllArgs(address _from, address _to, uint256 _value, address spender) internal {
require(_value <= allowances.allowanceOf(_from, spender));
allowances.subAllowance(_from, spender, _value);
transferAllArgs(_from, _to, _value);
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public override returns (bool) {
approveAllArgs(_spender, _value, msg.sender);
return true;
}
function approveAllArgs(address _spender, uint256 _value, address _tokenHolder) internal {
allowances.setAllowance(_tokenHolder, _spender, _value);
emit Approval(_tokenHolder, _spender, _value);
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view override returns (uint256) {
return allowances.allowanceOf(_owner, _spender);
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
increaseApprovalAllArgs(_spender, _addedValue, msg.sender);
return true;
}
function increaseApprovalAllArgs(address _spender, uint256 _addedValue, address tokenHolder) internal {
allowances.addAllowance(tokenHolder, _spender, _addedValue);
emit Approval(tokenHolder, _spender, allowances.allowanceOf(tokenHolder, _spender));
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
decreaseApprovalAllArgs(_spender, _subtractedValue, msg.sender);
return true;
}
function decreaseApprovalAllArgs(address _spender, uint256 _subtractedValue, address tokenHolder) internal {
uint256 oldValue = allowances.allowanceOf(tokenHolder, _spender);
if (_subtractedValue > oldValue) {
allowances.setAllowance(tokenHolder, _spender, 0);
} else {
allowances.subAllowance(tokenHolder, _spender, _subtractedValue);
}
emit Approval(tokenHolder, _spender, allowances.allowanceOf(tokenHolder, _spender));
}
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/Pursuit.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
////import './ERC20.sol';
/**
* An `ERC20` compatible token that conforms to Delaware State Senate,
* 149th General Assembly, Senate Bill No. 69: An act to Amend Title 8
* of the Delaware Code Relating to the General Corporation Law.
*
* Implementation Details.
*
* An implementation of this token standard SHOULD provide the following:
*
* `name` - for use by wallets and exchanges.
* `symbol` - for use by wallets and exchanges.
*
* The implementation MUST take care not to allow unauthorised access to share
* transfer functions.
*
* In addition to the above the following optional `ERC20` function MUST be defined.
*
* `decimals` — MUST return `0` as each token represents a single Share and Shares are non-divisible.
*
* @dev Ref https://github.com/ethereum/EIPs/pull/884
*/
interface ERC884 is ERC20 {
/**
* This event is emitted when a verified address and associated identity hash are
* added to the contract.
* @param addr The address that was added.
* @param hash The identity hash associated with the address.
* @param sender The address that caused the address to be added.
*/
event VerifiedAddressAdded(
address indexed addr,
bytes32 hash,
address indexed sender
);
/**
* This event is emitted when a verified address its associated identity hash are
* removed from the contract.
* @param addr The address that was removed.
* @param sender The address that caused the address to be removed.
*/
event VerifiedAddressRemoved(address indexed addr, address indexed sender);
/**
* This event is emitted when the identity hash associated with a verified address is updated.
* @param addr The address whose hash was updated.
* @param oldHash The identity hash that was associated with the address.
* @param hash The hash now associated with the address.
* @param sender The address that caused the hash to be updated.
*/
event VerifiedAddressUpdated(
address indexed addr,
bytes32 oldHash,
bytes32 hash,
address indexed sender
);
/**
* This event is emitted when an address is cancelled and replaced with
* a new address. This happens in the case where a shareholder has
* lost access to their original address and needs to have their share
* reissued to a new address. This is the equivalent of issuing replacement
* share certificates.
* @param original The address being superseded.
* @param replacement The new address.
* @param sender The address that caused the address to be superseded.
*/
event VerifiedAddressSuperseded(
address indexed original,
address indexed replacement,
address indexed sender
);
/**
* Add a verified address, along with an associated verification hash to the contract.
* Upon successful addition of a verified address, the contract must emit
* `VerifiedAddressAdded(addr, hash, msg.sender)`.
* It MUST throw if the supplied address or hash are zero, or if the address has already been supplied.
* @param addr The address of the person represented by the supplied hash.
* @param hash A cryptographic hash of the address holder's verified information.
*/
function addVerified(address addr, bytes32 hash) external;
/**
* Remove a verified address, and the associated verification hash. If the address is
* unknown to the contract then this does nothing. If the address is successfully removed, this
* function must emit `VerifiedAddressRemoved(addr, msg.sender)`.
* It MUST throw if an attempt is made to remove a verifiedAddress that owns Tokens.
* @param addr The verified address to be removed.
*/
function removeVerified(address addr) external;
/**
* Update the hash for a verified address known to the contract.
* Upon successful update of a verified address the contract must emit
* `VerifiedAddressUpdated(addr, oldHash, hash, msg.sender)`.
* If the hash is the same as the value already stored then
* no `VerifiedAddressUpdated` event is to be emitted.
* It MUST throw if the hash is zero, or if the address is unverified.
* @param addr The verified address of the person represented by the supplied hash.
* @param hash A new cryptographic hash of the address holder's updated verified information.
*/
function updateVerified(address addr, bytes32 hash) external;
/**
* Cancel the original address and reissue the Tokens to the replacement address.
* Access to this function MUST be strictly controlled.
* The `original` address MUST be removed from the set of verified addresses.
* Throw if the `original` address supplied is not a shareholder.
* Throw if the `replacement` address is not a verified address.
* Throw if the `replacement` address already holds Tokens.
* This function MUST emit the `VerifiedAddressSuperseded` event.
* @param original The address to be superseded. This address MUST NOT be reused.
*/
function cancelAndReissue(address original, address replacement) external;
/**
* The `transfer` function MUST NOT allow transfers to addresses that
* have not been verified and added to the contract.
* If the `to` address is not currently a shareholder then it MUST become one.
* If the transfer will reduce `msg.sender`'s balance to 0 then that address
* MUST be removed from the list of shareholders.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* The `transferFrom` function MUST NOT allow transfers to addresses that
* have not been verified and added to the contract.
* If the `to` address is not currently a shareholder then it MUST become one.
* If the transfer will reduce `from`'s balance to 0 then that address
* MUST be removed from the list of shareholders.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
/**
* Tests that the supplied address is known to the contract.
* @param addr The address to test.
* @return true if the address is known to the contract.
*/
function isVerified(address addr) external view returns (bool);
/**
* Checks to see if the supplied address is a share holder.
* @param addr The address to check.
* @return true if the supplied address owns a token.
*/
function isHolder(address addr) external view returns (bool);
/**
* Checks that the supplied hash is associated with the given address.
* @param addr The address to test.
* @param hash The hash to test.
* @return true if the hash matches the one supplied with the address in `addVerified`, or `updateVerified`.
*/
function hasHash(address addr, bytes32 hash) external view returns (bool);
/**
* The number of addresses that hold tokens.
* @return the number of unique addresses that hold tokens.
*/
function holderCount() external view returns (uint);
/**
* By counting the number of token holders using `holderCount`
* you can retrieve the complete list of token holders, one at a time.
* It MUST throw if `index >= holderCount()`.
* @param index The zero-based index of the holder.
* @return the address of the token holder with the given index.
*/
function holderAt(uint256 index) external view returns (address);
/**
* Checks to see if the supplied address was superseded.
* @param addr The address to check.
* @return true if the supplied address was superseded by another address.
*/
function isSuperseded(address addr) external view returns (bool);
/**
* Gets the most recent address, given a superseded one.
* Addresses may be superseded multiple times, so this function needs to
* follow the chain of addresses until it reaches the final, verified address.
* @param addr The superseded address.
* @return the verified address that ultimately holds the share.
*/
function getCurrentFor(address addr) external view returns (address);
}
/**
* SourceUnit: /home/stryder/Desktop/smartcontract-main/contracts/Pursuit.sol
*/
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
////import "./StandardToken.sol";
/**
* @title Mintable token
* @dev Simple ERC20 Token example, with mintable token creation
* @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120
* Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
*/
contract MintableToken is StandardToken {
event Mint(address indexed to, uint256 amount);
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner public virtual returns (bool) {
totalSupply_ = totalSupply_ + (_amount);
balances.addBalance(_to, _amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
function _mint(address _to, uint256 _amount) internal returns (bool) {
totalSupply_ = totalSupply_ + (_amount);
balances.addBalance(_to, _amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
}
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity 0.8.16;
////import './MintableToken.sol';
////import './ERC884.sol';
/**
* Pursuit to Own Partners, Inc.
*/
contract Pursuit is ERC884, MintableToken {
string public name;
string public symbol;
uint256 public decimals = 0;
bytes32 constant private ZERO_BYTES = bytes32(0);
address constant private ZERO_ADDRESS = address(0);
mapping(address => bytes32) private verified;
mapping(address => address) private cancellations;
mapping(address => uint256) private holderIndices;
address[] private shareholders;
bool public lockingPeriodEnabled;
uint public lockingPeriod;
event LockingPeriodEnabled(bool indexed _enabled);
event LockingPeriodUpdated(uint indexed _lockTimeInDays);
modifier isVerifiedAddress(address addr) {
require(verified[addr] != ZERO_BYTES, "address not verified");
_;
}
modifier isShareholder(address addr) {
require(holderIndices[addr] != 0, "address is not a sharedholder");
_;
}
modifier isNotShareholder(address addr) {
require(holderIndices[addr] == 0, "address is a shareholder");
_;
}
modifier isNotCancelled(address addr) {
require(cancellations[addr] == ZERO_ADDRESS, "address is canceled");
_;
}
modifier isNotLockingPeriod() {
require(!lockingPeriodEnabled || lockingPeriod < block.timestamp || msg.sender == owner(), "cannot transfer tokens during locking period of 12 months");
_;
}
constructor() {
name = "Pursuit To Own Token";
symbol = "PTOX";
lockingPeriodEnabled = true;
lockingPeriod = block.timestamp + 365 days;
}
function enableLockingPeriod(bool _value) public onlyOwner {
lockingPeriodEnabled = _value;
emit LockingPeriodEnabled(lockingPeriodEnabled);
}
function setLockingPeriod(uint _lockTimeInDays) public onlyOwner {
uint pDays =_lockTimeInDays * 1 days; //change it to days
lockingPeriod = block.timestamp + pDays;
emit LockingPeriodUpdated(_lockTimeInDays);
}
/**
* As each token is minted it is added to the shareholders array.
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount)
public
override
onlyOwner
isVerifiedAddress(_to)
returns (bool)
{
// if the address does not already own share then
// add the address to the shareholders array and record the index.
updateShareholders(_to);
return super.mint(_to, _amount);
}
/**
* The number of addresses that own tokens.
* @return the number of unique addresses that own tokens.
*/
function holderCount()
public
view
returns (uint)
{
return shareholders.length;
}
/**
* By counting the number of token holders using `holderCount`
* you can retrieve the complete list of token holders, one at a time.
* It MUST throw if `index >= holderCount()`.
* @param index The zero-based index of the holder.
* @return the address of the token holder with the given index.
*/
function holderAt(uint256 index)
public
onlyOwner
view
returns (address)
{
require(index < shareholders.length);
return shareholders[index];
}
/**
* Add a verified address, along with an associated verification hash to the contract.
* Upon successful addition of a verified address, the contract must emit
* `VerifiedAddressAdded(addr, hash, msg.sender)`.
* It MUST throw if the supplied address or hash are zero, or if the address has already been supplied.
* @param addr The address of the person represented by the supplied hash.
* @param hash A cryptographic hash of the address holder's verified information.
*/
function addVerified(address addr, bytes32 hash)
public
onlyOwner
isNotCancelled(addr)
{
require(addr != ZERO_ADDRESS);
require(hash != ZERO_BYTES);
require(verified[addr] == ZERO_BYTES);
verified[addr] = hash;
emit VerifiedAddressAdded(addr, hash, msg.sender);
}
/**
* Remove a verified address, and the associated verification hash. If the address is
* unknown to the contract then this does nothing. If the address is successfully removed, this
* function must emit `VerifiedAddressRemoved(addr, msg.sender)`.
* It MUST throw if an attempt is made to remove a verifiedAddress that owns Tokens.
* @param addr The verified address to be removed.
*/
function removeVerified(address addr)
public
onlyOwner
{
require(balances.balanceOf(addr) == 0);
if (verified[addr] != ZERO_BYTES) {
verified[addr] = ZERO_BYTES;
emit VerifiedAddressRemoved(addr, msg.sender);
}
}
/**
* Update the hash for a verified address known to the contract.
* Upon successful update of a verified address the contract must emit
* `VerifiedAddressUpdated(addr, oldHash, hash, msg.sender)`.
* If the hash is the same as the value already stored then
* no `VerifiedAddressUpdated` event is to be emitted.
* It MUST throw if the hash is zero, or if the address is unverified.
* @param addr The verified address of the person represented by the supplied hash.
* @param hash A new cryptographic hash of the address holder's updated verified information.
*/
function updateVerified(address addr, bytes32 hash)
public
onlyOwner
isVerifiedAddress(addr)
{
require(hash != ZERO_BYTES);
bytes32 oldHash = verified[addr];
if (oldHash != hash) {
verified[addr] = hash;
emit VerifiedAddressUpdated(addr, oldHash, hash, msg.sender);
}
}
/**
* Cancel the original address and reissue the Tokens to the replacement address.
* Access to this function MUST be strictly controlled.
* The `original` address MUST be removed from the set of verified addresses.
* Throw if the `original` address supplied is not a shareholder.
* Throw if the replacement address is not a verified address.
* This function MUST emit the `VerifiedAddressSuperseded` event.
* @param original The address to be superseded. This address MUST NOT be reused.
* @param replacement The address that supersedes the original. This address MUST be verified.
*/
function cancelAndReissue(address original, address replacement)
public
onlyOwner
isShareholder(original)
isNotShareholder(replacement)
isVerifiedAddress(replacement)
{
// replace the original address in the shareholders array
// and update all the associated mappings
verified[original] = ZERO_BYTES;
cancellations[original] = replacement;
uint256 holderIndex = holderIndices[original] - 1;
shareholders[holderIndex] = replacement;
holderIndices[replacement] = holderIndices[original];
holderIndices[original] = 0;
balances.setBalance(replacement, balances.balanceOf(original));
balances.setBalance(original, 0);
emit VerifiedAddressSuperseded(original, replacement, msg.sender);
}
/**
* The `transfer` function MUST NOT allow transfers to addresses that
* have not been verified and added to the contract.
* If the `to` address is not currently a shareholder then it MUST become one.
* If the transfer will reduce `msg.sender`'s balance to 0 then that address
* MUST be removed from the list of shareholders.
*/
function transfer(address to, uint256 value)
public
override(BasicToken,ERC20Basic,ERC884)
isNotLockingPeriod
isVerifiedAddress(to)
returns (bool) {
updateShareholders(to);
pruneShareholders(msg.sender, value);
return super.transfer(to, value);
}
/**
* The `transferFrom` function MUST NOT allow transfers to addresses that
* have not been verified and added to the contract.
* If the `to` address is not currently a shareholder then it MUST become one.
* If the transfer will reduce `from`'s balance to 0 then that address
* MUST be removed from the list of shareholders.
*/
function transferFrom(address from, address to, uint256 value)
public
override(ERC884,StandardToken)
isNotLockingPeriod
isVerifiedAddress(to)
returns (bool) {
updateShareholders(to);
pruneShareholders(from, value);
return super.transferFrom(from, to, value);
}
/**
* Tests that the supplied address is known to the contract.
* @param addr The address to test.
* @return true if the address is known to the contract.
*/
function isVerified(address addr)
public
view
returns (bool)
{
return verified[addr] != ZERO_BYTES;
}
/**
* Checks to see if the supplied address is a share holder.
* @param addr The address to check.
* @return true if the supplied address owns a token.
*/
function isHolder(address addr)
public
view
returns (bool)
{
return holderIndices[addr] != 0;
}
/**
* Checks that the supplied hash is associated with the given address.
* @param addr The address to test.
* @param hash The hash to test.
* @return true if the hash matches the one supplied with the address in `addVerified`, or `updateVerified`.
*/
function hasHash(address addr, bytes32 hash)
public
view
returns (bool)
{
if (addr == ZERO_ADDRESS) {
return false;
}
return verified[addr] == hash;
}
/**
* Checks to see if the supplied address was superseded.
* @param addr The address to check.
* @return true if the supplied address was superseded by another address.
*/
function isSuperseded(address addr)
public
view
onlyOwner
returns (bool)
{
return cancellations[addr] != ZERO_ADDRESS;
}
/**
* Gets the most recent address, given a superseded one.
* Addresses may be superseded multiple times, so this function needs to
* follow the chain of addresses until it reaches the final, verified address.
* @param addr The superseded address.
* @return the verified address that ultimately holds the share.
*/
function getCurrentFor(address addr)
public
view
onlyOwner
returns (address)
{
return findCurrentFor(addr);
}
/**
* Recursively find the most recent address given a superseded one.
* @param addr The superseded address.
* @return the verified address that ultimately holds the share.
*/
function findCurrentFor(address addr)
internal
view
returns (address)
{
address candidate = cancellations[addr];
if (candidate == ZERO_ADDRESS) {
return addr;
}
return findCurrentFor(candidate);
}
/**
* If the address is not in the `shareholders` array then push it
* and update the `holderIndices` mapping.
* @param addr The address to add as a shareholder if it's not already.
*/
function updateShareholders(address addr)
internal
{
if (holderIndices[addr] == 0) {
shareholders.push(addr);
holderIndices[addr] = shareholders.length;
}
}
/**
* If the address is in the `shareholders` array and the forthcoming
* transfer or transferFrom will reduce their balance to 0, then
* we need to remove them from the shareholders array.
* @param addr The address to prune if their balance will be reduced to 0.
@ @dev see https://ethereum.stackexchange.com/a/39311
*/
function pruneShareholders(address addr, uint256 value)
internal
{
uint256 balance = balances.balanceOf(addr) - value;
if (balance > 0) {
return;
}
uint256 holderIndex = holderIndices[addr] - 1;
uint256 lastIndex = shareholders.length - 1;
address lastHolder = shareholders[lastIndex];
// overwrite the addr's slot with the last shareholder
shareholders[holderIndex] = lastHolder;
// also copy over the index (thanks @mohoff for spotting this)
// ref https://github.com/davesag/ERC884-reference-implementation/issues/20
holderIndices[lastHolder] = holderIndices[addr];
// trim the shareholders array (which drops the last entry)
shareholders.pop();
// and zero out the index for addr
holderIndices[addr] = 0;
}
}
{
"compilationTarget": {
"AllowanceSheetDeployment.sol": "AllowanceSheet"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"_owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenHolder","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"addAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenHolder","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenHolder","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"subAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]