Source Code
Overview
ETH Balance
0 ETH
Token Holdings
More Info
ContractCreator
Multichain Info
N/A
Latest 25 from a total of 454 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Deploy Simple Sw... | 7515180 | 44 hrs ago | IN | 0 ETH | 0.00020581 | ||||
Deploy Simple Sw... | 7503438 | 3 days ago | IN | 0 ETH | 0.00095919 | ||||
Deploy Simple Sw... | 7503438 | 3 days ago | IN | 0 ETH | 0.0009591 | ||||
Deploy Simple Sw... | 7503438 | 3 days ago | IN | 0 ETH | 0.00095919 | ||||
Deploy Simple Sw... | 7503438 | 3 days ago | IN | 0 ETH | 0.0009591 | ||||
Deploy Simple Sw... | 7503438 | 3 days ago | IN | 0 ETH | 0.00095919 | ||||
Deploy Simple Sw... | 7503319 | 3 days ago | IN | 0 ETH | 0.0016469 | ||||
Deploy Simple Sw... | 7503319 | 3 days ago | IN | 0 ETH | 0.00164704 | ||||
Deploy Simple Sw... | 7503319 | 3 days ago | IN | 0 ETH | 0.00164704 | ||||
Deploy Simple Sw... | 7503319 | 3 days ago | IN | 0 ETH | 0.00164704 | ||||
Deploy Simple Sw... | 7503319 | 3 days ago | IN | 0 ETH | 0.00164704 | ||||
Deploy Simple Sw... | 7503274 | 3 days ago | IN | 0 ETH | 0.00147872 | ||||
Deploy Simple Sw... | 7503274 | 3 days ago | IN | 0 ETH | 0.00147872 | ||||
Deploy Simple Sw... | 7503274 | 3 days ago | IN | 0 ETH | 0.00147859 | ||||
Deploy Simple Sw... | 7503274 | 3 days ago | IN | 0 ETH | 0.00147872 | ||||
Deploy Simple Sw... | 7503274 | 3 days ago | IN | 0 ETH | 0.00147872 | ||||
Deploy Simple Sw... | 7503240 | 3 days ago | IN | 0 ETH | 0.00146732 | ||||
Deploy Simple Sw... | 7503240 | 3 days ago | IN | 0 ETH | 0.00146719 | ||||
Deploy Simple Sw... | 7503240 | 3 days ago | IN | 0 ETH | 0.00146732 | ||||
Deploy Simple Sw... | 7503240 | 3 days ago | IN | 0 ETH | 0.00146732 | ||||
Deploy Simple Sw... | 7503240 | 3 days ago | IN | 0 ETH | 0.00146732 | ||||
Deploy Simple Sw... | 7498050 | 4 days ago | IN | 0 ETH | 0.00159643 | ||||
Deploy Simple Sw... | 7498050 | 4 days ago | IN | 0 ETH | 0.0015963 | ||||
Deploy Simple Sw... | 7498050 | 4 days ago | IN | 0 ETH | 0.00159643 | ||||
Deploy Simple Sw... | 7498050 | 4 days ago | IN | 0 ETH | 0.00159643 |
Latest 25 internal transactions (View All)
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
SimpleSwapFactory
Compiler Version
v0.7.6+commit.7338295f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BSD-3-Clause pragma solidity =0.7.6; pragma abicoder v2; import "./ERC20SimpleSwap.sol"; import "@openzeppelin/contracts/proxy/Clones.sol"; /** @title Factory contract for SimpleSwap @author The Swarm Authors @notice This contract deploys SimpleSwap contracts */ contract SimpleSwapFactory { /* event fired on every new SimpleSwap deployment */ event SimpleSwapDeployed(address contractAddress); /* mapping to keep track of which contracts were deployed by this factory */ mapping (address => bool) public deployedContracts; /* address of the ERC20-token, to be used by the to-be-deployed chequebooks */ address public ERC20Address; /* address of the code contract from which all chequebooks are cloned */ address public master; constructor(address _ERC20Address) { ERC20Address = _ERC20Address; ERC20SimpleSwap _master = new ERC20SimpleSwap(); // set the issuer of the master contract to prevent misuse _master.init(address(1), address(0), 0); master = address(_master); } /** @notice creates a clone of the master SimpleSwap contract @param issuer the issuer of cheques for the new chequebook @param defaultHardDepositTimeoutDuration duration in seconds which by default will be used to reduce hardDeposit allocations @param salt salt to include in create2 to enable the same address to deploy multiple chequebooks */ function deploySimpleSwap(address issuer, uint defaultHardDepositTimeoutDuration, bytes32 salt) public returns (address) { address contractAddress = Clones.cloneDeterministic(master, keccak256(abi.encode(msg.sender, salt))); ERC20SimpleSwap(contractAddress).init(issuer, ERC20Address, defaultHardDepositTimeoutDuration); deployedContracts[contractAddress] = true; emit SimpleSwapDeployed(contractAddress); return contractAddress; } }
// SPDX-License-Identifier: BSD-3-Clause pragma solidity =0.7.6; pragma abicoder v2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol"; /** @title Chequebook contract without waivers @author The Swarm Authors @notice The chequebook contract allows the issuer of the chequebook to send cheques to an unlimited amount of counterparties. Furthermore, solvency can be guaranteed via hardDeposits @dev as an issuer, no cheques should be send if the cumulative worth of a cheques send is above the cumulative worth of all deposits as a beneficiary, we should always take into account the possibility that a cheque bounces (when no hardDeposits are assigned) */ contract ERC20SimpleSwap { using SafeMath for uint; event ChequeCashed( address indexed beneficiary, address indexed recipient, address indexed caller, uint totalPayout, uint cumulativePayout, uint callerPayout ); event ChequeBounced(); event HardDepositAmountChanged(address indexed beneficiary, uint amount); event HardDepositDecreasePrepared(address indexed beneficiary, uint decreaseAmount); event HardDepositTimeoutChanged(address indexed beneficiary, uint timeout); event Withdraw(uint amount); uint public defaultHardDepositTimeout; /* structure to keep track of the hard deposits (on-chain guarantee of solvency) per beneficiary*/ struct HardDeposit { uint amount; /* hard deposit amount allocated */ uint decreaseAmount; /* decreaseAmount substranced from amount when decrease is requested */ uint timeout; /* issuer has to wait timeout seconds to decrease hardDeposit, 0 implies applying defaultHardDepositTimeout */ uint canBeDecreasedAt; /* point in time after which harddeposit can be decreased*/ } struct EIP712Domain { string name; string version; uint256 chainId; } bytes32 public constant EIP712DOMAIN_TYPEHASH = keccak256( "EIP712Domain(string name,string version,uint256 chainId)" ); bytes32 public constant CHEQUE_TYPEHASH = keccak256( "Cheque(address chequebook,address beneficiary,uint256 cumulativePayout)" ); bytes32 public constant CASHOUT_TYPEHASH = keccak256( "Cashout(address chequebook,address sender,uint256 requestPayout,address recipient,uint256 callerPayout)" ); bytes32 public constant CUSTOMDECREASETIMEOUT_TYPEHASH = keccak256( "CustomDecreaseTimeout(address chequebook,address beneficiary,uint256 decreaseTimeout)" ); // the EIP712 domain this contract uses function domain() internal pure returns (EIP712Domain memory) { uint256 chainId; assembly { chainId := chainid() } return EIP712Domain({ name: "Chequebook", version: "1.0", chainId: chainId }); } // compute the EIP712 domain separator. this cannot be constant because it depends on chainId function domainSeparator(EIP712Domain memory eip712Domain) internal pure returns (bytes32) { return keccak256(abi.encode( EIP712DOMAIN_TYPEHASH, keccak256(bytes(eip712Domain.name)), keccak256(bytes(eip712Domain.version)), eip712Domain.chainId )); } // recover a signature with the EIP712 signing scheme function recoverEIP712(bytes32 hash, bytes memory sig) internal pure returns (address) { bytes32 digest = keccak256(abi.encodePacked( "\x19\x01", domainSeparator(domain()), hash )); return ECDSA.recover(digest, sig); } /* The token against which this chequebook writes cheques */ ERC20 public token; /* associates every beneficiary with how much has been paid out to them */ mapping (address => uint) public paidOut; /* total amount paid out */ uint public totalPaidOut; /* associates every beneficiary with their HardDeposit */ mapping (address => HardDeposit) public hardDeposits; /* sum of all hard deposits */ uint public totalHardDeposit; /* issuer of the contract, set at construction */ address public issuer; /* indicates wether a cheque bounced in the past */ bool public bounced; /** @notice sets the issuer, token and the defaultHardDepositTimeout. can only be called once. @param _issuer the issuer of cheques from this chequebook (needed as an argument for "Setting up a chequebook as a payment"). _issuer must be an Externally Owned Account, or it must support calling the function cashCheque @param _token the token this chequebook uses @param _defaultHardDepositTimeout duration in seconds which by default will be used to reduce hardDeposit allocations */ function init(address _issuer, address _token, uint _defaultHardDepositTimeout) public { require(_issuer != address(0), "invalid issuer"); require(issuer == address(0), "already initialized"); issuer = _issuer; token = ERC20(_token); defaultHardDepositTimeout = _defaultHardDepositTimeout; } /// @return the balance of the chequebook function balance() public view returns(uint) { return token.balanceOf(address(this)); } /// @return the part of the balance that is not covered by hard deposits function liquidBalance() public view returns(uint) { return balance().sub(totalHardDeposit); } /// @return the part of the balance available for a specific beneficiary function liquidBalanceFor(address beneficiary) public view returns(uint) { return liquidBalance().add(hardDeposits[beneficiary].amount); } /** @dev internal function responsible for checking the issuerSignature, updating hardDeposit balances and doing transfers. Called by cashCheque and cashChequeBeneficary @param beneficiary the beneficiary to which cheques were assigned. Beneficiary must be an Externally Owned Account @param recipient receives the differences between cumulativePayment and what was already paid-out to the beneficiary minus callerPayout @param cumulativePayout cumulative amount of cheques assigned to beneficiary @param issuerSig if issuer is not the sender, issuer must have given explicit approval on the cumulativePayout to the beneficiary */ function _cashChequeInternal( address beneficiary, address recipient, uint cumulativePayout, uint callerPayout, bytes memory issuerSig ) internal { /* The issuer must have given explicit approval to the cumulativePayout, either by being the caller or by signature*/ if (msg.sender != issuer) { require(issuer == recoverEIP712(chequeHash(address(this), beneficiary, cumulativePayout), issuerSig), "invalid issuer signature"); } /* the requestPayout is the amount requested for payment processing */ uint requestPayout = cumulativePayout.sub(paidOut[beneficiary]); /* calculates acutal payout */ uint totalPayout = Math.min(requestPayout, liquidBalanceFor(beneficiary)); /* calculates hard-deposit usage */ uint hardDepositUsage = Math.min(totalPayout, hardDeposits[beneficiary].amount); require(totalPayout >= callerPayout, "SimpleSwap: cannot pay caller"); /* if there are some of the hard deposit used, update hardDeposits*/ if (hardDepositUsage != 0) { hardDeposits[beneficiary].amount = hardDeposits[beneficiary].amount.sub(hardDepositUsage); totalHardDeposit = totalHardDeposit.sub(hardDepositUsage); } /* increase the stored paidOut amount to avoid double payout */ paidOut[beneficiary] = paidOut[beneficiary].add(totalPayout); totalPaidOut = totalPaidOut.add(totalPayout); /* let the world know that the issuer has over-promised on outstanding cheques */ if (requestPayout != totalPayout) { bounced = true; emit ChequeBounced(); } if (callerPayout != 0) { /* do a transfer to the caller if specified*/ require(token.transfer(msg.sender, callerPayout), "transfer failed"); /* do the actual payment */ require(token.transfer(recipient, totalPayout.sub(callerPayout)), "transfer failed"); } else { /* do the actual payment */ require(token.transfer(recipient, totalPayout), "transfer failed"); } emit ChequeCashed(beneficiary, recipient, msg.sender, totalPayout, cumulativePayout, callerPayout); } /** @notice cash a cheque of the beneficiary by a non-beneficiary and reward the sender for doing so with callerPayout @dev a beneficiary must be able to generate signatures (be an Externally Owned Account) to make use of this feature @param beneficiary the beneficiary to which cheques were assigned. Beneficiary must be an Externally Owned Account @param recipient receives the differences between cumulativePayment and what was already paid-out to the beneficiary minus callerPayout @param cumulativePayout cumulative amount of cheques assigned to beneficiary @param beneficiarySig beneficiary must have given explicit approval for cashing out the cumulativePayout by the sender and sending the callerPayout @param issuerSig if issuer is not the sender, issuer must have given explicit approval on the cumulativePayout to the beneficiary @param callerPayout when beneficiary does not have ether yet, he can incentivize other people to cash cheques with help of callerPayout @param issuerSig if issuer is not the sender, issuer must have given explicit approval on the cumulativePayout to the beneficiary */ function cashCheque( address beneficiary, address recipient, uint cumulativePayout, bytes memory beneficiarySig, uint256 callerPayout, bytes memory issuerSig ) public { require( beneficiary == recoverEIP712( cashOutHash( address(this), msg.sender, cumulativePayout, recipient, callerPayout ), beneficiarySig ), "invalid beneficiary signature"); _cashChequeInternal(beneficiary, recipient, cumulativePayout, callerPayout, issuerSig); } /** @notice cash a cheque as beneficiary @param recipient receives the differences between cumulativePayment and what was already paid-out to the beneficiary minus callerPayout @param cumulativePayout amount requested to pay out @param issuerSig issuer must have given explicit approval on the cumulativePayout to the beneficiary */ function cashChequeBeneficiary(address recipient, uint cumulativePayout, bytes memory issuerSig) public { _cashChequeInternal(msg.sender, recipient, cumulativePayout, 0, issuerSig); } /** @notice prepare to decrease the hard deposit @dev decreasing hardDeposits must be done in two steps to allow beneficiaries to cash any uncashed cheques (and make use of the assgined hard-deposits) @param beneficiary beneficiary whose hard deposit should be decreased @param decreaseAmount amount that the deposit is supposed to be decreased by */ function prepareDecreaseHardDeposit(address beneficiary, uint decreaseAmount) public { require(msg.sender == issuer, "SimpleSwap: not issuer"); HardDeposit storage hardDeposit = hardDeposits[beneficiary]; /* cannot decrease it by more than the deposit */ require(decreaseAmount <= hardDeposit.amount, "hard deposit not sufficient"); // if hardDeposit.timeout was never set, apply defaultHardDepositTimeout uint timeout = hardDeposit.timeout == 0 ? defaultHardDepositTimeout : hardDeposit.timeout; hardDeposit.canBeDecreasedAt = block.timestamp + timeout; hardDeposit.decreaseAmount = decreaseAmount; emit HardDepositDecreasePrepared(beneficiary, decreaseAmount); } /** @notice decrease the hard deposit after waiting the necesary amount of time since prepareDecreaseHardDeposit was called @param beneficiary beneficiary whose hard deposit should be decreased */ function decreaseHardDeposit(address beneficiary) public { HardDeposit storage hardDeposit = hardDeposits[beneficiary]; require(block.timestamp >= hardDeposit.canBeDecreasedAt && hardDeposit.canBeDecreasedAt != 0, "deposit not yet timed out"); /* this throws if decreaseAmount > amount */ //TODO: if there is a cash-out in between prepareDecreaseHardDeposit and decreaseHardDeposit, decreaseHardDeposit will throw and reducing hard-deposits is impossible. hardDeposit.amount = hardDeposit.amount.sub(hardDeposit.decreaseAmount); /* reset the canBeDecreasedAt to avoid a double decrease */ hardDeposit.canBeDecreasedAt = 0; /* keep totalDeposit in sync */ totalHardDeposit = totalHardDeposit.sub(hardDeposit.decreaseAmount); emit HardDepositAmountChanged(beneficiary, hardDeposit.amount); } /** @notice increase the hard deposit @param beneficiary beneficiary whose hard deposit should be decreased @param amount the new hard deposit */ function increaseHardDeposit(address beneficiary, uint amount) public { require(msg.sender == issuer, "SimpleSwap: not issuer"); /* ensure hard deposits don't exceed the global balance */ require(totalHardDeposit.add(amount) <= balance(), "hard deposit exceeds balance"); HardDeposit storage hardDeposit = hardDeposits[beneficiary]; hardDeposit.amount = hardDeposit.amount.add(amount); // we don't explicitely set hardDepositTimout, as zero means using defaultHardDepositTimeout totalHardDeposit = totalHardDeposit.add(amount); /* disable any pending decrease */ hardDeposit.canBeDecreasedAt = 0; emit HardDepositAmountChanged(beneficiary, hardDeposit.amount); } /** @notice allows for setting a custom hardDepositDecreaseTimeout per beneficiary @dev this is required when solvency must be guaranteed for a period longer than the defaultHardDepositDecreaseTimeout @param beneficiary beneficiary whose hard deposit decreaseTimeout must be changed @param hardDepositTimeout new hardDeposit.timeout for beneficiary @param beneficiarySig beneficiary must give explicit approval by giving his signature on the new decreaseTimeout */ function setCustomHardDepositTimeout( address beneficiary, uint hardDepositTimeout, bytes memory beneficiarySig ) public { require(msg.sender == issuer, "not issuer"); require( beneficiary == recoverEIP712(customDecreaseTimeoutHash(address(this), beneficiary, hardDepositTimeout), beneficiarySig), "invalid beneficiary signature" ); hardDeposits[beneficiary].timeout = hardDepositTimeout; emit HardDepositTimeoutChanged(beneficiary, hardDepositTimeout); } /// @notice withdraw ether /// @param amount amount to withdraw // solhint-disable-next-line no-simple-event-func-name function withdraw(uint amount) public { /* only issuer can do this */ require(msg.sender == issuer, "not issuer"); /* ensure we don't take anything from the hard deposit */ require(amount <= liquidBalance(), "liquidBalance not sufficient"); require(token.transfer(issuer, amount), "transfer failed"); } function chequeHash(address chequebook, address beneficiary, uint cumulativePayout) internal pure returns (bytes32) { return keccak256(abi.encode( CHEQUE_TYPEHASH, chequebook, beneficiary, cumulativePayout )); } function cashOutHash(address chequebook, address sender, uint requestPayout, address recipient, uint callerPayout) internal pure returns (bytes32) { return keccak256(abi.encode( CASHOUT_TYPEHASH, chequebook, sender, requestPayout, recipient, callerPayout )); } function customDecreaseTimeoutHash(address chequebook, address beneficiary, uint decreaseTimeout) internal pure returns (bytes32) { return keccak256(abi.encode( CUSTOMDECREASETIMEOUT_TYPEHASH, chequebook, beneficiary, decreaseTimeout )); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. * * _Available since v3.4._ */ library Clones { /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`. * * This function uses the create opcode, which should never revert. */ function clone(address master) internal returns (address instance) { // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, master)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create(0, ptr, 0x37) } require(instance != address(0), "ERC1167: create failed"); } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `master` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) { // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, master)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create2(0, ptr, 0x37, salt) } require(instance != address(0), "ERC1167: create2 failed"); } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address master, bytes32 salt, address deployer) internal pure returns (address predicted) { // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, master)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000) mstore(add(ptr, 0x38), shl(0x60, deployer)) mstore(add(ptr, 0x4c), salt) mstore(add(ptr, 0x6c), keccak256(ptr, 0x37)) predicted := keccak256(add(ptr, 0x37), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address master, bytes32 salt) internal view returns (address predicted) { return predictDeterministicAddress(master, salt, address(this)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { revert("ECDSA: invalid signature length"); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return recover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover-bytes32-bytes-} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value"); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value"); // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * replicates the behavior of the * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`] * JSON-RPC method. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../access/AccessControl.sol"; import "../utils/Context.sol"; import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20Burnable.sol"; import "../token/ERC20/ERC20Pausable.sol"; /** * @dev {ERC20} token, including: * * - ability for holders to burn (destroy) their tokens * - a minter role that allows for token minting (creation) * - a pauser role that allows to stop all token transfers * * This contract uses {AccessControl} to lock permissioned functions using the * different roles - head to its documentation for details. * * The account that deploys the contract will be granted the minter and pauser * roles, as well as the default admin role, which will let it grant both minter * and pauser roles to other accounts. */ contract ERC20PresetMinterPauser is Context, AccessControl, ERC20Burnable, ERC20Pausable { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); /** * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the * account that deploys the contract. * * See {ERC20-constructor}. */ constructor(string memory name, string memory symbol) public ERC20(name, symbol) { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender()); } /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `MINTER_ROLE`. */ function mint(address to, uint256 amount) public virtual { require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint"); _mint(to, amount); } /** * @dev Pauses all token transfers. * * See {ERC20Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function pause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to pause"); _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC20Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function unpause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to unpause"); _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) { super._beforeTokenTransfer(from, to, amount); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @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 GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: 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 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/EnumerableSet.sol"; import "../utils/Address.sol"; import "../utils/Context.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context { using EnumerableSet for EnumerableSet.AddressSet; using Address for address; struct RoleData { EnumerableSet.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view returns (bool) { return _roles[role].members.contains(account); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view returns (address) { return _roles[role].members.at(index); } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./ERC20.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { using SafeMath for uint256; /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./ERC20.sol"; import "../../utils/Pausable.sol"; /** * @dev ERC20 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. */ abstract contract ERC20Pausable is ERC20, Pausable { /** * @dev See {ERC20-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); require(!paused(), "ERC20Pausable: token transfer while paused"); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor () internal { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"_ERC20Address","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"contractAddress","type":"address"}],"name":"SimpleSwapDeployed","type":"event"},{"inputs":[],"name":"ERC20Address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"issuer","type":"address"},{"internalType":"uint256","name":"defaultHardDepositTimeoutDuration","type":"uint256"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"name":"deploySimpleSwap","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"deployedContracts","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"master","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50604051611df2380380611df283398101604081905261002f91610112565b600180546001600160a01b0319166001600160a01b03831617905560405160009061005990610105565b604051809103906000f080158015610075573d6000803e3d6000fd5b506040516343431f6360e11b81529091506001600160a01b038216906386863ec6906100ab906001906000908190600401610140565b600060405180830381600087803b1580156100c557600080fd5b505af11580156100d9573d6000803e3d6000fd5b5050600280546001600160a01b0319166001600160a01b03949094169390931790925550610164915050565b6118e58061050d83390190565b600060208284031215610123578081fd5b81516001600160a01b0381168114610139578182fd5b9392505050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b61039a806101736000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806315efd8a714610051578063a6021ace1461007a578063c70242ad14610082578063ee97f7f3146100a2575b600080fd5b61006461005f3660046102d6565b6100aa565b6040516100719190610308565b60405180910390f35b6100646101bb565b6100956100903660046102b5565b6101ca565b6040516100719190610359565b6100646101df565b60025460405160009182916100ee916001600160a01b0316906100d3903390879060200161031c565b604051602081830303815290604052805190602001206101ee565b6001546040516343431f6360e11b81529192506001600160a01b03808416926386863ec692610126928a929116908990600401610335565b600060405180830381600087803b15801561014057600080fd5b505af1158015610154573d6000803e3d6000fd5b5050506001600160a01b03821660009081526020819052604090819020805460ff19166001179055517fc0ffc525a1c7689549d7f79b49eca900e61ac49b43d977f680bcc3b36224c00491506101ab908390610308565b60405180910390a1949350505050565b6001546001600160a01b031681565b60006020819052908152604090205460ff1681565b6002546001600160a01b031681565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528360601b60148201526e5af43d82803e903d91602b57fd5bf360881b6028820152826037826000f59150506001600160a01b038116610293576040805162461bcd60e51b815260206004820152601760248201527f455243313136373a2063726561746532206661696c6564000000000000000000604482015290519081900360640190fd5b92915050565b80356001600160a01b03811681146102b057600080fd5b919050565b6000602082840312156102c6578081fd5b6102cf82610299565b9392505050565b6000806000606084860312156102ea578182fd5b6102f384610299565b95602085013595506040909401359392505050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b90151581526020019056fea2646970667358221220b260612b64b2388a58a0d557b99cc9121129d7c5aaa1c649d70eac8f0870b29c64736f6c63430007060033608060405234801561001057600080fd5b506118c5806100206000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c8063946f46a2116100c3578063b7ec1a331161007c578063b7ec1a331461027f578063c49f91d314610287578063c76a4d311461028f578063d4c9a8e8146102a2578063e0bcf13a146102b5578063fc0c546a146102bd5761014d565b8063946f46a214610211578063b6343b0d14610224578063b648b41714610247578063b69ef8a81461025c578063b777035014610264578063b7998907146102775761014d565b80631d143848116101155780631d143848146101a85780632e1a7d4d146101bd578063338f3fed146101d0578063488b017c146101e357806381f03fcb146101eb57806386863ec6146101fe5761014d565b80630d5f26591461015257806312101021146101675780631357e1dc1461018557806315c3343f1461018d5780631633fb1d14610195575b600080fd5b61016561016036600461146b565b6102c5565b005b61016f6102d8565b60405161017c9190611563565b60405180910390f35b61016f6102de565b61016f6102e4565b6101656101a33660046113ae565b610308565b6101b061036c565b60405161017c919061152b565b6101656101cb3660046114e0565b61037b565b6101656101de366004611442565b610473565b61016f610556565b61016f6101f9366004611359565b61057a565b61016561020c366004611373565b61058c565b61016561021f366004611359565b610610565b610237610232366004611359565b6106d0565b60405161017c94939291906115c7565b61024f6106f7565b60405161017c9190611558565b61016f610707565b610165610272366004611442565b61078d565b61016f610867565b61016f61088b565b61016f6108a1565b61016f61029d366004611359565b6108c5565b6101656102b036600461146b565b6108f8565b61016f6109b4565b6101b06109ba565b6102d33384846000856109c9565b505050565b60005481565b60035481565b7f48ebe6deff4a5ee645c01506a026031e2a945d6f41f1f4e5098ad65347492c1281565b61031e6103183033878987610dd2565b84610e30565b6001600160a01b0316866001600160a01b0316146103575760405162461bcd60e51b815260040161034e906117d5565b60405180910390fd5b61036486868685856109c9565b505050505050565b6006546001600160a01b031681565b6006546001600160a01b031633146103a55760405162461bcd60e51b815260040161034e906115e2565b6103ad61088b565b8111156103cc5760405162461bcd60e51b815260040161034e90611695565b60015460065460405163a9059cbb60e01b81526001600160a01b039283169263a9059cbb9261040292911690859060040161153f565b602060405180830381600087803b15801561041c57600080fd5b505af1158015610430573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045491906114c0565b6104705760405162461bcd60e51b815260040161034e9061180c565b50565b6006546001600160a01b0316331461049d5760405162461bcd60e51b815260040161034e90611665565b6104a5610707565b6005546104b29083610e7f565b11156104d05760405162461bcd60e51b815260040161034e90611730565b6001600160a01b038216600090815260046020526040902080546104f49083610e7f565b81556005546105039083610e7f565b6005556000600382015580546040516001600160a01b038516917f2506c43272ded05d095b91dbba876e66e46888157d3e078db5691496e96c5fad916105499190611563565b60405180910390a2505050565b7f7d824962dd0f01520922ea1766c987b1db570cd5db90bdba5ccf5e320607950281565b60026020526000908152604090205481565b6001600160a01b0383166105b25760405162461bcd60e51b815260040161034e9061163d565b6006546001600160a01b0316156105db5760405162461bcd60e51b815260040161034e906116cc565b600680546001600160a01b039485166001600160a01b0319918216179091556001805493909416921691909117909155600055565b6001600160a01b03811660009081526004602052604090206003810154421080159061063f5750600381015415155b61065b5760405162461bcd60e51b815260040161034e90611606565b6001810154815461066b91610ee0565b815560006003820155600181015460055461068591610ee0565b60055580546040516001600160a01b038416917f2506c43272ded05d095b91dbba876e66e46888157d3e078db5691496e96c5fad916106c49190611563565b60405180910390a25050565b60046020526000908152604090208054600182015460028301546003909301549192909184565b600654600160a01b900460ff1681565b6001546040516370a0823160e01b81526000916001600160a01b0316906370a082319061073890309060040161152b565b60206040518083038186803b15801561075057600080fd5b505afa158015610764573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078891906114f8565b905090565b6006546001600160a01b031633146107b75760405162461bcd60e51b815260040161034e90611665565b6001600160a01b038216600090815260046020526040902080548211156107f05760405162461bcd60e51b815260040161034e906116f9565b6000816002015460001461080857816002015461080c565b6000545b4281016003840155600183018490556040519091506001600160a01b038516907fc8305077b495025ec4c1d977b176a762c350bb18cad4666ce1ee85c32b78698a90610859908690611563565b60405180910390a250505050565b7fe95f353750f192082df064ca5142d3a2d6f0bef0f3ffad66d80d8af86b7a749a81565b600061078860055461089b610707565b90610ee0565b7fc2f8787176b8ac6bf7215b4adcc1e069bf4ab82d9ab1df05a57a91d425935b6e81565b6001600160a01b0381166000908152600460205260408120546108f0906108ea61088b565b90610e7f565b90505b919050565b6006546001600160a01b031633146109225760405162461bcd60e51b815260040161034e906115e2565b610936610930308585610f3d565b82610e30565b6001600160a01b0316836001600160a01b0316146109665760405162461bcd60e51b815260040161034e906117d5565b6001600160a01b03831660008181526004602052604090819020600201849055517f7b816003a769eb718bd9c66bdbd2dd5827da3f92bc6645276876bd7957b08cf090610549908590611563565b60055481565b6001546001600160a01b031681565b6006546001600160a01b03163314610a16576109e9610930308786610f95565b6006546001600160a01b03908116911614610a165760405162461bcd60e51b815260040161034e9061179e565b6001600160a01b038516600090815260026020526040812054610a3a908590610ee0565b90506000610a5082610a4b896108c5565b610fce565b6001600160a01b03881660009081526004602052604081205491925090610a78908390610fce565b905084821015610a9a5760405162461bcd60e51b815260040161034e90611767565b8015610aed576001600160a01b038816600090815260046020526040902054610ac39082610ee0565b6001600160a01b038916600090815260046020526040902055600554610ae99082610ee0565b6005555b6001600160a01b038816600090815260026020526040902054610b109083610e7f565b6001600160a01b038916600090815260026020526040902055600354610b369083610e7f565b600355828214610b7d576006805460ff60a01b1916600160a01b1790556040517f3f4449c047e11092ec54dc0751b6b4817a9162745de856c893a26e611d18ffc490600090a15b8415610ccf5760015460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb90610bb5903390899060040161153f565b602060405180830381600087803b158015610bcf57600080fd5b505af1158015610be3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0791906114c0565b610c235760405162461bcd60e51b815260040161034e9061180c565b6001546001600160a01b031663a9059cbb88610c3f8589610ee0565b6040518363ffffffff1660e01b8152600401610c5c92919061153f565b602060405180830381600087803b158015610c7657600080fd5b505af1158015610c8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cae91906114c0565b610cca5760405162461bcd60e51b815260040161034e9061180c565b610d6f565b60015460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb90610d01908a90869060040161153f565b602060405180830381600087803b158015610d1b57600080fd5b505af1158015610d2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5391906114c0565b610d6f5760405162461bcd60e51b815260040161034e9061180c565b336001600160a01b0316876001600160a01b0316896001600160a01b03167f950494fc3642fae5221b6c32e0e45765c95ebb382a04a71b160db0843e74c99f858a8a604051610dc093929190611835565b60405180910390a45050505050505050565b60007f7d824962dd0f01520922ea1766c987b1db570cd5db90bdba5ccf5e32060795028686868686604051602001610e0f96959493929190611591565b60405160208183030381529060405280519060200120905095945050505050565b600080610e43610e3e610fe4565b61103e565b84604051602001610e55929190611510565b604051602081830303815290604052805190602001209050610e7781846110ae565b949350505050565b600082820183811015610ed9576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b600082821115610f37576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60007fe95f353750f192082df064ca5142d3a2d6f0bef0f3ffad66d80d8af86b7a749a848484604051602001610f76949392919061156c565b6040516020818303038152906040528051906020012090509392505050565b60007f48ebe6deff4a5ee645c01506a026031e2a945d6f41f1f4e5098ad65347492c12848484604051602001610f76949392919061156c565b6000818310610fdd5781610ed9565b5090919050565b610fec6112ac565b506040805160a081018252600a6060820190815269436865717565626f6f6b60b01b608083015281528151808301835260038152620312e360ec1b602082810191909152820152469181019190915290565b60007fc2f8787176b8ac6bf7215b4adcc1e069bf4ab82d9ab1df05a57a91d425935b6e826000015180519060200120836020015180519060200120846040015160405160200161109194939291906115c7565b604051602081830303815290604052805190602001209050919050565b60008151604114611106576040805162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015290519081900360640190fd5b60208201516040830151606084015160001a6111248682858561112e565b9695505050505050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a082111561118f5760405162461bcd60e51b815260040180806020018281038252602281526020018061184c6022913960400191505060405180910390fd5b8360ff16601b14806111a457508360ff16601c145b6111df5760405162461bcd60e51b815260040180806020018281038252602281526020018061186e6022913960400191505060405180910390fd5b600060018686868660405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa15801561123b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166112a3576040805162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015290519081900360640190fd5b95945050505050565b60405180606001604052806060815260200160608152602001600081525090565b80356001600160a01b03811681146108f357600080fd5b600082601f8301126112f4578081fd5b813567ffffffffffffffff8082111561130957fe5b604051601f8301601f19168101602001828111828210171561132757fe5b60405282815284830160200186101561133e578384fd5b82602086016020830137918201602001929092529392505050565b60006020828403121561136a578081fd5b610ed9826112cd565b600080600060608486031215611387578182fd5b611390846112cd565b925061139e602085016112cd565b9150604084013590509250925092565b60008060008060008060c087890312156113c6578182fd5b6113cf876112cd565b95506113dd602088016112cd565b945060408701359350606087013567ffffffffffffffff80821115611400578384fd5b61140c8a838b016112e4565b94506080890135935060a0890135915080821115611428578283fd5b5061143589828a016112e4565b9150509295509295509295565b60008060408385031215611454578182fd5b61145d836112cd565b946020939093013593505050565b60008060006060848603121561147f578283fd5b611488846112cd565b925060208401359150604084013567ffffffffffffffff8111156114aa578182fd5b6114b6868287016112e4565b9150509250925092565b6000602082840312156114d1578081fd5b81518015158114610ed9578182fd5b6000602082840312156114f1578081fd5b5035919050565b600060208284031215611509578081fd5b5051919050565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b90815260200190565b9384526001600160a01b03928316602085015291166040830152606082015260800190565b9586526001600160a01b03948516602087015292841660408601526060850191909152909116608083015260a082015260c00190565b93845260208401929092526040830152606082015260800190565b6020808252600a90820152693737ba1034b9b9bab2b960b11b604082015260600190565b60208082526019908201527f6465706f736974206e6f74207965742074696d6564206f757400000000000000604082015260600190565b6020808252600e908201526d34b73b30b634b21034b9b9bab2b960911b604082015260600190565b60208082526016908201527529b4b6b83632a9bbb0b81d103737ba1034b9b9bab2b960511b604082015260600190565b6020808252601c908201527f6c697175696442616c616e6365206e6f742073756666696369656e7400000000604082015260600190565b602080825260139082015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b604082015260600190565b6020808252601b908201527f68617264206465706f736974206e6f742073756666696369656e740000000000604082015260600190565b6020808252601c908201527f68617264206465706f73697420657863656564732062616c616e636500000000604082015260600190565b6020808252601d908201527f53696d706c65537761703a2063616e6e6f74207061792063616c6c6572000000604082015260600190565b60208082526018908201527f696e76616c696420697373756572207369676e61747572650000000000000000604082015260600190565b6020808252601d908201527f696e76616c69642062656e6566696369617279207369676e6174757265000000604082015260600190565b6020808252600f908201526e1d1c985b9cd9995c8819985a5b1959608a1b604082015260600190565b928352602083019190915260408201526060019056fe45434453413a20696e76616c6964207369676e6174757265202773272076616c756545434453413a20696e76616c6964207369676e6174757265202776272076616c7565a2646970667358221220b270820590249f6db00f7142812273c92ea84cea0862f4083a5c75edd08f437264736f6c63430007060033000000000000000000000000543ddb01ba47acb11de34891cd86b675f04840db
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806315efd8a714610051578063a6021ace1461007a578063c70242ad14610082578063ee97f7f3146100a2575b600080fd5b61006461005f3660046102d6565b6100aa565b6040516100719190610308565b60405180910390f35b6100646101bb565b6100956100903660046102b5565b6101ca565b6040516100719190610359565b6100646101df565b60025460405160009182916100ee916001600160a01b0316906100d3903390879060200161031c565b604051602081830303815290604052805190602001206101ee565b6001546040516343431f6360e11b81529192506001600160a01b03808416926386863ec692610126928a929116908990600401610335565b600060405180830381600087803b15801561014057600080fd5b505af1158015610154573d6000803e3d6000fd5b5050506001600160a01b03821660009081526020819052604090819020805460ff19166001179055517fc0ffc525a1c7689549d7f79b49eca900e61ac49b43d977f680bcc3b36224c00491506101ab908390610308565b60405180910390a1949350505050565b6001546001600160a01b031681565b60006020819052908152604090205460ff1681565b6002546001600160a01b031681565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528360601b60148201526e5af43d82803e903d91602b57fd5bf360881b6028820152826037826000f59150506001600160a01b038116610293576040805162461bcd60e51b815260206004820152601760248201527f455243313136373a2063726561746532206661696c6564000000000000000000604482015290519081900360640190fd5b92915050565b80356001600160a01b03811681146102b057600080fd5b919050565b6000602082840312156102c6578081fd5b6102cf82610299565b9392505050565b6000806000606084860312156102ea578182fd5b6102f384610299565b95602085013595506040909401359392505050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b90151581526020019056fea2646970667358221220b260612b64b2388a58a0d557b99cc9121129d7c5aaa1c649d70eac8f0870b29c64736f6c63430007060033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000543ddb01ba47acb11de34891cd86b675f04840db
-----Decoded View---------------
Arg [0] : _ERC20Address (address): 0x543dDb01Ba47acB11de34891cD86B675F04840db
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000543ddb01ba47acb11de34891cd86b675f04840db
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.