contract_name
stringlengths
1
61
file_path
stringlengths
5
50.4k
contract_address
stringlengths
42
42
language
stringclasses
1 value
class_name
stringlengths
1
61
class_code
stringlengths
4
330k
class_documentation
stringlengths
0
29.1k
class_documentation_type
stringclasses
6 values
func_name
stringlengths
0
62
func_code
stringlengths
1
303k
func_documentation
stringlengths
2
14.9k
func_documentation_type
stringclasses
4 values
compiler_version
stringlengths
15
42
license_type
stringclasses
14 values
swarm_source
stringlengths
0
71
meta
dict
__index_level_0__
int64
0
60.4k
TokenERC20
TokenERC20.sol
0x1c3c649566115e0f306118dcbb3077000dfce046
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
transfer
function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; }
/** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://d8d5bb5673af2efbe50fca5a5c1f6fc159300cf33174fb2ce32840944f9e0896
{ "func_code_index": [ 2693, 2850 ] }
55,761
TokenERC20
TokenERC20.sol
0x1c3c649566115e0f306118dcbb3077000dfce046
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; }
/** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://d8d5bb5673af2efbe50fca5a5c1f6fc159300cf33174fb2ce32840944f9e0896
{ "func_code_index": [ 3125, 3426 ] }
55,762
TokenERC20
TokenERC20.sol
0x1c3c649566115e0f306118dcbb3077000dfce046
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
approve
function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; }
/** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://d8d5bb5673af2efbe50fca5a5c1f6fc159300cf33174fb2ce32840944f9e0896
{ "func_code_index": [ 3690, 3915 ] }
55,763
TokenERC20
TokenERC20.sol
0x1c3c649566115e0f306118dcbb3077000dfce046
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
approveAndCall
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } }
/** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://d8d5bb5673af2efbe50fca5a5c1f6fc159300cf33174fb2ce32840944f9e0896
{ "func_code_index": [ 4309, 4661 ] }
55,764
TokenERC20
TokenERC20.sol
0x1c3c649566115e0f306118dcbb3077000dfce046
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
burn
function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; }
/** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://d8d5bb5673af2efbe50fca5a5c1f6fc159300cf33174fb2ce32840944f9e0896
{ "func_code_index": [ 4831, 5205 ] }
55,765
TokenERC20
TokenERC20.sol
0x1c3c649566115e0f306118dcbb3077000dfce046
Solidity
TokenERC20
contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
burnFrom
function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; }
/** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://d8d5bb5673af2efbe50fca5a5c1f6fc159300cf33174fb2ce32840944f9e0896
{ "func_code_index": [ 5463, 6074 ] }
55,766
AWG
contracts/token/Feeless.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
Feeless
contract Feeless { /** * @dev The replacement for msg.sender on functions that use the feeless modifier. */ address internal msgSender; /** * @dev Mimics the blockchain nonce relative to this contract (or contract that extents). */ mapping(address => uint256) public nonces; /** * @dev Holds reference to the initial signer of the transaction in the msgSender variable. * @dev After execution the variable is reset. */ modifier feeless() { if (msgSender == address(0)) { msgSender = msg.sender; _; msgSender = address(0); } else { _; } } struct CallResult { bool success; bytes payload; } /// @notice Only the certSign owner can call this function. /// @dev Signed transactions are passed to this function. function performFeelessTransaction( address sender, address target, bytes memory data, uint256 nonce, bytes memory sig) public payable { require(address(this) == target, "Feeless: Target should be the extended contract"); bytes memory prefix = "\x19Ethereum Signed Message:\n32"; bytes32 hash = keccak256(abi.encodePacked(prefix, keccak256(abi.encodePacked(target, data, nonce)))); msgSender = ECRecovery.recover(hash, sig); require(msgSender == sender, "Feeless: Unexpected sender"); require(nonces[msgSender]++ == nonce, "Feeless: nonce does not comply"); (bool _success, bytes memory _payload) = target.call.value(msg.value)(data); CallResult memory callResult = CallResult(_success, _payload); require(callResult.success, "Feeless: Call failed"); msgSender = address(0); } }
/** * @title Feeless * @dev Usage: Used as an extension in contracts that want to execute feeless functions. * @dev Usage: Apply the feeless modifier. * @dev Based on https://github.com/bitclave/Feeless */
NatSpecMultiLine
performFeelessTransaction
function performFeelessTransaction( address sender, address target, bytes memory data, uint256 nonce, bytes memory sig) public payable { require(address(this) == target, "Feeless: Target should be the extended contract"); bytes memory prefix = "\x19Ethereum Signed Message:\n32"; bytes32 hash = keccak256(abi.encodePacked(prefix, keccak256(abi.encodePacked(target, data, nonce)))); msgSender = ECRecovery.recover(hash, sig); require(msgSender == sender, "Feeless: Unexpected sender"); require(nonces[msgSender]++ == nonce, "Feeless: nonce does not comply"); (bool _success, bytes memory _payload) = target.call.value(msg.value)(data); CallResult memory callResult = CallResult(_success, _payload); require(callResult.success, "Feeless: Call failed"); msgSender = address(0); }
/// @notice Only the certSign owner can call this function. /// @dev Signed transactions are passed to this function.
NatSpecSingleLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 915, 1846 ] }
55,767
game_3733
game_3733.sol
0xcc426a7d0883bdad1cd41798dda1d3a8b7c26385
Solidity
game_3733
contract game_3733 { string public standard = 'https://3733.net.cn'; string public name="game link of 3733 1.0"; string public symbol="3733"; uint8 public decimals = 18; uint256 public totalSupply=6000000000 ether; address payable s_owner; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; struct USER_DATE { uint8 flags; uint256 feng_hong_timer; } mapping(address => USER_DATE)public s_user; uint32 s_index=2; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); event Transfer_2(address from,address to ,uint256 value,uint256 from_p,uint256 to_p);//转账通知挖矿事件 event ev_feng_hong(address ad,uint256 value); event ev_delete_bws(address ad,uint256 value); event ev_get_tang_guo(address ad); event ev_shi_mu(address ad,uint256 eth_value,uint256 bws_value); uint256 public tang_guo =3000000 ether; uint256 public shi_mu =50000000 ether; uint256 public wa_kuang =300000000 ether; uint256 public fen_hong =150000000 ether; uint256 public game_fang =50000000 ether; uint256 public xiao_hui_bws=500000000 ether; constructor ()public { s_owner=msg.sender; balanceOf[s_owner]=47000000 ether; s_user[s_owner].flags=1; } function()external payable { if(msg.value==0) { if(s_user[msg.sender].flags==1) { uint256 t=now; if(t-s_user[msg.sender].feng_hong_timer>2592000) { s_user[msg.sender].feng_hong_timer=t; uint256 f=balanceOf[msg.sender]/100000000; f=balanceOf[msg.sender]/(1 ether) *f; if(f>10000 ether)f=10000 ether; if(fen_hong>=f) { fen_hong-=f; balanceOf[msg.sender]+=f; emit ev_feng_hong(msg.sender,f); } } } if(tang_guo>=(300 ether) && (s_user[msg.sender].flags==0)) { s_user[msg.sender].flags=1; tang_guo-=300 ether; balanceOf[msg.sender]=300 ether; emit ev_get_tang_guo(msg.sender); } } else if(msg.value>=0.01 ether) { assert(shi_mu>=msg.value*100000); shi_mu-=msg.value*100000; uint256 last=balanceOf[msg.sender]; balanceOf[msg.sender]+=msg.value*100000; assert(last< balanceOf[msg.sender]); emit ev_shi_mu(msg.sender,msg.value,msg.value*100000); } } function _transfer(address _from, address _to, uint256 _value) internal { require(_to != address(0x0)); require(s_user[_from].flags!=2 && s_user[_from].flags!=3); require(s_user[_to].flags!=3); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint256 p=(_value/100000000)*(balanceOf[_from]/(1 ether)); if(p>_value/10)p=_value/10; if(wa_kuang<p/100*5)p=0; uint previousBalances = balanceOf[_from] + balanceOf[_to]+p/100*105; balanceOf[_from] -= (_value-p); wa_kuang-=p/100*105; balanceOf[_to] += (_value+p/100*5); emit Transfer(_from, _to, _value); emit Transfer_2(_from,_to ,_value,p,p/100*5); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){ require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function set_gamer(address ad,uint8 value)public { require(ad!=address(0x0)); require(msg.sender==s_owner); s_user[ad].flags=value; } function delete_bws(uint256 value)public { require (balanceOf[msg.sender]>=value); require (xiao_hui_bws >= value); balanceOf[msg.sender]-=value; xiao_hui_bws-=value; emit ev_delete_bws(msg.sender,value); } function safe_add(uint256 value1,uint256 value2)internal pure returns(uint256) { uint256 ret=value2+value1; assert(ret>=value1); return ret; } function safe_sub(uint256 value1,uint256 value2)internal pure returns(uint256) { uint256 ret=value1-value2; assert(ret<=value1); return ret; } //bws获取 function get_bws(uint8 flags,uint256 value) public { require(msg.sender==s_owner); if(flags==1) { tang_guo=safe_sub(tang_guo,value); balanceOf[msg.sender]=safe_add(balanceOf[msg.sender],value); } else if(flags==2) { balanceOf[msg.sender]=safe_sub(balanceOf[msg.sender],value); tang_guo=safe_add(tang_guo,value); } else if(flags==3) { tang_guo=safe_sub(shi_mu,value); balanceOf[msg.sender]=safe_add(balanceOf[msg.sender],value); } else if(flags==4) { balanceOf[msg.sender]=safe_sub(balanceOf[msg.sender],value); tang_guo=safe_add(shi_mu,value); } else if(flags==5) { tang_guo=safe_sub(wa_kuang,value); balanceOf[msg.sender]=safe_add(balanceOf[msg.sender],value); } else if(flags==6) { balanceOf[msg.sender]=safe_sub(balanceOf[msg.sender],value); tang_guo=safe_add(wa_kuang,value); } else if(flags==7) { tang_guo=safe_sub(fen_hong,value); balanceOf[msg.sender]=safe_add(balanceOf[msg.sender],value); } else if(flags==8) { balanceOf[msg.sender]=safe_sub(balanceOf[msg.sender],value); tang_guo=safe_add(fen_hong,value); } else if(flags==9) { tang_guo=safe_sub(game_fang,value); balanceOf[msg.sender]=safe_add(balanceOf[msg.sender],value); } else if(flags==10) { balanceOf[msg.sender]=safe_sub(balanceOf[msg.sender],value); tang_guo=safe_add(game_fang,value); } } function get_eth() public { uint256 balance=address(this).balance; s_owner.transfer(balance); } }
get_bws
function get_bws(uint8 flags,uint256 value) public { require(msg.sender==s_owner); if(flags==1) { tang_guo=safe_sub(tang_guo,value); balanceOf[msg.sender]=safe_add(balanceOf[msg.sender],value); } else if(flags==2) { balanceOf[msg.sender]=safe_sub(balanceOf[msg.sender],value); tang_guo=safe_add(tang_guo,value); } else if(flags==3) { tang_guo=safe_sub(shi_mu,value); balanceOf[msg.sender]=safe_add(balanceOf[msg.sender],value); } else if(flags==4) { balanceOf[msg.sender]=safe_sub(balanceOf[msg.sender],value); tang_guo=safe_add(shi_mu,value); } else if(flags==5) { tang_guo=safe_sub(wa_kuang,value); balanceOf[msg.sender]=safe_add(balanceOf[msg.sender],value); } else if(flags==6) { balanceOf[msg.sender]=safe_sub(balanceOf[msg.sender],value); tang_guo=safe_add(wa_kuang,value); } else if(flags==7) { tang_guo=safe_sub(fen_hong,value); balanceOf[msg.sender]=safe_add(balanceOf[msg.sender],value); } else if(flags==8) { balanceOf[msg.sender]=safe_sub(balanceOf[msg.sender],value); tang_guo=safe_add(fen_hong,value); } else if(flags==9) { tang_guo=safe_sub(game_fang,value); balanceOf[msg.sender]=safe_add(balanceOf[msg.sender],value); } else if(flags==10) { balanceOf[msg.sender]=safe_sub(balanceOf[msg.sender],value); tang_guo=safe_add(game_fang,value); } }
//bws获取
LineComment
v0.5.1+commit.c8a2cb62
None
bzzr://3feac3ae738110e446d747bb55b04d18417e0cd227a0bbfcd721ff84159572a7
{ "func_code_index": [ 5231, 7053 ] }
55,768
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
stopMigration
function stopMigration() public onlyOwner { _migrationOpen = false; }
/** * @dev Stop migration by setting flag. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 985, 1073 ] }
55,769
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
migrateBalances
function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } }
/** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 1377, 1667 ] }
55,770
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
forceTransfer
function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); }
/** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 1771, 1952 ] }
55,771
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
whitelistAddress
function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; }
/** * @dev Set the whitelisting level for an account. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 2029, 2217 ] }
55,772
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
setFees
function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; }
/** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 2370, 2797 ] }
55,773
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
setFeeManager
function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; }
/** * @dev Set the address where the fees are forwarded. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 2877, 3102 ] }
55,774
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
retrieveStorageFee
function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); }
/** * @dev Function called by the owner to force an account to pay storage fee to date. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 3213, 3329 ] }
55,775
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
resetStorageFees
function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } }
/** * @dev Function called by the owner to reset storage fees for selected accounts. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 3437, 3632 ] }
55,776
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
addMinter
function addMinter(address account) external onlyOwner { _addMinter(account); }
/** * @dev See `MinterRole._addMinter`. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 3695, 3793 ] }
55,777
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
removeMinter
function removeMinter(address account) external onlyOwner { _removeMinter(account); }
/** * @dev See `MinterRole._removeMinter`. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 3859, 3963 ] }
55,778
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
addBurner
function addBurner(address account) external onlyOwner { _addBurner(account); }
/** * @dev See `BurnerRole._addBurner`. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 4026, 4124 ] }
55,779
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
removeBurner
function removeBurner(address account) external onlyOwner { _removeBurner(account); }
/** * @dev See `BurnerRole._removeBurner`. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 4190, 4294 ] }
55,780
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
burn
function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); }
/** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 4402, 4501 ] }
55,781
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
mint
function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); }
/** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 4609, 4722 ] }
55,782
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
transferFeeless
function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); }
/** * @notice Feeless ERC20 transfer. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 4783, 4978 ] }
55,783
AWG
contracts/token/AWG.sol
0x696acc2de564b48682d71d0847b3632f87c9a402
Solidity
AWG
contract AWG is ERC20StorageFee, MinterRole, BurnerRole, Ownable, Feeless, IToken { /** * @dev Fired when a feeless transfer has been executed. */ event TransferFeeless(address indexed account, uint256 indexed value); /** * @dev Fired when a feeless approve has been executed. */ event ApproveFeeless(address indexed spender, uint256 indexed value); /** * @notice ERC20 convention. */ uint8 public constant decimals = 18; /** * @notice ERC20 convention. */ string public constant name = "AurusGOLD"; /** * @notice ERC20 convention. */ string public constant symbol = "AWG"; /** * @dev Flag to indicate that the migration from old token has stopped. */ bool private _migrationOpen = true; constructor() public { feeStartTimestamp = block.timestamp; } /** * @dev Stop migration by setting flag. */ function stopMigration() public onlyOwner { _migrationOpen = false; } /** * @dev Check if migration is open. */ modifier whenMigration() { require(_migrationOpen, "Migration: stopped"); _; } /** * @dev Migrate balance from old token when migration is open, and both the old and the new token are paused. */ function migrateBalances(address[] calldata _accounts) external whenPaused whenMigration onlyOwner { require(AWG(oldAWGContract).paused(), "Pausable: not paused"); for (uint i=0; i<_accounts.length; i++) { _migrateBalance(_accounts[i]); } } /** * @dev Force a transfer between 2 accounts. AML logs on https://aurus.io/aml */ function forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) external onlyOwner { _forceTransfer(sender,recipient,amount,details); } /** * @dev Set the whitelisting level for an account. */ function whitelistAddress(address account, uint8 level) external onlyOwner { require(level<=3, "Level: Please use level 0 to 3."); whitelist[account] = level; } /** * @dev Set the fees in the system. All the fees are in mpip, except fixedTransferFee that is in wei. Level is between 0 and 2 */ function setFees(uint256 _dailyStorageFee, uint256 _fixedTransferFee, uint256 _dynamicTransferFee, uint256 _mintingFee, uint8 level) external onlyOwner { require(level<=2, "Level: Please use level 0 to 2."); dailyStorageFee[level] = _dailyStorageFee; fixedTransferFee[level] = _fixedTransferFee; dynamicTransferFee[level] = _dynamicTransferFee; mintingFee = _mintingFee; } /** * @dev Set the address where the fees are forwarded. */ function setFeeManager(address account) external onlyOwner { (bool success, ) = feeManager.call(abi.encodeWithSignature("processFee(uint256)",0)); require(success); feeManager = account; } /** * @dev Function called by the owner to force an account to pay storage fee to date. */ function retrieveStorageFee(address account) external onlyOwner { _retrieveStorageFee(account); } /** * @dev Function called by the owner to reset storage fees for selected accounts. */ function resetStorageFees(address[] calldata _accounts) external onlyOwner { for (uint i=0; i<_accounts.length; i++) { _resetStorageFee(_accounts[i]); } } /** * @dev See `MinterRole._addMinter`. */ function addMinter(address account) external onlyOwner { _addMinter(account); } /** * @dev See `MinterRole._removeMinter`. */ function removeMinter(address account) external onlyOwner { _removeMinter(account); } /** * @dev See `BurnerRole._addBurner`. */ function addBurner(address account) external onlyOwner { _addBurner(account); } /** * @dev See `BurnerRole._removeBurner`. */ function removeBurner(address account) external onlyOwner { _removeBurner(account); } /** * @notice The caller must have the `BurnerRole`. * @dev See `ERC20._burn`. */ function burn(uint256 amount) external onlyBurner { _burn(msg.sender, amount); } /** * @notice The caller must have the `MinterRole`. * @dev See `ERC20._mint`. */ function mint(address account, uint256 amount) external onlyMinter { _mint(account, amount); } /** * @notice Feeless ERC20 transfer. */ function transferFeeless(address account, uint256 value) feeless whenNotPaused external { _transfer(msgSender, account, value); emit TransferFeeless(account, value); } /** * @notice Feeless ERC20 transfer. */ function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); } }
/** * @title AWG Token * @notice ERC20 token implementation. * @dev Implements mintable, burnable and pausable token interfaces. */
NatSpecMultiLine
approveFeeless
function approveFeeless(address spender, uint256 value) feeless whenNotPaused external { _approve(msgSender, spender, value); emit ApproveFeeless(spender, value); }
/** * @notice Feeless ERC20 transfer. */
NatSpecMultiLine
v0.5.4+commit.9549d8ff
MIT
bzzr://9ce91c89b7de19f2f5221b1c3deead8577a2d45162c687c0054fc1889b0c61c8
{ "func_code_index": [ 5039, 5231 ] }
55,784
DRIP
DRIP.sol
0x9931e0371fac4f4a4acdbcaf110ae5b3a1329973
Solidity
Ownable
contract Ownable is Context { address payable private _owner; address payable private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor (address ownerAddress) { _owner = payable(ownerAddress); emit OwnershipTransferred(address(0), _owner); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = payable(address(0)); } function transferOwnership(address payable newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = payable(address(0)); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until defined days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; _previousOwner = payable(address(0)); } }
lock
function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = payable(address(0)); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); }
//Locks the contract for owner for the amount of time provided
LineComment
v0.8.4+commit.c7e474f2
Unlicense
ipfs://e72b98690cfc1e288a84fa746d49e470128460cebaa866cd908c389345a7c41e
{ "func_code_index": [ 1191, 1431 ] }
55,785
DRIP
DRIP.sol
0x9931e0371fac4f4a4acdbcaf110ae5b3a1329973
Solidity
Ownable
contract Ownable is Context { address payable private _owner; address payable private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor (address ownerAddress) { _owner = payable(ownerAddress); emit OwnershipTransferred(address(0), _owner); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = payable(address(0)); } function transferOwnership(address payable newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = payable(address(0)); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until defined days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; _previousOwner = payable(address(0)); } }
unlock
function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until defined days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; _previousOwner = payable(address(0)); }
//Unlocks the contract for owner when _lockTime is exceeds
LineComment
v0.8.4+commit.c7e474f2
Unlicense
ipfs://e72b98690cfc1e288a84fa746d49e470128460cebaa866cd908c389345a7c41e
{ "func_code_index": [ 1498, 1861 ] }
55,786
DRIP
DRIP.sol
0x9931e0371fac4f4a4acdbcaf110ae5b3a1329973
Solidity
DRIP
contract DRIP is Context, IBEP20, Ownable{ using SafeMath for uint256; using Address for address; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; mapping(address => bool) private _isExcludedFromMaxTx; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 99000 * 10**6 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Do Right and Invest Properly"; string private _symbol = "DRIP"; uint8 private _decimals = 9; IPancakeRouter02 public pancakeRouter; address public immutable pancakePair; address payable public buyBackWallet; address payable public marketWallet; uint256 public _taxFee = 0; // 1% will be distributed among holder as DRIP divideneds uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 10; // 10% will be added to the liquidity pool uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _buyBackFee = 35; // 3.5% will go to the buyBack address uint256 private _previousCharityFee = _buyBackFee; uint256 public _marketFee = 35; // 3.5% will go to the market address uint256 private _previousMarketFee = _marketFee; uint256 public _maxTxAmount = 3000000 * 10**6 * 10**9; uint256 public minTokenNumberToSell = 200000 * 10**6 * 10**9; bool public swapAndLiquifyEnabled = false; // should be true to turn on to liquidate the pool bool public reflectionFeesdiabled = false; bool inSwapAndLiquify = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event ClaimBNBSuccessfully( address recipient, uint256 ethReceived, uint256 nextAvailableClaimDate ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor ( address payable ownerAddress, address payable _buyBackAddress, address payable _marketWallet ) Ownable(ownerAddress) { _rOwned[owner()] = _rTotal; buyBackWallet = _buyBackAddress; marketWallet = _marketWallet; IPancakeRouter02 _pancakeRouter = IPancakeRouter02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a pancake pair for this new token pancakePair = IPancakeFactory(_pancakeRouter.factory()) .createPair(address(this), _pancakeRouter.WETH()); // set the rest of the contract variables pancakeRouter = _pancakeRouter; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; // exclude from max tx _isExcludedFromMaxTx[owner()] = true; _isExcludedFromMaxTx[address(this)] = true; emit Transfer(address(0), owner(), _tTotal); } //to receive BNB from pancakeRouter when swapping receive() external payable {} function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; } // to manually distribute tokens to holders function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); uint256 rAmount = tAmount.mul(_getRate()); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } // getter functions function getContractBalance() public view returns(uint256) { return address(this).balance; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function isExcludedFromFee(address account) public view returns (bool) { return _isExcludedFromFee[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns (uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { uint256 rAmount = tAmount.mul(_getRate()); return rAmount; } else { uint256 rAmount = tAmount.mul(_getRate()); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(_getRate())); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns (uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } // setter functions for Owner function excludeFromReward(address account) public onlyOwner { require(!_isExcluded[account], "Account is already excluded"); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _rOwned[account] = _tOwned[account].mul(_getRate()); _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setMaxTxAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMinTokenNumberToSell(uint256 _amount) public onlyOwner { minTokenNumberToSell = _amount; } function setExcludeFromMaxTx(address _address, bool value) public onlyOwner { _isExcludedFromMaxTx[_address] = value; } function setFeePercents(uint256 taxFee, uint256 liquidityFee, uint256 buyBackFee, uint256 marketFee) external onlyOwner { _taxFee = taxFee; _liquidityFee = liquidityFee; _buyBackFee = buyBackFee; _marketFee = marketFee; } function setSwapAndLiquifyEnabled(bool _state) public onlyOwner { swapAndLiquifyEnabled = _state; emit SwapAndLiquifyEnabledUpdated(_state); } function setReflectionFees(bool _state) external onlyOwner { reflectionFeesdiabled = _state; } function setBuyBackAddress(address payable _buyBackAddress) external onlyOwner { buyBackWallet = _buyBackAddress; } function setMarketAddress(address payable _marketAddress) external onlyOwner { marketWallet = _marketAddress; } function setPancakeRouter(IPancakeRouter02 _pancakeRouter) external onlyOwner { pancakeRouter = _pancakeRouter; } // internal functions for contract function totalFeePerTx(uint256 tAmount) internal view returns(uint256) { uint256 percentage = tAmount.mul(_taxFee.add(_liquidityFee).add(_buyBackFee).add(_marketFee)).div(1e3); return percentage; } function _reflectFee(uint256 tAmount) private { uint256 tFee = tAmount.mul(_taxFee).div(1e3); uint256 rFee = tFee.mul(_getRate()); _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeAllFee(uint256 tAmount, uint256 currentRate) internal { uint256 tFee = tAmount.mul(_liquidityFee.add(_buyBackFee).add(_marketFee)).div(1e3); uint256 rFee = tFee.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rFee); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tFee); emit Transfer(_msgSender(), address(this), tFee); } function removeAllFee() private { _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _previousCharityFee = _buyBackFee; _previousMarketFee = _marketFee; _taxFee = 0; _liquidityFee = 0; _buyBackFee = 0; _marketFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; _buyBackFee = _previousCharityFee; _marketFee = _previousMarketFee; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "BEP20: transfer from the zero address"); require(to != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "BEP20: Transfer amount must be greater than zero"); if(!_isExcludedFromMaxTx[from] && !_isExcludedFromMaxTx[to] // by default false ){ require(amount <= _maxTxAmount,"BEP20: Amount exceed max limit"); } // swap and liquify swapAndLiquify(from, to); //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to] || reflectionFeesdiabled) { takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from, to, amount, takeFee); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if (!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if (!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function swapAndLiquify(address from, address to) private { // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is pancake pair. uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool shouldSell = contractTokenBalance >= minTokenNumberToSell; if ( !inSwapAndLiquify && shouldSell && from != pancakePair && swapAndLiquifyEnabled && !(from == address(this) && to == address(pancakePair)) // swap 1 time ) { // only sell for minTokenNumberToSell, decouple from _maxTxAmount // split the contract balance into 4 pieces contractTokenBalance = minTokenNumberToSell; // approve contract _approve(address(this), address(pancakeRouter), contractTokenBalance); uint256 totalPercent = _liquidityFee.add(_buyBackFee).add(_marketFee); uint256 lpPercent = _liquidityFee.mul(1e4).div(totalPercent).div(2); uint256 bbPercent = _buyBackFee.mul(1e4).div(totalPercent); uint256 mwPercent = _marketFee.mul(1e4).div(totalPercent); uint256 otherPiece = contractTokenBalance.mul(lpPercent).div(1e4); uint256 tokenAmountToBeSwapped = contractTokenBalance.sub(otherPiece); // now is to lock into staking pool Utils.swapTokensForEth(address(pancakeRouter), tokenAmountToBeSwapped); // how much BNB did we just swap into? // capture the contract's current BNB balance. // this is so that we can capture exactly the amount of BNB that the // swap creates, and not make the liquidity event include any BNB that // has been manually sent to the contract uint256 deltaBalance = getContractBalance(); totalPercent = lpPercent.add(bbPercent).add(mwPercent); uint256 bnbToBeAddedToLiquidity = deltaBalance.mul(lpPercent).div(totalPercent); // add liquidity to pancake Utils.addLiquidity(address(pancakeRouter), owner(), otherPiece, bnbToBeAddedToLiquidity); // buybcak fee transfer buyBackWallet.transfer(deltaBalance.mul(bbPercent).div(totalPercent)); // market fee transfer marketWallet.transfer(getContractBalance()); emit SwapAndLiquify(tokenAmountToBeSwapped, deltaBalance, otherPiece); } } }
// Modified by team BloctechSolutions.com
LineComment
//to receive BNB from pancakeRouter when swapping
LineComment
v0.8.4+commit.c7e474f2
Unlicense
ipfs://e72b98690cfc1e288a84fa746d49e470128460cebaa866cd908c389345a7c41e
{ "func_code_index": [ 3406, 3440 ] }
55,787
DRIP
DRIP.sol
0x9931e0371fac4f4a4acdbcaf110ae5b3a1329973
Solidity
DRIP
contract DRIP is Context, IBEP20, Ownable{ using SafeMath for uint256; using Address for address; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; mapping(address => bool) private _isExcludedFromMaxTx; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 99000 * 10**6 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Do Right and Invest Properly"; string private _symbol = "DRIP"; uint8 private _decimals = 9; IPancakeRouter02 public pancakeRouter; address public immutable pancakePair; address payable public buyBackWallet; address payable public marketWallet; uint256 public _taxFee = 0; // 1% will be distributed among holder as DRIP divideneds uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 10; // 10% will be added to the liquidity pool uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _buyBackFee = 35; // 3.5% will go to the buyBack address uint256 private _previousCharityFee = _buyBackFee; uint256 public _marketFee = 35; // 3.5% will go to the market address uint256 private _previousMarketFee = _marketFee; uint256 public _maxTxAmount = 3000000 * 10**6 * 10**9; uint256 public minTokenNumberToSell = 200000 * 10**6 * 10**9; bool public swapAndLiquifyEnabled = false; // should be true to turn on to liquidate the pool bool public reflectionFeesdiabled = false; bool inSwapAndLiquify = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event ClaimBNBSuccessfully( address recipient, uint256 ethReceived, uint256 nextAvailableClaimDate ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor ( address payable ownerAddress, address payable _buyBackAddress, address payable _marketWallet ) Ownable(ownerAddress) { _rOwned[owner()] = _rTotal; buyBackWallet = _buyBackAddress; marketWallet = _marketWallet; IPancakeRouter02 _pancakeRouter = IPancakeRouter02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a pancake pair for this new token pancakePair = IPancakeFactory(_pancakeRouter.factory()) .createPair(address(this), _pancakeRouter.WETH()); // set the rest of the contract variables pancakeRouter = _pancakeRouter; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; // exclude from max tx _isExcludedFromMaxTx[owner()] = true; _isExcludedFromMaxTx[address(this)] = true; emit Transfer(address(0), owner(), _tTotal); } //to receive BNB from pancakeRouter when swapping receive() external payable {} function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; } // to manually distribute tokens to holders function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); uint256 rAmount = tAmount.mul(_getRate()); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } // getter functions function getContractBalance() public view returns(uint256) { return address(this).balance; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function isExcludedFromFee(address account) public view returns (bool) { return _isExcludedFromFee[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns (uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { uint256 rAmount = tAmount.mul(_getRate()); return rAmount; } else { uint256 rAmount = tAmount.mul(_getRate()); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(_getRate())); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns (uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } // setter functions for Owner function excludeFromReward(address account) public onlyOwner { require(!_isExcluded[account], "Account is already excluded"); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _rOwned[account] = _tOwned[account].mul(_getRate()); _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setMaxTxAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMinTokenNumberToSell(uint256 _amount) public onlyOwner { minTokenNumberToSell = _amount; } function setExcludeFromMaxTx(address _address, bool value) public onlyOwner { _isExcludedFromMaxTx[_address] = value; } function setFeePercents(uint256 taxFee, uint256 liquidityFee, uint256 buyBackFee, uint256 marketFee) external onlyOwner { _taxFee = taxFee; _liquidityFee = liquidityFee; _buyBackFee = buyBackFee; _marketFee = marketFee; } function setSwapAndLiquifyEnabled(bool _state) public onlyOwner { swapAndLiquifyEnabled = _state; emit SwapAndLiquifyEnabledUpdated(_state); } function setReflectionFees(bool _state) external onlyOwner { reflectionFeesdiabled = _state; } function setBuyBackAddress(address payable _buyBackAddress) external onlyOwner { buyBackWallet = _buyBackAddress; } function setMarketAddress(address payable _marketAddress) external onlyOwner { marketWallet = _marketAddress; } function setPancakeRouter(IPancakeRouter02 _pancakeRouter) external onlyOwner { pancakeRouter = _pancakeRouter; } // internal functions for contract function totalFeePerTx(uint256 tAmount) internal view returns(uint256) { uint256 percentage = tAmount.mul(_taxFee.add(_liquidityFee).add(_buyBackFee).add(_marketFee)).div(1e3); return percentage; } function _reflectFee(uint256 tAmount) private { uint256 tFee = tAmount.mul(_taxFee).div(1e3); uint256 rFee = tFee.mul(_getRate()); _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeAllFee(uint256 tAmount, uint256 currentRate) internal { uint256 tFee = tAmount.mul(_liquidityFee.add(_buyBackFee).add(_marketFee)).div(1e3); uint256 rFee = tFee.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rFee); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tFee); emit Transfer(_msgSender(), address(this), tFee); } function removeAllFee() private { _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _previousCharityFee = _buyBackFee; _previousMarketFee = _marketFee; _taxFee = 0; _liquidityFee = 0; _buyBackFee = 0; _marketFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; _buyBackFee = _previousCharityFee; _marketFee = _previousMarketFee; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "BEP20: transfer from the zero address"); require(to != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "BEP20: Transfer amount must be greater than zero"); if(!_isExcludedFromMaxTx[from] && !_isExcludedFromMaxTx[to] // by default false ){ require(amount <= _maxTxAmount,"BEP20: Amount exceed max limit"); } // swap and liquify swapAndLiquify(from, to); //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to] || reflectionFeesdiabled) { takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from, to, amount, takeFee); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if (!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if (!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function swapAndLiquify(address from, address to) private { // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is pancake pair. uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool shouldSell = contractTokenBalance >= minTokenNumberToSell; if ( !inSwapAndLiquify && shouldSell && from != pancakePair && swapAndLiquifyEnabled && !(from == address(this) && to == address(pancakePair)) // swap 1 time ) { // only sell for minTokenNumberToSell, decouple from _maxTxAmount // split the contract balance into 4 pieces contractTokenBalance = minTokenNumberToSell; // approve contract _approve(address(this), address(pancakeRouter), contractTokenBalance); uint256 totalPercent = _liquidityFee.add(_buyBackFee).add(_marketFee); uint256 lpPercent = _liquidityFee.mul(1e4).div(totalPercent).div(2); uint256 bbPercent = _buyBackFee.mul(1e4).div(totalPercent); uint256 mwPercent = _marketFee.mul(1e4).div(totalPercent); uint256 otherPiece = contractTokenBalance.mul(lpPercent).div(1e4); uint256 tokenAmountToBeSwapped = contractTokenBalance.sub(otherPiece); // now is to lock into staking pool Utils.swapTokensForEth(address(pancakeRouter), tokenAmountToBeSwapped); // how much BNB did we just swap into? // capture the contract's current BNB balance. // this is so that we can capture exactly the amount of BNB that the // swap creates, and not make the liquidity event include any BNB that // has been manually sent to the contract uint256 deltaBalance = getContractBalance(); totalPercent = lpPercent.add(bbPercent).add(mwPercent); uint256 bnbToBeAddedToLiquidity = deltaBalance.mul(lpPercent).div(totalPercent); // add liquidity to pancake Utils.addLiquidity(address(pancakeRouter), owner(), otherPiece, bnbToBeAddedToLiquidity); // buybcak fee transfer buyBackWallet.transfer(deltaBalance.mul(bbPercent).div(totalPercent)); // market fee transfer marketWallet.transfer(getContractBalance()); emit SwapAndLiquify(tokenAmountToBeSwapped, deltaBalance, otherPiece); } } }
// Modified by team BloctechSolutions.com
LineComment
deliver
function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); uint256 rAmount = tAmount.mul(_getRate()); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); }
// to manually distribute tokens to holders
LineComment
v0.8.4+commit.c7e474f2
Unlicense
ipfs://e72b98690cfc1e288a84fa746d49e470128460cebaa866cd908c389345a7c41e
{ "func_code_index": [ 5397, 5776 ] }
55,788
DRIP
DRIP.sol
0x9931e0371fac4f4a4acdbcaf110ae5b3a1329973
Solidity
DRIP
contract DRIP is Context, IBEP20, Ownable{ using SafeMath for uint256; using Address for address; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; mapping(address => bool) private _isExcludedFromMaxTx; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 99000 * 10**6 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Do Right and Invest Properly"; string private _symbol = "DRIP"; uint8 private _decimals = 9; IPancakeRouter02 public pancakeRouter; address public immutable pancakePair; address payable public buyBackWallet; address payable public marketWallet; uint256 public _taxFee = 0; // 1% will be distributed among holder as DRIP divideneds uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 10; // 10% will be added to the liquidity pool uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _buyBackFee = 35; // 3.5% will go to the buyBack address uint256 private _previousCharityFee = _buyBackFee; uint256 public _marketFee = 35; // 3.5% will go to the market address uint256 private _previousMarketFee = _marketFee; uint256 public _maxTxAmount = 3000000 * 10**6 * 10**9; uint256 public minTokenNumberToSell = 200000 * 10**6 * 10**9; bool public swapAndLiquifyEnabled = false; // should be true to turn on to liquidate the pool bool public reflectionFeesdiabled = false; bool inSwapAndLiquify = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event ClaimBNBSuccessfully( address recipient, uint256 ethReceived, uint256 nextAvailableClaimDate ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor ( address payable ownerAddress, address payable _buyBackAddress, address payable _marketWallet ) Ownable(ownerAddress) { _rOwned[owner()] = _rTotal; buyBackWallet = _buyBackAddress; marketWallet = _marketWallet; IPancakeRouter02 _pancakeRouter = IPancakeRouter02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a pancake pair for this new token pancakePair = IPancakeFactory(_pancakeRouter.factory()) .createPair(address(this), _pancakeRouter.WETH()); // set the rest of the contract variables pancakeRouter = _pancakeRouter; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; // exclude from max tx _isExcludedFromMaxTx[owner()] = true; _isExcludedFromMaxTx[address(this)] = true; emit Transfer(address(0), owner(), _tTotal); } //to receive BNB from pancakeRouter when swapping receive() external payable {} function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; } // to manually distribute tokens to holders function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); uint256 rAmount = tAmount.mul(_getRate()); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } // getter functions function getContractBalance() public view returns(uint256) { return address(this).balance; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function isExcludedFromFee(address account) public view returns (bool) { return _isExcludedFromFee[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns (uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { uint256 rAmount = tAmount.mul(_getRate()); return rAmount; } else { uint256 rAmount = tAmount.mul(_getRate()); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(_getRate())); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns (uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } // setter functions for Owner function excludeFromReward(address account) public onlyOwner { require(!_isExcluded[account], "Account is already excluded"); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _rOwned[account] = _tOwned[account].mul(_getRate()); _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setMaxTxAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMinTokenNumberToSell(uint256 _amount) public onlyOwner { minTokenNumberToSell = _amount; } function setExcludeFromMaxTx(address _address, bool value) public onlyOwner { _isExcludedFromMaxTx[_address] = value; } function setFeePercents(uint256 taxFee, uint256 liquidityFee, uint256 buyBackFee, uint256 marketFee) external onlyOwner { _taxFee = taxFee; _liquidityFee = liquidityFee; _buyBackFee = buyBackFee; _marketFee = marketFee; } function setSwapAndLiquifyEnabled(bool _state) public onlyOwner { swapAndLiquifyEnabled = _state; emit SwapAndLiquifyEnabledUpdated(_state); } function setReflectionFees(bool _state) external onlyOwner { reflectionFeesdiabled = _state; } function setBuyBackAddress(address payable _buyBackAddress) external onlyOwner { buyBackWallet = _buyBackAddress; } function setMarketAddress(address payable _marketAddress) external onlyOwner { marketWallet = _marketAddress; } function setPancakeRouter(IPancakeRouter02 _pancakeRouter) external onlyOwner { pancakeRouter = _pancakeRouter; } // internal functions for contract function totalFeePerTx(uint256 tAmount) internal view returns(uint256) { uint256 percentage = tAmount.mul(_taxFee.add(_liquidityFee).add(_buyBackFee).add(_marketFee)).div(1e3); return percentage; } function _reflectFee(uint256 tAmount) private { uint256 tFee = tAmount.mul(_taxFee).div(1e3); uint256 rFee = tFee.mul(_getRate()); _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeAllFee(uint256 tAmount, uint256 currentRate) internal { uint256 tFee = tAmount.mul(_liquidityFee.add(_buyBackFee).add(_marketFee)).div(1e3); uint256 rFee = tFee.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rFee); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tFee); emit Transfer(_msgSender(), address(this), tFee); } function removeAllFee() private { _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _previousCharityFee = _buyBackFee; _previousMarketFee = _marketFee; _taxFee = 0; _liquidityFee = 0; _buyBackFee = 0; _marketFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; _buyBackFee = _previousCharityFee; _marketFee = _previousMarketFee; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "BEP20: transfer from the zero address"); require(to != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "BEP20: Transfer amount must be greater than zero"); if(!_isExcludedFromMaxTx[from] && !_isExcludedFromMaxTx[to] // by default false ){ require(amount <= _maxTxAmount,"BEP20: Amount exceed max limit"); } // swap and liquify swapAndLiquify(from, to); //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to] || reflectionFeesdiabled) { takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from, to, amount, takeFee); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if (!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if (!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function swapAndLiquify(address from, address to) private { // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is pancake pair. uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool shouldSell = contractTokenBalance >= minTokenNumberToSell; if ( !inSwapAndLiquify && shouldSell && from != pancakePair && swapAndLiquifyEnabled && !(from == address(this) && to == address(pancakePair)) // swap 1 time ) { // only sell for minTokenNumberToSell, decouple from _maxTxAmount // split the contract balance into 4 pieces contractTokenBalance = minTokenNumberToSell; // approve contract _approve(address(this), address(pancakeRouter), contractTokenBalance); uint256 totalPercent = _liquidityFee.add(_buyBackFee).add(_marketFee); uint256 lpPercent = _liquidityFee.mul(1e4).div(totalPercent).div(2); uint256 bbPercent = _buyBackFee.mul(1e4).div(totalPercent); uint256 mwPercent = _marketFee.mul(1e4).div(totalPercent); uint256 otherPiece = contractTokenBalance.mul(lpPercent).div(1e4); uint256 tokenAmountToBeSwapped = contractTokenBalance.sub(otherPiece); // now is to lock into staking pool Utils.swapTokensForEth(address(pancakeRouter), tokenAmountToBeSwapped); // how much BNB did we just swap into? // capture the contract's current BNB balance. // this is so that we can capture exactly the amount of BNB that the // swap creates, and not make the liquidity event include any BNB that // has been manually sent to the contract uint256 deltaBalance = getContractBalance(); totalPercent = lpPercent.add(bbPercent).add(mwPercent); uint256 bnbToBeAddedToLiquidity = deltaBalance.mul(lpPercent).div(totalPercent); // add liquidity to pancake Utils.addLiquidity(address(pancakeRouter), owner(), otherPiece, bnbToBeAddedToLiquidity); // buybcak fee transfer buyBackWallet.transfer(deltaBalance.mul(bbPercent).div(totalPercent)); // market fee transfer marketWallet.transfer(getContractBalance()); emit SwapAndLiquify(tokenAmountToBeSwapped, deltaBalance, otherPiece); } } }
// Modified by team BloctechSolutions.com
LineComment
getContractBalance
function getContractBalance() public view returns(uint256) { return address(this).balance; }
// getter functions
LineComment
v0.8.4+commit.c7e474f2
Unlicense
ipfs://e72b98690cfc1e288a84fa746d49e470128460cebaa866cd908c389345a7c41e
{ "func_code_index": [ 5806, 5917 ] }
55,789
DRIP
DRIP.sol
0x9931e0371fac4f4a4acdbcaf110ae5b3a1329973
Solidity
DRIP
contract DRIP is Context, IBEP20, Ownable{ using SafeMath for uint256; using Address for address; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; mapping(address => bool) private _isExcludedFromMaxTx; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 99000 * 10**6 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Do Right and Invest Properly"; string private _symbol = "DRIP"; uint8 private _decimals = 9; IPancakeRouter02 public pancakeRouter; address public immutable pancakePair; address payable public buyBackWallet; address payable public marketWallet; uint256 public _taxFee = 0; // 1% will be distributed among holder as DRIP divideneds uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 10; // 10% will be added to the liquidity pool uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _buyBackFee = 35; // 3.5% will go to the buyBack address uint256 private _previousCharityFee = _buyBackFee; uint256 public _marketFee = 35; // 3.5% will go to the market address uint256 private _previousMarketFee = _marketFee; uint256 public _maxTxAmount = 3000000 * 10**6 * 10**9; uint256 public minTokenNumberToSell = 200000 * 10**6 * 10**9; bool public swapAndLiquifyEnabled = false; // should be true to turn on to liquidate the pool bool public reflectionFeesdiabled = false; bool inSwapAndLiquify = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event ClaimBNBSuccessfully( address recipient, uint256 ethReceived, uint256 nextAvailableClaimDate ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor ( address payable ownerAddress, address payable _buyBackAddress, address payable _marketWallet ) Ownable(ownerAddress) { _rOwned[owner()] = _rTotal; buyBackWallet = _buyBackAddress; marketWallet = _marketWallet; IPancakeRouter02 _pancakeRouter = IPancakeRouter02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a pancake pair for this new token pancakePair = IPancakeFactory(_pancakeRouter.factory()) .createPair(address(this), _pancakeRouter.WETH()); // set the rest of the contract variables pancakeRouter = _pancakeRouter; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; // exclude from max tx _isExcludedFromMaxTx[owner()] = true; _isExcludedFromMaxTx[address(this)] = true; emit Transfer(address(0), owner(), _tTotal); } //to receive BNB from pancakeRouter when swapping receive() external payable {} function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; } // to manually distribute tokens to holders function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); uint256 rAmount = tAmount.mul(_getRate()); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } // getter functions function getContractBalance() public view returns(uint256) { return address(this).balance; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function isExcludedFromFee(address account) public view returns (bool) { return _isExcludedFromFee[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns (uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { uint256 rAmount = tAmount.mul(_getRate()); return rAmount; } else { uint256 rAmount = tAmount.mul(_getRate()); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(_getRate())); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns (uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } // setter functions for Owner function excludeFromReward(address account) public onlyOwner { require(!_isExcluded[account], "Account is already excluded"); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _rOwned[account] = _tOwned[account].mul(_getRate()); _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setMaxTxAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMinTokenNumberToSell(uint256 _amount) public onlyOwner { minTokenNumberToSell = _amount; } function setExcludeFromMaxTx(address _address, bool value) public onlyOwner { _isExcludedFromMaxTx[_address] = value; } function setFeePercents(uint256 taxFee, uint256 liquidityFee, uint256 buyBackFee, uint256 marketFee) external onlyOwner { _taxFee = taxFee; _liquidityFee = liquidityFee; _buyBackFee = buyBackFee; _marketFee = marketFee; } function setSwapAndLiquifyEnabled(bool _state) public onlyOwner { swapAndLiquifyEnabled = _state; emit SwapAndLiquifyEnabledUpdated(_state); } function setReflectionFees(bool _state) external onlyOwner { reflectionFeesdiabled = _state; } function setBuyBackAddress(address payable _buyBackAddress) external onlyOwner { buyBackWallet = _buyBackAddress; } function setMarketAddress(address payable _marketAddress) external onlyOwner { marketWallet = _marketAddress; } function setPancakeRouter(IPancakeRouter02 _pancakeRouter) external onlyOwner { pancakeRouter = _pancakeRouter; } // internal functions for contract function totalFeePerTx(uint256 tAmount) internal view returns(uint256) { uint256 percentage = tAmount.mul(_taxFee.add(_liquidityFee).add(_buyBackFee).add(_marketFee)).div(1e3); return percentage; } function _reflectFee(uint256 tAmount) private { uint256 tFee = tAmount.mul(_taxFee).div(1e3); uint256 rFee = tFee.mul(_getRate()); _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeAllFee(uint256 tAmount, uint256 currentRate) internal { uint256 tFee = tAmount.mul(_liquidityFee.add(_buyBackFee).add(_marketFee)).div(1e3); uint256 rFee = tFee.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rFee); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tFee); emit Transfer(_msgSender(), address(this), tFee); } function removeAllFee() private { _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _previousCharityFee = _buyBackFee; _previousMarketFee = _marketFee; _taxFee = 0; _liquidityFee = 0; _buyBackFee = 0; _marketFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; _buyBackFee = _previousCharityFee; _marketFee = _previousMarketFee; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "BEP20: transfer from the zero address"); require(to != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "BEP20: Transfer amount must be greater than zero"); if(!_isExcludedFromMaxTx[from] && !_isExcludedFromMaxTx[to] // by default false ){ require(amount <= _maxTxAmount,"BEP20: Amount exceed max limit"); } // swap and liquify swapAndLiquify(from, to); //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to] || reflectionFeesdiabled) { takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from, to, amount, takeFee); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if (!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if (!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function swapAndLiquify(address from, address to) private { // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is pancake pair. uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool shouldSell = contractTokenBalance >= minTokenNumberToSell; if ( !inSwapAndLiquify && shouldSell && from != pancakePair && swapAndLiquifyEnabled && !(from == address(this) && to == address(pancakePair)) // swap 1 time ) { // only sell for minTokenNumberToSell, decouple from _maxTxAmount // split the contract balance into 4 pieces contractTokenBalance = minTokenNumberToSell; // approve contract _approve(address(this), address(pancakeRouter), contractTokenBalance); uint256 totalPercent = _liquidityFee.add(_buyBackFee).add(_marketFee); uint256 lpPercent = _liquidityFee.mul(1e4).div(totalPercent).div(2); uint256 bbPercent = _buyBackFee.mul(1e4).div(totalPercent); uint256 mwPercent = _marketFee.mul(1e4).div(totalPercent); uint256 otherPiece = contractTokenBalance.mul(lpPercent).div(1e4); uint256 tokenAmountToBeSwapped = contractTokenBalance.sub(otherPiece); // now is to lock into staking pool Utils.swapTokensForEth(address(pancakeRouter), tokenAmountToBeSwapped); // how much BNB did we just swap into? // capture the contract's current BNB balance. // this is so that we can capture exactly the amount of BNB that the // swap creates, and not make the liquidity event include any BNB that // has been manually sent to the contract uint256 deltaBalance = getContractBalance(); totalPercent = lpPercent.add(bbPercent).add(mwPercent); uint256 bnbToBeAddedToLiquidity = deltaBalance.mul(lpPercent).div(totalPercent); // add liquidity to pancake Utils.addLiquidity(address(pancakeRouter), owner(), otherPiece, bnbToBeAddedToLiquidity); // buybcak fee transfer buyBackWallet.transfer(deltaBalance.mul(bbPercent).div(totalPercent)); // market fee transfer marketWallet.transfer(getContractBalance()); emit SwapAndLiquify(tokenAmountToBeSwapped, deltaBalance, otherPiece); } } }
// Modified by team BloctechSolutions.com
LineComment
excludeFromReward
function excludeFromReward(address account) public onlyOwner { require(!_isExcluded[account], "Account is already excluded"); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); }
// setter functions for Owner
LineComment
v0.8.4+commit.c7e474f2
Unlicense
ipfs://e72b98690cfc1e288a84fa746d49e470128460cebaa866cd908c389345a7c41e
{ "func_code_index": [ 7096, 7433 ] }
55,790
DRIP
DRIP.sol
0x9931e0371fac4f4a4acdbcaf110ae5b3a1329973
Solidity
DRIP
contract DRIP is Context, IBEP20, Ownable{ using SafeMath for uint256; using Address for address; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; mapping(address => bool) private _isExcludedFromMaxTx; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 99000 * 10**6 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Do Right and Invest Properly"; string private _symbol = "DRIP"; uint8 private _decimals = 9; IPancakeRouter02 public pancakeRouter; address public immutable pancakePair; address payable public buyBackWallet; address payable public marketWallet; uint256 public _taxFee = 0; // 1% will be distributed among holder as DRIP divideneds uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 10; // 10% will be added to the liquidity pool uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _buyBackFee = 35; // 3.5% will go to the buyBack address uint256 private _previousCharityFee = _buyBackFee; uint256 public _marketFee = 35; // 3.5% will go to the market address uint256 private _previousMarketFee = _marketFee; uint256 public _maxTxAmount = 3000000 * 10**6 * 10**9; uint256 public minTokenNumberToSell = 200000 * 10**6 * 10**9; bool public swapAndLiquifyEnabled = false; // should be true to turn on to liquidate the pool bool public reflectionFeesdiabled = false; bool inSwapAndLiquify = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event ClaimBNBSuccessfully( address recipient, uint256 ethReceived, uint256 nextAvailableClaimDate ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor ( address payable ownerAddress, address payable _buyBackAddress, address payable _marketWallet ) Ownable(ownerAddress) { _rOwned[owner()] = _rTotal; buyBackWallet = _buyBackAddress; marketWallet = _marketWallet; IPancakeRouter02 _pancakeRouter = IPancakeRouter02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a pancake pair for this new token pancakePair = IPancakeFactory(_pancakeRouter.factory()) .createPair(address(this), _pancakeRouter.WETH()); // set the rest of the contract variables pancakeRouter = _pancakeRouter; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; // exclude from max tx _isExcludedFromMaxTx[owner()] = true; _isExcludedFromMaxTx[address(this)] = true; emit Transfer(address(0), owner(), _tTotal); } //to receive BNB from pancakeRouter when swapping receive() external payable {} function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; } // to manually distribute tokens to holders function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); uint256 rAmount = tAmount.mul(_getRate()); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } // getter functions function getContractBalance() public view returns(uint256) { return address(this).balance; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function isExcludedFromFee(address account) public view returns (bool) { return _isExcludedFromFee[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns (uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { uint256 rAmount = tAmount.mul(_getRate()); return rAmount; } else { uint256 rAmount = tAmount.mul(_getRate()); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(_getRate())); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns (uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } // setter functions for Owner function excludeFromReward(address account) public onlyOwner { require(!_isExcluded[account], "Account is already excluded"); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _rOwned[account] = _tOwned[account].mul(_getRate()); _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setMaxTxAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMinTokenNumberToSell(uint256 _amount) public onlyOwner { minTokenNumberToSell = _amount; } function setExcludeFromMaxTx(address _address, bool value) public onlyOwner { _isExcludedFromMaxTx[_address] = value; } function setFeePercents(uint256 taxFee, uint256 liquidityFee, uint256 buyBackFee, uint256 marketFee) external onlyOwner { _taxFee = taxFee; _liquidityFee = liquidityFee; _buyBackFee = buyBackFee; _marketFee = marketFee; } function setSwapAndLiquifyEnabled(bool _state) public onlyOwner { swapAndLiquifyEnabled = _state; emit SwapAndLiquifyEnabledUpdated(_state); } function setReflectionFees(bool _state) external onlyOwner { reflectionFeesdiabled = _state; } function setBuyBackAddress(address payable _buyBackAddress) external onlyOwner { buyBackWallet = _buyBackAddress; } function setMarketAddress(address payable _marketAddress) external onlyOwner { marketWallet = _marketAddress; } function setPancakeRouter(IPancakeRouter02 _pancakeRouter) external onlyOwner { pancakeRouter = _pancakeRouter; } // internal functions for contract function totalFeePerTx(uint256 tAmount) internal view returns(uint256) { uint256 percentage = tAmount.mul(_taxFee.add(_liquidityFee).add(_buyBackFee).add(_marketFee)).div(1e3); return percentage; } function _reflectFee(uint256 tAmount) private { uint256 tFee = tAmount.mul(_taxFee).div(1e3); uint256 rFee = tFee.mul(_getRate()); _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeAllFee(uint256 tAmount, uint256 currentRate) internal { uint256 tFee = tAmount.mul(_liquidityFee.add(_buyBackFee).add(_marketFee)).div(1e3); uint256 rFee = tFee.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rFee); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tFee); emit Transfer(_msgSender(), address(this), tFee); } function removeAllFee() private { _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _previousCharityFee = _buyBackFee; _previousMarketFee = _marketFee; _taxFee = 0; _liquidityFee = 0; _buyBackFee = 0; _marketFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; _buyBackFee = _previousCharityFee; _marketFee = _previousMarketFee; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "BEP20: transfer from the zero address"); require(to != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "BEP20: Transfer amount must be greater than zero"); if(!_isExcludedFromMaxTx[from] && !_isExcludedFromMaxTx[to] // by default false ){ require(amount <= _maxTxAmount,"BEP20: Amount exceed max limit"); } // swap and liquify swapAndLiquify(from, to); //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to] || reflectionFeesdiabled) { takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from, to, amount, takeFee); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if (!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if (!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function swapAndLiquify(address from, address to) private { // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is pancake pair. uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool shouldSell = contractTokenBalance >= minTokenNumberToSell; if ( !inSwapAndLiquify && shouldSell && from != pancakePair && swapAndLiquifyEnabled && !(from == address(this) && to == address(pancakePair)) // swap 1 time ) { // only sell for minTokenNumberToSell, decouple from _maxTxAmount // split the contract balance into 4 pieces contractTokenBalance = minTokenNumberToSell; // approve contract _approve(address(this), address(pancakeRouter), contractTokenBalance); uint256 totalPercent = _liquidityFee.add(_buyBackFee).add(_marketFee); uint256 lpPercent = _liquidityFee.mul(1e4).div(totalPercent).div(2); uint256 bbPercent = _buyBackFee.mul(1e4).div(totalPercent); uint256 mwPercent = _marketFee.mul(1e4).div(totalPercent); uint256 otherPiece = contractTokenBalance.mul(lpPercent).div(1e4); uint256 tokenAmountToBeSwapped = contractTokenBalance.sub(otherPiece); // now is to lock into staking pool Utils.swapTokensForEth(address(pancakeRouter), tokenAmountToBeSwapped); // how much BNB did we just swap into? // capture the contract's current BNB balance. // this is so that we can capture exactly the amount of BNB that the // swap creates, and not make the liquidity event include any BNB that // has been manually sent to the contract uint256 deltaBalance = getContractBalance(); totalPercent = lpPercent.add(bbPercent).add(mwPercent); uint256 bnbToBeAddedToLiquidity = deltaBalance.mul(lpPercent).div(totalPercent); // add liquidity to pancake Utils.addLiquidity(address(pancakeRouter), owner(), otherPiece, bnbToBeAddedToLiquidity); // buybcak fee transfer buyBackWallet.transfer(deltaBalance.mul(bbPercent).div(totalPercent)); // market fee transfer marketWallet.transfer(getContractBalance()); emit SwapAndLiquify(tokenAmountToBeSwapped, deltaBalance, otherPiece); } } }
// Modified by team BloctechSolutions.com
LineComment
totalFeePerTx
function totalFeePerTx(uint256 tAmount) internal view returns(uint256) { uint256 percentage = tAmount.mul(_taxFee.add(_liquidityFee).add(_buyBackFee).add(_marketFee)).div(1e3); return percentage; }
// internal functions for contract
LineComment
v0.8.4+commit.c7e474f2
Unlicense
ipfs://e72b98690cfc1e288a84fa746d49e470128460cebaa866cd908c389345a7c41e
{ "func_code_index": [ 9642, 9867 ] }
55,791
DRIP
DRIP.sol
0x9931e0371fac4f4a4acdbcaf110ae5b3a1329973
Solidity
DRIP
contract DRIP is Context, IBEP20, Ownable{ using SafeMath for uint256; using Address for address; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; mapping(address => bool) private _isExcludedFromMaxTx; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 99000 * 10**6 * 1e9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Do Right and Invest Properly"; string private _symbol = "DRIP"; uint8 private _decimals = 9; IPancakeRouter02 public pancakeRouter; address public immutable pancakePair; address payable public buyBackWallet; address payable public marketWallet; uint256 public _taxFee = 0; // 1% will be distributed among holder as DRIP divideneds uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 10; // 10% will be added to the liquidity pool uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _buyBackFee = 35; // 3.5% will go to the buyBack address uint256 private _previousCharityFee = _buyBackFee; uint256 public _marketFee = 35; // 3.5% will go to the market address uint256 private _previousMarketFee = _marketFee; uint256 public _maxTxAmount = 3000000 * 10**6 * 10**9; uint256 public minTokenNumberToSell = 200000 * 10**6 * 10**9; bool public swapAndLiquifyEnabled = false; // should be true to turn on to liquidate the pool bool public reflectionFeesdiabled = false; bool inSwapAndLiquify = false; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event ClaimBNBSuccessfully( address recipient, uint256 ethReceived, uint256 nextAvailableClaimDate ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor ( address payable ownerAddress, address payable _buyBackAddress, address payable _marketWallet ) Ownable(ownerAddress) { _rOwned[owner()] = _rTotal; buyBackWallet = _buyBackAddress; marketWallet = _marketWallet; IPancakeRouter02 _pancakeRouter = IPancakeRouter02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a pancake pair for this new token pancakePair = IPancakeFactory(_pancakeRouter.factory()) .createPair(address(this), _pancakeRouter.WETH()); // set the rest of the contract variables pancakeRouter = _pancakeRouter; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; // exclude from max tx _isExcludedFromMaxTx[owner()] = true; _isExcludedFromMaxTx[address(this)] = true; emit Transfer(address(0), owner(), _tTotal); } //to receive BNB from pancakeRouter when swapping receive() external payable {} function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero")); return true; } // to manually distribute tokens to holders function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); uint256 rAmount = tAmount.mul(_getRate()); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } // getter functions function getContractBalance() public view returns(uint256) { return address(this).balance; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function isExcludedFromFee(address account) public view returns (bool) { return _isExcludedFromFee[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns (uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { uint256 rAmount = tAmount.mul(_getRate()); return rAmount; } else { uint256 rAmount = tAmount.mul(_getRate()); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(_getRate())); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns (uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } // setter functions for Owner function excludeFromReward(address account) public onlyOwner { require(!_isExcluded[account], "Account is already excluded"); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _rOwned[account] = _tOwned[account].mul(_getRate()); _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setMaxTxAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMinTokenNumberToSell(uint256 _amount) public onlyOwner { minTokenNumberToSell = _amount; } function setExcludeFromMaxTx(address _address, bool value) public onlyOwner { _isExcludedFromMaxTx[_address] = value; } function setFeePercents(uint256 taxFee, uint256 liquidityFee, uint256 buyBackFee, uint256 marketFee) external onlyOwner { _taxFee = taxFee; _liquidityFee = liquidityFee; _buyBackFee = buyBackFee; _marketFee = marketFee; } function setSwapAndLiquifyEnabled(bool _state) public onlyOwner { swapAndLiquifyEnabled = _state; emit SwapAndLiquifyEnabledUpdated(_state); } function setReflectionFees(bool _state) external onlyOwner { reflectionFeesdiabled = _state; } function setBuyBackAddress(address payable _buyBackAddress) external onlyOwner { buyBackWallet = _buyBackAddress; } function setMarketAddress(address payable _marketAddress) external onlyOwner { marketWallet = _marketAddress; } function setPancakeRouter(IPancakeRouter02 _pancakeRouter) external onlyOwner { pancakeRouter = _pancakeRouter; } // internal functions for contract function totalFeePerTx(uint256 tAmount) internal view returns(uint256) { uint256 percentage = tAmount.mul(_taxFee.add(_liquidityFee).add(_buyBackFee).add(_marketFee)).div(1e3); return percentage; } function _reflectFee(uint256 tAmount) private { uint256 tFee = tAmount.mul(_taxFee).div(1e3); uint256 rFee = tFee.mul(_getRate()); _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeAllFee(uint256 tAmount, uint256 currentRate) internal { uint256 tFee = tAmount.mul(_liquidityFee.add(_buyBackFee).add(_marketFee)).div(1e3); uint256 rFee = tFee.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rFee); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tFee); emit Transfer(_msgSender(), address(this), tFee); } function removeAllFee() private { _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _previousCharityFee = _buyBackFee; _previousMarketFee = _marketFee; _taxFee = 0; _liquidityFee = 0; _buyBackFee = 0; _marketFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; _buyBackFee = _previousCharityFee; _marketFee = _previousMarketFee; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "BEP20: transfer from the zero address"); require(to != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "BEP20: Transfer amount must be greater than zero"); if(!_isExcludedFromMaxTx[from] && !_isExcludedFromMaxTx[to] // by default false ){ require(amount <= _maxTxAmount,"BEP20: Amount exceed max limit"); } // swap and liquify swapAndLiquify(from, to); //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to] || reflectionFeesdiabled) { takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from, to, amount, takeFee); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if (!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if (!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); uint256 tTransferAmount = tAmount.sub(totalFeePerTx(tAmount)); uint256 rAmount = tAmount.mul(currentRate); uint256 rTransferAmount = rAmount.sub(totalFeePerTx(tAmount).mul(currentRate)); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeAllFee(tAmount, currentRate); _reflectFee(tAmount); emit Transfer(sender, recipient, tTransferAmount); } function swapAndLiquify(address from, address to) private { // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is pancake pair. uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool shouldSell = contractTokenBalance >= minTokenNumberToSell; if ( !inSwapAndLiquify && shouldSell && from != pancakePair && swapAndLiquifyEnabled && !(from == address(this) && to == address(pancakePair)) // swap 1 time ) { // only sell for minTokenNumberToSell, decouple from _maxTxAmount // split the contract balance into 4 pieces contractTokenBalance = minTokenNumberToSell; // approve contract _approve(address(this), address(pancakeRouter), contractTokenBalance); uint256 totalPercent = _liquidityFee.add(_buyBackFee).add(_marketFee); uint256 lpPercent = _liquidityFee.mul(1e4).div(totalPercent).div(2); uint256 bbPercent = _buyBackFee.mul(1e4).div(totalPercent); uint256 mwPercent = _marketFee.mul(1e4).div(totalPercent); uint256 otherPiece = contractTokenBalance.mul(lpPercent).div(1e4); uint256 tokenAmountToBeSwapped = contractTokenBalance.sub(otherPiece); // now is to lock into staking pool Utils.swapTokensForEth(address(pancakeRouter), tokenAmountToBeSwapped); // how much BNB did we just swap into? // capture the contract's current BNB balance. // this is so that we can capture exactly the amount of BNB that the // swap creates, and not make the liquidity event include any BNB that // has been manually sent to the contract uint256 deltaBalance = getContractBalance(); totalPercent = lpPercent.add(bbPercent).add(mwPercent); uint256 bnbToBeAddedToLiquidity = deltaBalance.mul(lpPercent).div(totalPercent); // add liquidity to pancake Utils.addLiquidity(address(pancakeRouter), owner(), otherPiece, bnbToBeAddedToLiquidity); // buybcak fee transfer buyBackWallet.transfer(deltaBalance.mul(bbPercent).div(totalPercent)); // market fee transfer marketWallet.transfer(getContractBalance()); emit SwapAndLiquify(tokenAmountToBeSwapped, deltaBalance, otherPiece); } } }
// Modified by team BloctechSolutions.com
LineComment
_tokenTransfer
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if (!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if (!takeFee) restoreAllFee(); }
//this method is responsible for taking all fee, if takeFee is true
LineComment
v0.8.4+commit.c7e474f2
Unlicense
ipfs://e72b98690cfc1e288a84fa746d49e470128460cebaa866cd908c389345a7c41e
{ "func_code_index": [ 13338, 14164 ] }
55,792
MetaHedonistsNFT
contracts/4_TheHedonistNFT.sol
0xb16ffafcaa7255a3e112af8d705764ac7c5d175c
Solidity
MetaHedonistsNFT
contract MetaHedonistsNFT is ERC721, ERC721Enumerable, Ownable { // Mapping from tokenId to image base64 mapping(uint256 => string) private _tokenImages; // Mapping from tokenId to image sha256 mapping(uint256 => bytes32) private _tokenHashes; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; bool public _isSaleStart; string private _baseTokenURI; uint256 private _mintedTokenIDSum; address private _beneficiary1; address private _beneficiary2; // Mapping from pack num to pack cost mapping(uint256 => uint256) private _packCosts; // Mapping from pack num to pack`s token ID sum mapping(uint256 => uint256) private _packLimit; constructor(string memory baseTokenURI, address beneficiary1, address beneficiary2) ERC721("MetaHedonists", "METAHEDONISTS") { _baseTokenURI = baseTokenURI; _beneficiary1 = beneficiary1; _beneficiary2 = beneficiary2; _packLimit[1] = 499500; // sum from #0 to #999 _packLimit[2] = 1999000; // sum from #0 to #1999 _packLimit[3] = 4498500; // sum from #0 to #2999 _packLimit[4] = 7998000; // sum from #0 to #3999 _packLimit[5] = 12497500; // sum from #0 to #4999 _packLimit[6] = 17997000; // sum from #0 to #5999 _packLimit[7] = 24496500; // sum from #0 to #6999 _packLimit[8] = 31996000; // sum from #0 to #7999 _packLimit[9] = 40495500; // sum from #0 to #8999 _packLimit[10] = 49995000; // sum from #0 to #9999 _packCosts[1] = 0.01*10**18; // 0.01 _packCosts[2] = 0.02*10**18; // 0.02 _packCosts[3] = 0.02*10**18; // 0.02 _packCosts[4] = 0.05*10**18; // 0.05 _packCosts[5] = 0.05*10**18; // 0.05 _packCosts[6] = 0.05*10**18; // 0.05 _packCosts[7] = 0.1*10**18; // 0.1 _packCosts[8] = 0.1*10**18; // 0.1 _packCosts[9] = 0.1*10**18; // 0.1 _packCosts[10] = 1*10**18; // 1 _isSaleStart = false; } function mintedTokenIDSum() public virtual view returns (uint256) { return _mintedTokenIDSum; } function _baseURI() internal view override returns (string memory) { return _baseTokenURI; } function _pack(uint256 tokenId) internal pure returns (uint256) { uint256 pack; if (tokenId <= 999) { pack = 1; } else if (tokenId <= 1999) { pack = 2; } else if (tokenId <= 2999) { pack = 3; } else if (tokenId <= 3999) { pack = 4; } else if (tokenId <= 4999) { pack = 5; } else if (tokenId <= 5999) { pack = 6; } else if (tokenId <= 6999) { pack = 7; } else if (tokenId <= 7999) { pack = 8; } else if (tokenId <= 8999) { pack = 9; } else if (tokenId <= 9999) { pack = 10; } return pack; } function changeBeneficiary(address beneficiary1, address beneficiary2) public virtual onlyOwner { _beneficiary1 = beneficiary1; _beneficiary2 = beneficiary2; } function changeBaseURI(string memory newBaseURI) public virtual onlyOwner { _baseTokenURI = newBaseURI; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "METAHEDONISTS: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; // If _tokenURI is set, return the token URI. if (bytes(_tokenURI).length > 0) { return _tokenURI; } return super.tokenURI(tokenId); } function setTokenURIs(uint256[] memory tokenIDs, string[] memory tokenURIs) public virtual onlyOwner { require(tokenIDs.length == tokenURIs.length, "METAHEDONISTS: tokenIDs length must be equal to tokenURIs length"); for(uint256 index = 0; index < tokenIDs.length; index++) { uint256 tokenID = tokenIDs[index]; require(_exists(tokenID), "METAHEDONISTS: URI set of nonexistent token"); _tokenURIs[tokenID] = tokenURIs[index]; } } function getImage(uint256 tokenId) public virtual view returns (string memory) { require(_exists(tokenId), "METAHEDONISTS: get image of nonexistent token"); return string(abi.encodePacked("data:image/png;base64,", _tokenImages[tokenId])); } function setImages(uint256[] memory tokenIDs, string[] memory images) public virtual onlyOwner { require(tokenIDs.length == images.length, "METAHEDONISTS: tokenIDs length must be equal to images length"); for(uint256 index = 0; index < tokenIDs.length; index++) { uint256 tokenID = tokenIDs[index]; _tokenHashes[tokenID] = sha256(abi.encodePacked(images[index])); _tokenImages[tokenID] = images[index]; } } function getHash(uint256 tokenId) public virtual view returns (bytes32) { return _tokenHashes[tokenId]; } function setHashes(uint256[] memory tokenIDs, bytes32[] memory hashes) public virtual onlyOwner { require(tokenIDs.length == hashes.length, "METAHEDONISTS: tokenIDs length must be equal to hashes length"); for(uint256 index = 0; index < tokenIDs.length; index++) { _tokenHashes[tokenIDs[index]] = hashes[index]; } } function airDrop(uint256[] memory tokenIDs, address[] memory holders) public virtual onlyOwner { require(tokenIDs.length == holders.length, "METAHEDONISTS: tokenIDs length must be equal to holders length"); for(uint256 index = 0; index < tokenIDs.length; index++) { uint256 tokenID = tokenIDs[index]; _safeMint(holders[index], tokenID); _mintedTokenIDSum += tokenID; } } function startSale() public virtual onlyOwner { _isSaleStart = true; } function mint(string memory image, uint256 tokenId) public virtual payable { require(_isSaleStart, "METAHEDONISTS: sale has not started yet"); require(!_exists(tokenId), "METAHEDONISTS: this token has already been minted"); require(tokenId <= 9999, "METAHEDONISTS: token ID number is exceeded"); require(sha256(abi.encodePacked(image)) == _tokenHashes[tokenId], "METAHEDONISTS: not original image"); uint256 pack = _pack(tokenId); require(_mintedTokenIDSum <= _packLimit[pack], "METAHEDONISTS: pack is pending yet. Purchase a token of a current pack or wait please."); require(msg.value == _packCosts[pack], "METAHEDONISTS: value must equal to NFT cost"); // Mint NFT to buyer _safeMint(_msgSender(), tokenId); // Transfer NFT cost to beneficiaries payable(_beneficiary1).transfer(msg.value/2); payable(_beneficiary2).transfer(msg.value/2); // Increase token ID sum _mintedTokenIDSum += tokenId; // Store image _tokenImages[tokenId] = image; } function withdraw(uint256 _amount) public virtual onlyOwner { require(_amount <= address(this).balance); payable(_msgSender()).transfer(_amount); } // The following functions are overrides required by Solidity. function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } }
_beforeTokenTransfer
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); }
// The following functions are overrides required by Solidity.
LineComment
v0.8.7+commit.e28d00a7
MIT
ipfs://665d9e703b329f24872d841fb92375d68344de792c2d6abef52199f4f9dad4a0
{ "func_code_index": [ 7569, 7755 ] }
55,793
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
IERC20
interface IERC20 { 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); }
balanceOf
function balanceOf(address account) external view returns (uint256);
/** * @dev Returns the amount of tokens owned by `account`. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 165, 238 ] }
55,794
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
IERC20
interface IERC20 { 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); }
transfer
function transfer(address recipient, uint256 amount) external returns (bool);
/** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 462, 544 ] }
55,795
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
IERC20
interface IERC20 { 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); }
allowance
function allowance(address owner, address spender) external view returns (uint256);
/** * @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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 823, 911 ] }
55,796
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
IERC20
interface IERC20 { 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); }
approve
function approve(address spender, uint256 amount) external returns (bool);
/** * @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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 1575, 1654 ] }
55,797
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
IERC20
interface IERC20 { 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); }
transferFrom
function transferFrom(address sender, address recipient, 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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 1967, 2069 ] }
55,798
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
SafeMath
library SafeMath { /** * @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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @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. */
NatSpecMultiLine
add
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 addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 259, 445 ] }
55,799
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
SafeMath
library SafeMath { /** * @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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @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. */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); }
/** * @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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 723, 864 ] }
55,800
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
SafeMath
library SafeMath { /** * @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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @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. */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; }
/** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 1162, 1359 ] }
55,801
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
SafeMath
library SafeMath { /** * @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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @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. */
NatSpecMultiLine
mul
function mul(uint256 a, uint256 b) internal pure returns (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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; }
/** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 1613, 2089 ] }
55,802
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
SafeMath
library SafeMath { /** * @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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @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. */
NatSpecMultiLine
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); }
/** * @dev Returns the integer division of two unsigned integers. Reverts 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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 2560, 2697 ] }
55,803
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
SafeMath
library SafeMath { /** * @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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @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. */
NatSpecMultiLine
div
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
/** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 3188, 3471 ] }
55,804
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
SafeMath
library SafeMath { /** * @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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @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. */
NatSpecMultiLine
mod
function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); }
/** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 3931, 4066 ] }
55,805
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
SafeMath
library SafeMath { /** * @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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @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. */
NatSpecMultiLine
mod
function mod(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), * Reverts with custom message 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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 4546, 4717 ] }
55,806
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
Address
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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
isContract
function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); }
/** * @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 * ==== */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 606, 1230 ] }
55,807
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
Address
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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
sendValue
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 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]. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 2160, 2562 ] }
55,808
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
Address
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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCall
function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); }
/** * @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._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 3318, 3496 ] }
55,809
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
Address
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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCall
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 with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 3721, 3922 ] }
55,810
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
Address
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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCallWithValue
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-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._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 4292, 4523 ] }
55,811
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
Address
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) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCallWithValue
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"); return _functionCallWithValue(target, data, value, errorMessage); }
/** * @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._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 4774, 5095 ] }
55,812
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
Ownable
contract Ownable is Context { address private _owner; address payable private _processing; address private _burnAddress = address(0x0000000000000000000000000000000000000000); address private _lockedLiquidity; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } function lockedLiquidity() public view returns (address) { return _lockedLiquidity; } function processing() public view returns (address payable) { return _processing; } function burn() public view returns (address) { return _burnAddress; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } modifier onlyProcessing() { require(_processing == _msgSender(), "Caller is not the processing fee address"); _; } /** * @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 { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function setProcessingAddress(address payable processingAddress) public virtual onlyOwner { _processing = processingAddress; } function setLockedLiquidityAddress(address liquidityAddress) public virtual onlyOwner { _lockedLiquidity = liquidityAddress; } }
/** * @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. */
NatSpecMultiLine
owner
function owner() public view returns (address) { return _owner; }
/** * @dev Returns the address of the current owner. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 667, 751 ] }
55,813
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
Ownable
contract Ownable is Context { address private _owner; address payable private _processing; address private _burnAddress = address(0x0000000000000000000000000000000000000000); address private _lockedLiquidity; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } function lockedLiquidity() public view returns (address) { return _lockedLiquidity; } function processing() public view returns (address payable) { return _processing; } function burn() public view returns (address) { return _burnAddress; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } modifier onlyProcessing() { require(_processing == _msgSender(), "Caller is not the processing fee address"); _; } /** * @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 { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function setProcessingAddress(address payable processingAddress) public virtual onlyOwner { _processing = processingAddress; } function setLockedLiquidityAddress(address liquidityAddress) public virtual onlyOwner { _lockedLiquidity = liquidityAddress; } }
/** * @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. */
NatSpecMultiLine
renounceOwnership
function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); }
/** * @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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 1797, 1950 ] }
55,814
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
GapeToken
contract GapeToken is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isDevWallet; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "GiantApe"; string private _symbol = "GAPE"; uint8 private _decimals = 9; uint256 public _taxFee = 0; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 6; uint256 private _processingPercentageOfLiquidity = 33; uint256 private _previousLiquidityFee = _liquidityFee; uint256 private _totalProcessingFees = 0; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 1000 * 10**6 * 10**9; uint256 private numTokensSellToAddToLiquidity = 1 * 10**6 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () public { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[burn()] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } 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; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function processingPercentageOfLiquidity() public view returns (uint256) { return _processingPercentageOfLiquidity; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function devWallet(address account) public view returns(bool) { return _isDevWallet[account]; } function setAsDevWallet(address account) external onlyOwner() { _isDevWallet[account] = true; } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function setDevWalletFee() private { //Any dev wallets are subjected to a higher fee (2x) if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _liquidityFee = _liquidityFee.mul(2); _taxFee = _taxFee.mul(2); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { 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); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(to != processing(), "The processing address cannot receive tokens"); require(from != processing(), "The processing address cannot send tokens"); require(amount > 0, "Transfer amount must be greater than zero"); if((from != owner() && to != owner())) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function collectProcessing() public onlyProcessing { _totalProcessingFees = _totalProcessingFees.add(address(this).balance); processing().transfer(address(this).balance); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract // this also ignores any ETH that was reserved for processing last time // this was called uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); //Now reserve a percentage of that eth for processing fee uint256 balanceToProcessing = (newBalance.mul(processingPercentageOfLiquidity())).div(10**2); uint256 tokensExtra = (otherHalf.mul(processingPercentageOfLiquidity())).div(10**2); //How much eth is left for liquidity? newBalance = newBalance.sub(balanceToProcessing); //how many tokens are left for liquidity? otherHalf = otherHalf.sub(tokensExtra); //Leftover tokens will be swapped into liquidity the next time this is called // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable lockedLiquidity(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if(devWallet(sender)) setDevWalletFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); if(devWallet(sender)) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
//to recieve ETH from uniswapV2Router when swaping
LineComment
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 8276, 8310 ] }
55,815
GapeToken
GapeToken.sol
0x5cd347025aee70a5395a50c2761b5d2fee40922d
Solidity
GapeToken
contract GapeToken is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isDevWallet; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "GiantApe"; string private _symbol = "GAPE"; uint8 private _decimals = 9; uint256 public _taxFee = 0; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 6; uint256 private _processingPercentageOfLiquidity = 33; uint256 private _previousLiquidityFee = _liquidityFee; uint256 private _totalProcessingFees = 0; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 1000 * 10**6 * 10**9; uint256 private numTokensSellToAddToLiquidity = 1 * 10**6 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () public { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[burn()] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } 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; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function processingPercentageOfLiquidity() public view returns (uint256) { return _processingPercentageOfLiquidity; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function devWallet(address account) public view returns(bool) { return _isDevWallet[account]; } function setAsDevWallet(address account) external onlyOwner() { _isDevWallet[account] = true; } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function setDevWalletFee() private { //Any dev wallets are subjected to a higher fee (2x) if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _liquidityFee = _liquidityFee.mul(2); _taxFee = _taxFee.mul(2); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { 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); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(to != processing(), "The processing address cannot receive tokens"); require(from != processing(), "The processing address cannot send tokens"); require(amount > 0, "Transfer amount must be greater than zero"); if((from != owner() && to != owner())) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function collectProcessing() public onlyProcessing { _totalProcessingFees = _totalProcessingFees.add(address(this).balance); processing().transfer(address(this).balance); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract // this also ignores any ETH that was reserved for processing last time // this was called uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); //Now reserve a percentage of that eth for processing fee uint256 balanceToProcessing = (newBalance.mul(processingPercentageOfLiquidity())).div(10**2); uint256 tokensExtra = (otherHalf.mul(processingPercentageOfLiquidity())).div(10**2); //How much eth is left for liquidity? newBalance = newBalance.sub(balanceToProcessing); //how many tokens are left for liquidity? otherHalf = otherHalf.sub(tokensExtra); //Leftover tokens will be swapped into liquidity the next time this is called // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable lockedLiquidity(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if(devWallet(sender)) setDevWalletFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); if(devWallet(sender)) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
_tokenTransfer
function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if(devWallet(sender)) setDevWalletFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); if(devWallet(sender)) restoreAllFee(); }
//this method is responsible for taking all fee, if takeFee is true
LineComment
v0.6.12+commit.27d51765
None
ipfs://ecd4533be653630be736c2a5a5448d0a5d511a98374ac2562b2ce25cd78a8611
{ "func_code_index": [ 17426, 18373 ] }
55,816
TokenTimelockVault
TokenTimelockVault.sol
0xa9fed80262bfa6d6981711f0c3661dc82ac27132
Solidity
Ownable
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
renounceOwnership
function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); }
/** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://c1efb24f4cd36f9139647ea866a8f7c6674bdacb6c597ca8428ec4ae0cea4ffe
{ "func_code_index": [ 815, 932 ] }
55,817
TokenTimelockVault
TokenTimelockVault.sol
0xa9fed80262bfa6d6981711f0c3661dc82ac27132
Solidity
Ownable
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
transferOwnership
function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); }
/** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://c1efb24f4cd36f9139647ea866a8f7c6674bdacb6c597ca8428ec4ae0cea4ffe
{ "func_code_index": [ 1097, 1205 ] }
55,818
TokenTimelockVault
TokenTimelockVault.sol
0xa9fed80262bfa6d6981711f0c3661dc82ac27132
Solidity
Ownable
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
_transferOwnership
function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; }
/** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://c1efb24f4cd36f9139647ea866a8f7c6674bdacb6c597ca8428ec4ae0cea4ffe
{ "func_code_index": [ 1343, 1521 ] }
55,819
TokenTimelockVault
TokenTimelockVault.sol
0xa9fed80262bfa6d6981711f0c3661dc82ac27132
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } 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 a / b; } /** * @dev Subtracts 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 c) { c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; }
/** * @dev Multiplies two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://c1efb24f4cd36f9139647ea866a8f7c6674bdacb6c597ca8428ec4ae0cea4ffe
{ "func_code_index": [ 89, 476 ] }
55,820
TokenTimelockVault
TokenTimelockVault.sol
0xa9fed80262bfa6d6981711f0c3661dc82ac27132
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } 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 a / b; } /** * @dev Subtracts 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 c) { c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
div
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 a / b; }
/** * @dev Integer division of two numbers, truncating the quotient. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://c1efb24f4cd36f9139647ea866a8f7c6674bdacb6c597ca8428ec4ae0cea4ffe
{ "func_code_index": [ 560, 840 ] }
55,821
TokenTimelockVault
TokenTimelockVault.sol
0xa9fed80262bfa6d6981711f0c3661dc82ac27132
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } 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 a / b; } /** * @dev Subtracts 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 c) { c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; }
/** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://c1efb24f4cd36f9139647ea866a8f7c6674bdacb6c597ca8428ec4ae0cea4ffe
{ "func_code_index": [ 954, 1070 ] }
55,822
TokenTimelockVault
TokenTimelockVault.sol
0xa9fed80262bfa6d6981711f0c3661dc82ac27132
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } 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 a / b; } /** * @dev Subtracts 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 c) { c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath * @dev Math operations with safety checks that throw on error */
NatSpecMultiLine
add
function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; }
/** * @dev Adds two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://c1efb24f4cd36f9139647ea866a8f7c6674bdacb6c597ca8428ec4ae0cea4ffe
{ "func_code_index": [ 1134, 1264 ] }
55,823
TokenTimelockVault
TokenTimelockVault.sol
0xa9fed80262bfa6d6981711f0c3661dc82ac27132
Solidity
Lockable
contract Lockable is Ownable { bool public isLocked = false; event Locked(); /** * @dev Must be called after crowdsale ends, to do some extra finalization * work. Calls the contract's finalization function. */ function lock() onlyOwner public { require(!isLocked); emit Locked(); isLocked = true; } modifier notLocked() { require(!isLocked); _; } }
lock
function lock() onlyOwner public { require(!isLocked); emit Locked(); isLocked = true; }
/** * @dev Must be called after crowdsale ends, to do some extra finalization * work. Calls the contract's finalization function. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://c1efb24f4cd36f9139647ea866a8f7c6674bdacb6c597ca8428ec4ae0cea4ffe
{ "func_code_index": [ 250, 379 ] }
55,824
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
_add
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 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. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 908, 1327 ] }
55,825
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
_remove
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 Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 1498, 3047 ] }
55,826
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
_contains
function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; }
/** * @dev Returns true if the value is in the set. O(1). */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 3128, 3262 ] }
55,827
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
_length
function _length(Set storage set) private view returns (uint256) { return set._values.length; }
/** * @dev Returns the number of values on the set. O(1). */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 3343, 3457 ] }
55,828
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
_at
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]; }
/** * @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}. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 3796, 4005 ] }
55,829
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
add
function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(value))); }
/** * @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. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 4254, 4402 ] }
55,830
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
remove
function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(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. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 4573, 4727 ] }
55,831
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
contains
function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(value))); }
/** * @dev Returns true if the value is in the set. O(1). */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 4808, 4971 ] }
55,832
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
length
function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); }
/** * @dev Returns the number of values in the set. O(1). */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 5052, 5174 ] }
55,833
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
at
function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint256(_at(set._inner, index))); }
/** * @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}. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 5513, 5667 ] }
55,834
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
add
function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); }
/** * @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. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 5912, 6048 ] }
55,835
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
remove
function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(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. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 6219, 6361 ] }
55,836
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
contains
function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); }
/** * @dev Returns true if the value is in the set. O(1). */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 6442, 6593 ] }
55,837
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
length
function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); }
/** * @dev Returns the number of values on the set. O(1). */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 6674, 6793 ] }
55,838
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
EnumerableSet
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]; } // 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(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(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(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(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)); } }
/** * @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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */
NatSpecMultiLine
at
function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); }
/** * @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}. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 7132, 7274 ] }
55,839
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
Address
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 in 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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
isContract
function isContract(address account) internal view returns (bool) { // This method relies in 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 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 * ==== */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 606, 1033 ] }
55,840
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
Address
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 in 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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
sendValue
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 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]. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 1963, 2365 ] }
55,841
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
Address
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 in 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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCall
function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); }
/** * @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._ */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 3121, 3299 ] }
55,842
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
Address
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 in 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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCall
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 with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 3524, 3725 ] }
55,843
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
Address
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 in 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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCallWithValue
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-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._ */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 4095, 4326 ] }
55,844
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
Address
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 in 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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCallWithValue
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"); return _functionCallWithValue(target, data, value, errorMessage); }
/** * @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._ */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 4577, 4898 ] }
55,845
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
AccessControl
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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); require(role != DEFAULT_ADMIN_ROLE); _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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); require(role != DEFAULT_ADMIN_ROLE); _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) internal { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) internal { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } }
/** * @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. */
NatSpecMultiLine
hasRole
function hasRole(bytes32 role, address account) public view returns (bool) { return _roles[role].members.contains(account); }
/** * @dev Returns `true` if `account` has been granted `role`. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 1546, 1690 ] }
55,846
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
AccessControl
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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); require(role != DEFAULT_ADMIN_ROLE); _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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); require(role != DEFAULT_ADMIN_ROLE); _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) internal { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) internal { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } }
/** * @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. */
NatSpecMultiLine
getRoleMemberCount
function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); }
/** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 1859, 1991 ] }
55,847
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
AccessControl
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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); require(role != DEFAULT_ADMIN_ROLE); _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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); require(role != DEFAULT_ADMIN_ROLE); _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) internal { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) internal { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } }
/** * @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. */
NatSpecMultiLine
getRoleMember
function getRoleMember(bytes32 role, uint256 index) public view returns (address) { return _roles[role].members.at(index); }
/** * @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. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 2585, 2728 ] }
55,848
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
AccessControl
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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); require(role != DEFAULT_ADMIN_ROLE); _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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); require(role != DEFAULT_ADMIN_ROLE); _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) internal { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) internal { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } }
/** * @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. */
NatSpecMultiLine
getRoleAdmin
function getRoleAdmin(bytes32 role) public view returns (bytes32) { return _roles[role].adminRole; }
/** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 2912, 3031 ] }
55,849
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
AccessControl
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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); require(role != DEFAULT_ADMIN_ROLE); _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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); require(role != DEFAULT_ADMIN_ROLE); _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) internal { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) internal { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } }
/** * @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. */
NatSpecMultiLine
grantRole
function grantRole(bytes32 role, address account) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); require(role != DEFAULT_ADMIN_ROLE); _grantRole(role, account); }
/** * @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. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 3288, 3568 ] }
55,850
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
AccessControl
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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); require(role != DEFAULT_ADMIN_ROLE); _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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); require(role != DEFAULT_ADMIN_ROLE); _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) internal { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) internal { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } }
/** * @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. */
NatSpecMultiLine
revokeRole
function revokeRole(bytes32 role, address account) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); require(role != DEFAULT_ADMIN_ROLE); _revokeRole(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. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 3808, 4091 ] }
55,851
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
AccessControl
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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); require(role != DEFAULT_ADMIN_ROLE); _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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); require(role != DEFAULT_ADMIN_ROLE); _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) internal { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) internal { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } }
/** * @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. */
NatSpecMultiLine
renounceRole
function renounceRole(bytes32 role, address account) public virtual { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _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`. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 4593, 4807 ] }
55,852
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
AccessControl
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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); require(role != DEFAULT_ADMIN_ROLE); _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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); require(role != DEFAULT_ADMIN_ROLE); _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) internal { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) internal { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } }
/** * @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. */
NatSpecMultiLine
_setupRole
function _setupRole(bytes32 role, address account) internal virtual { _grantRole(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}. * ==== */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 5385, 5502 ] }
55,853
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
AccessControl
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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); require(role != DEFAULT_ADMIN_ROLE); _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) internal virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); require(role != DEFAULT_ADMIN_ROLE); _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) internal { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) internal { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } }
/** * @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. */
NatSpecMultiLine
_setRoleAdmin
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; }
/** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */
NatSpecMultiLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 5629, 5833 ] }
55,854
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
MultiSigWallet
contract MultiSigWallet is AccessControl { /* * Events */ event Confirmation(address indexed sender, uint256 indexed transactionId); event Revocation(address indexed sender, uint256 indexed transactionId); event Submission(uint256 indexed transactionId, address indexed sender); event Execution(uint256 indexed transactionId); event ExecutionFailure(uint256 indexed transactionId); event Deposit(address indexed sender, uint256 value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint256 required); /* * Constants */ uint256 public constant MAX_OWNER_COUNT = 3; /* * Storage */ bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); bytes public constant mintActionHash = abi.encodeWithSignature( "mint(uint256)" ); bytes public constant burnActionHash = abi.encodeWithSignature( "burn(uint256)" ); mapping(uint256 => Transaction) public transactions; mapping(uint256 => mapping(address => bool)) public confirmations; mapping(address => bool) public isOwner; address[] public owners; uint256 public required; uint256 public transactionCount; struct Transaction { address destination; uint256 value; bytes data; bool executed; address sender; uint256 timestamp; } /* * Modifiers */ modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint256 transactionId) { require(transactions[transactionId].destination != address(0)); _; } modifier confirmed(uint256 transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint256 transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint256 transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != address(0)); _; } modifier validRequirement(uint256 ownerCount, uint256 _required) { require( ownerCount <= MAX_OWNER_COUNT && _required <= ownerCount && _required != 0 && ownerCount != 0 ); _; } /// @dev Fallback function allows to deposit ether. receive() external payable { if (msg.value > 0) emit Deposit(msg.sender, msg.value); } /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. constructor(address[] memory _owners, uint256 _required) public validRequirement(_owners.length, _required) { _setupRole(DEFAULT_ADMIN_ROLE, address(this)); for (uint256 i = 0; i < _owners.length; i++) { require(!isOwner[_owners[i]] && _owners[i] != address(0)); isOwner[_owners[i]] = true; _setupRole(DEFAULT_ADMIN_ROLE, _owners[i]); } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. // function addOwner(address owner) // public // onlyWallet // ownerDoesNotExist(owner) // notNull(owner) // validRequirement(owners.length + 1, required) // { // isOwner[owner] = true; // owners.push(owner); // _setupRole(DEFAULT_ADMIN_ROLE, owner); // emit OwnerAddition(owner); // } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. // function removeOwner(address owner) public onlyWallet ownerExists(owner) { // isOwner[owner] = false; // for (uint256 i = 0; i < owners.length - 1; i++) // if (owners[i] == owner) { // owners[i] = owners[owners.length - 1]; // break; // } // owners.pop(); // if (required > owners.length) changeRequirement(owners.length); // emit OwnerRemoval(owner); // } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param newOwner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint256 i = 0; i < owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; _revokeRole(DEFAULT_ADMIN_ROLE, owner); isOwner[newOwner] = true; _grantRole(DEFAULT_ADMIN_ROLE, newOwner); emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. // function changeRequirement(uint256 _required) // public // onlyWallet // validRequirement(owners.length, _required) // { // required = _required; // emit RequirementChange(_required); // } /// @dev Allows an owner/admin, minter, burner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId transaction ID. function submitTransaction( address destination, uint256 value, bytes memory data ) public ownerExists(msg.sender) returns (uint256 transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } function submitMintTransaction(address destination, bytes memory data) public returns (uint256 transactionId) { require( hasRole(MINTER_ROLE, msg.sender) || isOwner[msg.sender], "Caller is not a minter or admin" ); bytes memory actionHash = abi.encodePacked(mintActionHash, data); transactionId = addTransaction(destination, 0, actionHash); } function submitBurnTransaction(address destination, bytes memory data) public returns (uint256 transactionId) { require( hasRole(BURNER_ROLE, msg.sender) || isOwner[msg.sender], "Caller is not a burner or admin" ); bytes memory actionHash = abi.encodePacked(burnActionHash, data); transactionId = addTransaction(destination, 0, actionHash); } function grantRoleTransaction(bytes32 _role, address _account) public onlyWallet { grantRole(_role, _account); } function revokeRoleTransaction(bytes32 _role, address _account) public onlyWallet { revokeRole(_role, _account); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint256 transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if ( external_call( txn.destination, txn.value, txn.data.length, txn.data ) ) emit Execution(transactionId); else { emit ExecutionFailure(transactionId); txn.executed = false; } } } // call has been separated into its own function in order to take advantage // of the Solidity's code generator to produce a loop that copies tx.data into memory. function external_call( address destination, uint256 value, uint256 dataLength, bytes memory data ) internal returns (bool) { bool result; assembly { let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention) let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that result := call( sub(gas(), 34710), // 34710 is the value that solidity is currently emitting // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) + // callNewAccountGas (25000, in case the destination address does not exist and needs creating) destination, value, d, dataLength, // Size of the input (in bytes) - this is what fixes the padding problem x, 0 // Output is ignored, therefore the output size is zero ) } return result; } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint256 transactionId) public view returns (bool) { uint256 count = 0; for (uint256 i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId transaction ID. function addTransaction( address destination, uint256 value, bytes memory data ) internal notNull(destination) returns (uint256 transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false, sender: msg.sender, timestamp: now }); transactionCount += 1; emit Submission(transactionId, msg.sender); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return count Number of confirmations. function getConfirmationCount(uint256 transactionId) public view returns (uint256 count) { for (uint256 i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return count Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public view returns (uint256 count) { for (uint256 i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public view returns (address[] memory) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return _confirmations Returns array of owner addresses. function getConfirmations(uint256 transactionId) public view returns (address[] memory _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint256 count = 0; uint256 i; for (i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i = 0; i < count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return _transactionIds Returns array of transaction IDs. function getTransactionIds( uint256 from, uint256 to, bool pending, bool executed ) public view returns (uint256[] memory _transactionIds) { uint256[] memory transactionIdsTemp = new uint256[](transactionCount); uint256 count = 0; uint256 i; for (i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint256[](to - from); for (i = from; i < to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } function renounceRole(bytes32 role, address account) public virtual override { revert("Cannot renounceRole"); } }
/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
NatSpecSingleLine
/// @dev Fallback function allows to deposit ether.
NatSpecSingleLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 2902, 3007 ] }
55,855
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
MultiSigWallet
contract MultiSigWallet is AccessControl { /* * Events */ event Confirmation(address indexed sender, uint256 indexed transactionId); event Revocation(address indexed sender, uint256 indexed transactionId); event Submission(uint256 indexed transactionId, address indexed sender); event Execution(uint256 indexed transactionId); event ExecutionFailure(uint256 indexed transactionId); event Deposit(address indexed sender, uint256 value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint256 required); /* * Constants */ uint256 public constant MAX_OWNER_COUNT = 3; /* * Storage */ bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); bytes public constant mintActionHash = abi.encodeWithSignature( "mint(uint256)" ); bytes public constant burnActionHash = abi.encodeWithSignature( "burn(uint256)" ); mapping(uint256 => Transaction) public transactions; mapping(uint256 => mapping(address => bool)) public confirmations; mapping(address => bool) public isOwner; address[] public owners; uint256 public required; uint256 public transactionCount; struct Transaction { address destination; uint256 value; bytes data; bool executed; address sender; uint256 timestamp; } /* * Modifiers */ modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint256 transactionId) { require(transactions[transactionId].destination != address(0)); _; } modifier confirmed(uint256 transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint256 transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint256 transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != address(0)); _; } modifier validRequirement(uint256 ownerCount, uint256 _required) { require( ownerCount <= MAX_OWNER_COUNT && _required <= ownerCount && _required != 0 && ownerCount != 0 ); _; } /// @dev Fallback function allows to deposit ether. receive() external payable { if (msg.value > 0) emit Deposit(msg.sender, msg.value); } /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. constructor(address[] memory _owners, uint256 _required) public validRequirement(_owners.length, _required) { _setupRole(DEFAULT_ADMIN_ROLE, address(this)); for (uint256 i = 0; i < _owners.length; i++) { require(!isOwner[_owners[i]] && _owners[i] != address(0)); isOwner[_owners[i]] = true; _setupRole(DEFAULT_ADMIN_ROLE, _owners[i]); } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. // function addOwner(address owner) // public // onlyWallet // ownerDoesNotExist(owner) // notNull(owner) // validRequirement(owners.length + 1, required) // { // isOwner[owner] = true; // owners.push(owner); // _setupRole(DEFAULT_ADMIN_ROLE, owner); // emit OwnerAddition(owner); // } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. // function removeOwner(address owner) public onlyWallet ownerExists(owner) { // isOwner[owner] = false; // for (uint256 i = 0; i < owners.length - 1; i++) // if (owners[i] == owner) { // owners[i] = owners[owners.length - 1]; // break; // } // owners.pop(); // if (required > owners.length) changeRequirement(owners.length); // emit OwnerRemoval(owner); // } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param newOwner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint256 i = 0; i < owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; _revokeRole(DEFAULT_ADMIN_ROLE, owner); isOwner[newOwner] = true; _grantRole(DEFAULT_ADMIN_ROLE, newOwner); emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. // function changeRequirement(uint256 _required) // public // onlyWallet // validRequirement(owners.length, _required) // { // required = _required; // emit RequirementChange(_required); // } /// @dev Allows an owner/admin, minter, burner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId transaction ID. function submitTransaction( address destination, uint256 value, bytes memory data ) public ownerExists(msg.sender) returns (uint256 transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } function submitMintTransaction(address destination, bytes memory data) public returns (uint256 transactionId) { require( hasRole(MINTER_ROLE, msg.sender) || isOwner[msg.sender], "Caller is not a minter or admin" ); bytes memory actionHash = abi.encodePacked(mintActionHash, data); transactionId = addTransaction(destination, 0, actionHash); } function submitBurnTransaction(address destination, bytes memory data) public returns (uint256 transactionId) { require( hasRole(BURNER_ROLE, msg.sender) || isOwner[msg.sender], "Caller is not a burner or admin" ); bytes memory actionHash = abi.encodePacked(burnActionHash, data); transactionId = addTransaction(destination, 0, actionHash); } function grantRoleTransaction(bytes32 _role, address _account) public onlyWallet { grantRole(_role, _account); } function revokeRoleTransaction(bytes32 _role, address _account) public onlyWallet { revokeRole(_role, _account); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint256 transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if ( external_call( txn.destination, txn.value, txn.data.length, txn.data ) ) emit Execution(transactionId); else { emit ExecutionFailure(transactionId); txn.executed = false; } } } // call has been separated into its own function in order to take advantage // of the Solidity's code generator to produce a loop that copies tx.data into memory. function external_call( address destination, uint256 value, uint256 dataLength, bytes memory data ) internal returns (bool) { bool result; assembly { let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention) let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that result := call( sub(gas(), 34710), // 34710 is the value that solidity is currently emitting // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) + // callNewAccountGas (25000, in case the destination address does not exist and needs creating) destination, value, d, dataLength, // Size of the input (in bytes) - this is what fixes the padding problem x, 0 // Output is ignored, therefore the output size is zero ) } return result; } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint256 transactionId) public view returns (bool) { uint256 count = 0; for (uint256 i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId transaction ID. function addTransaction( address destination, uint256 value, bytes memory data ) internal notNull(destination) returns (uint256 transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false, sender: msg.sender, timestamp: now }); transactionCount += 1; emit Submission(transactionId, msg.sender); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return count Number of confirmations. function getConfirmationCount(uint256 transactionId) public view returns (uint256 count) { for (uint256 i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return count Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public view returns (uint256 count) { for (uint256 i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public view returns (address[] memory) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return _confirmations Returns array of owner addresses. function getConfirmations(uint256 transactionId) public view returns (address[] memory _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint256 count = 0; uint256 i; for (i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i = 0; i < count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return _transactionIds Returns array of transaction IDs. function getTransactionIds( uint256 from, uint256 to, bool pending, bool executed ) public view returns (uint256[] memory _transactionIds) { uint256[] memory transactionIdsTemp = new uint256[](transactionCount); uint256 count = 0; uint256 i; for (i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint256[](to - from); for (i = from; i < to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } function renounceRole(bytes32 role, address account) public virtual override { revert("Cannot renounceRole"); } }
/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
NatSpecSingleLine
replaceOwner
function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint256 i = 0; i < owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; _revokeRole(DEFAULT_ADMIN_ROLE, owner); isOwner[newOwner] = true; _grantRole(DEFAULT_ADMIN_ROLE, newOwner); emit OwnerRemoval(owner); emit OwnerAddition(newOwner); }
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param newOwner Address of new owner.
NatSpecSingleLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 5053, 5639 ] }
55,856
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
MultiSigWallet
contract MultiSigWallet is AccessControl { /* * Events */ event Confirmation(address indexed sender, uint256 indexed transactionId); event Revocation(address indexed sender, uint256 indexed transactionId); event Submission(uint256 indexed transactionId, address indexed sender); event Execution(uint256 indexed transactionId); event ExecutionFailure(uint256 indexed transactionId); event Deposit(address indexed sender, uint256 value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint256 required); /* * Constants */ uint256 public constant MAX_OWNER_COUNT = 3; /* * Storage */ bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); bytes public constant mintActionHash = abi.encodeWithSignature( "mint(uint256)" ); bytes public constant burnActionHash = abi.encodeWithSignature( "burn(uint256)" ); mapping(uint256 => Transaction) public transactions; mapping(uint256 => mapping(address => bool)) public confirmations; mapping(address => bool) public isOwner; address[] public owners; uint256 public required; uint256 public transactionCount; struct Transaction { address destination; uint256 value; bytes data; bool executed; address sender; uint256 timestamp; } /* * Modifiers */ modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint256 transactionId) { require(transactions[transactionId].destination != address(0)); _; } modifier confirmed(uint256 transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint256 transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint256 transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != address(0)); _; } modifier validRequirement(uint256 ownerCount, uint256 _required) { require( ownerCount <= MAX_OWNER_COUNT && _required <= ownerCount && _required != 0 && ownerCount != 0 ); _; } /// @dev Fallback function allows to deposit ether. receive() external payable { if (msg.value > 0) emit Deposit(msg.sender, msg.value); } /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. constructor(address[] memory _owners, uint256 _required) public validRequirement(_owners.length, _required) { _setupRole(DEFAULT_ADMIN_ROLE, address(this)); for (uint256 i = 0; i < _owners.length; i++) { require(!isOwner[_owners[i]] && _owners[i] != address(0)); isOwner[_owners[i]] = true; _setupRole(DEFAULT_ADMIN_ROLE, _owners[i]); } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. // function addOwner(address owner) // public // onlyWallet // ownerDoesNotExist(owner) // notNull(owner) // validRequirement(owners.length + 1, required) // { // isOwner[owner] = true; // owners.push(owner); // _setupRole(DEFAULT_ADMIN_ROLE, owner); // emit OwnerAddition(owner); // } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. // function removeOwner(address owner) public onlyWallet ownerExists(owner) { // isOwner[owner] = false; // for (uint256 i = 0; i < owners.length - 1; i++) // if (owners[i] == owner) { // owners[i] = owners[owners.length - 1]; // break; // } // owners.pop(); // if (required > owners.length) changeRequirement(owners.length); // emit OwnerRemoval(owner); // } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param newOwner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint256 i = 0; i < owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; _revokeRole(DEFAULT_ADMIN_ROLE, owner); isOwner[newOwner] = true; _grantRole(DEFAULT_ADMIN_ROLE, newOwner); emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. // function changeRequirement(uint256 _required) // public // onlyWallet // validRequirement(owners.length, _required) // { // required = _required; // emit RequirementChange(_required); // } /// @dev Allows an owner/admin, minter, burner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId transaction ID. function submitTransaction( address destination, uint256 value, bytes memory data ) public ownerExists(msg.sender) returns (uint256 transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } function submitMintTransaction(address destination, bytes memory data) public returns (uint256 transactionId) { require( hasRole(MINTER_ROLE, msg.sender) || isOwner[msg.sender], "Caller is not a minter or admin" ); bytes memory actionHash = abi.encodePacked(mintActionHash, data); transactionId = addTransaction(destination, 0, actionHash); } function submitBurnTransaction(address destination, bytes memory data) public returns (uint256 transactionId) { require( hasRole(BURNER_ROLE, msg.sender) || isOwner[msg.sender], "Caller is not a burner or admin" ); bytes memory actionHash = abi.encodePacked(burnActionHash, data); transactionId = addTransaction(destination, 0, actionHash); } function grantRoleTransaction(bytes32 _role, address _account) public onlyWallet { grantRole(_role, _account); } function revokeRoleTransaction(bytes32 _role, address _account) public onlyWallet { revokeRole(_role, _account); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint256 transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if ( external_call( txn.destination, txn.value, txn.data.length, txn.data ) ) emit Execution(transactionId); else { emit ExecutionFailure(transactionId); txn.executed = false; } } } // call has been separated into its own function in order to take advantage // of the Solidity's code generator to produce a loop that copies tx.data into memory. function external_call( address destination, uint256 value, uint256 dataLength, bytes memory data ) internal returns (bool) { bool result; assembly { let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention) let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that result := call( sub(gas(), 34710), // 34710 is the value that solidity is currently emitting // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) + // callNewAccountGas (25000, in case the destination address does not exist and needs creating) destination, value, d, dataLength, // Size of the input (in bytes) - this is what fixes the padding problem x, 0 // Output is ignored, therefore the output size is zero ) } return result; } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint256 transactionId) public view returns (bool) { uint256 count = 0; for (uint256 i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId transaction ID. function addTransaction( address destination, uint256 value, bytes memory data ) internal notNull(destination) returns (uint256 transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false, sender: msg.sender, timestamp: now }); transactionCount += 1; emit Submission(transactionId, msg.sender); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return count Number of confirmations. function getConfirmationCount(uint256 transactionId) public view returns (uint256 count) { for (uint256 i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return count Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public view returns (uint256 count) { for (uint256 i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public view returns (address[] memory) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return _confirmations Returns array of owner addresses. function getConfirmations(uint256 transactionId) public view returns (address[] memory _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint256 count = 0; uint256 i; for (i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i = 0; i < count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return _transactionIds Returns array of transaction IDs. function getTransactionIds( uint256 from, uint256 to, bool pending, bool executed ) public view returns (uint256[] memory _transactionIds) { uint256[] memory transactionIdsTemp = new uint256[](transactionCount); uint256 count = 0; uint256 i; for (i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint256[](to - from); for (i = from; i < to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } function renounceRole(bytes32 role, address account) public virtual override { revert("Cannot renounceRole"); } }
/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
NatSpecSingleLine
submitTransaction
function submitTransaction( address destination, uint256 value, bytes memory data ) public ownerExists(msg.sender) returns (uint256 transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); }
/// @dev Allows an owner/admin, minter, burner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId transaction ID.
NatSpecSingleLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 6349, 6652 ] }
55,857
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
MultiSigWallet
contract MultiSigWallet is AccessControl { /* * Events */ event Confirmation(address indexed sender, uint256 indexed transactionId); event Revocation(address indexed sender, uint256 indexed transactionId); event Submission(uint256 indexed transactionId, address indexed sender); event Execution(uint256 indexed transactionId); event ExecutionFailure(uint256 indexed transactionId); event Deposit(address indexed sender, uint256 value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint256 required); /* * Constants */ uint256 public constant MAX_OWNER_COUNT = 3; /* * Storage */ bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); bytes public constant mintActionHash = abi.encodeWithSignature( "mint(uint256)" ); bytes public constant burnActionHash = abi.encodeWithSignature( "burn(uint256)" ); mapping(uint256 => Transaction) public transactions; mapping(uint256 => mapping(address => bool)) public confirmations; mapping(address => bool) public isOwner; address[] public owners; uint256 public required; uint256 public transactionCount; struct Transaction { address destination; uint256 value; bytes data; bool executed; address sender; uint256 timestamp; } /* * Modifiers */ modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint256 transactionId) { require(transactions[transactionId].destination != address(0)); _; } modifier confirmed(uint256 transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint256 transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint256 transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != address(0)); _; } modifier validRequirement(uint256 ownerCount, uint256 _required) { require( ownerCount <= MAX_OWNER_COUNT && _required <= ownerCount && _required != 0 && ownerCount != 0 ); _; } /// @dev Fallback function allows to deposit ether. receive() external payable { if (msg.value > 0) emit Deposit(msg.sender, msg.value); } /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. constructor(address[] memory _owners, uint256 _required) public validRequirement(_owners.length, _required) { _setupRole(DEFAULT_ADMIN_ROLE, address(this)); for (uint256 i = 0; i < _owners.length; i++) { require(!isOwner[_owners[i]] && _owners[i] != address(0)); isOwner[_owners[i]] = true; _setupRole(DEFAULT_ADMIN_ROLE, _owners[i]); } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. // function addOwner(address owner) // public // onlyWallet // ownerDoesNotExist(owner) // notNull(owner) // validRequirement(owners.length + 1, required) // { // isOwner[owner] = true; // owners.push(owner); // _setupRole(DEFAULT_ADMIN_ROLE, owner); // emit OwnerAddition(owner); // } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. // function removeOwner(address owner) public onlyWallet ownerExists(owner) { // isOwner[owner] = false; // for (uint256 i = 0; i < owners.length - 1; i++) // if (owners[i] == owner) { // owners[i] = owners[owners.length - 1]; // break; // } // owners.pop(); // if (required > owners.length) changeRequirement(owners.length); // emit OwnerRemoval(owner); // } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param newOwner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint256 i = 0; i < owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; _revokeRole(DEFAULT_ADMIN_ROLE, owner); isOwner[newOwner] = true; _grantRole(DEFAULT_ADMIN_ROLE, newOwner); emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. // function changeRequirement(uint256 _required) // public // onlyWallet // validRequirement(owners.length, _required) // { // required = _required; // emit RequirementChange(_required); // } /// @dev Allows an owner/admin, minter, burner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId transaction ID. function submitTransaction( address destination, uint256 value, bytes memory data ) public ownerExists(msg.sender) returns (uint256 transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } function submitMintTransaction(address destination, bytes memory data) public returns (uint256 transactionId) { require( hasRole(MINTER_ROLE, msg.sender) || isOwner[msg.sender], "Caller is not a minter or admin" ); bytes memory actionHash = abi.encodePacked(mintActionHash, data); transactionId = addTransaction(destination, 0, actionHash); } function submitBurnTransaction(address destination, bytes memory data) public returns (uint256 transactionId) { require( hasRole(BURNER_ROLE, msg.sender) || isOwner[msg.sender], "Caller is not a burner or admin" ); bytes memory actionHash = abi.encodePacked(burnActionHash, data); transactionId = addTransaction(destination, 0, actionHash); } function grantRoleTransaction(bytes32 _role, address _account) public onlyWallet { grantRole(_role, _account); } function revokeRoleTransaction(bytes32 _role, address _account) public onlyWallet { revokeRole(_role, _account); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint256 transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if ( external_call( txn.destination, txn.value, txn.data.length, txn.data ) ) emit Execution(transactionId); else { emit ExecutionFailure(transactionId); txn.executed = false; } } } // call has been separated into its own function in order to take advantage // of the Solidity's code generator to produce a loop that copies tx.data into memory. function external_call( address destination, uint256 value, uint256 dataLength, bytes memory data ) internal returns (bool) { bool result; assembly { let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention) let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that result := call( sub(gas(), 34710), // 34710 is the value that solidity is currently emitting // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) + // callNewAccountGas (25000, in case the destination address does not exist and needs creating) destination, value, d, dataLength, // Size of the input (in bytes) - this is what fixes the padding problem x, 0 // Output is ignored, therefore the output size is zero ) } return result; } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint256 transactionId) public view returns (bool) { uint256 count = 0; for (uint256 i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId transaction ID. function addTransaction( address destination, uint256 value, bytes memory data ) internal notNull(destination) returns (uint256 transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false, sender: msg.sender, timestamp: now }); transactionCount += 1; emit Submission(transactionId, msg.sender); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return count Number of confirmations. function getConfirmationCount(uint256 transactionId) public view returns (uint256 count) { for (uint256 i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return count Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public view returns (uint256 count) { for (uint256 i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public view returns (address[] memory) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return _confirmations Returns array of owner addresses. function getConfirmations(uint256 transactionId) public view returns (address[] memory _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint256 count = 0; uint256 i; for (i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i = 0; i < count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return _transactionIds Returns array of transaction IDs. function getTransactionIds( uint256 from, uint256 to, bool pending, bool executed ) public view returns (uint256[] memory _transactionIds) { uint256[] memory transactionIdsTemp = new uint256[](transactionCount); uint256 count = 0; uint256 i; for (i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint256[](to - from); for (i = from; i < to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } function renounceRole(bytes32 role, address account) public virtual override { revert("Cannot renounceRole"); } }
/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
NatSpecSingleLine
confirmTransaction
function confirmTransaction(uint256 transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); }
/// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID.
NatSpecSingleLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 7953, 8319 ] }
55,858
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
MultiSigWallet
contract MultiSigWallet is AccessControl { /* * Events */ event Confirmation(address indexed sender, uint256 indexed transactionId); event Revocation(address indexed sender, uint256 indexed transactionId); event Submission(uint256 indexed transactionId, address indexed sender); event Execution(uint256 indexed transactionId); event ExecutionFailure(uint256 indexed transactionId); event Deposit(address indexed sender, uint256 value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint256 required); /* * Constants */ uint256 public constant MAX_OWNER_COUNT = 3; /* * Storage */ bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); bytes public constant mintActionHash = abi.encodeWithSignature( "mint(uint256)" ); bytes public constant burnActionHash = abi.encodeWithSignature( "burn(uint256)" ); mapping(uint256 => Transaction) public transactions; mapping(uint256 => mapping(address => bool)) public confirmations; mapping(address => bool) public isOwner; address[] public owners; uint256 public required; uint256 public transactionCount; struct Transaction { address destination; uint256 value; bytes data; bool executed; address sender; uint256 timestamp; } /* * Modifiers */ modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint256 transactionId) { require(transactions[transactionId].destination != address(0)); _; } modifier confirmed(uint256 transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint256 transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint256 transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != address(0)); _; } modifier validRequirement(uint256 ownerCount, uint256 _required) { require( ownerCount <= MAX_OWNER_COUNT && _required <= ownerCount && _required != 0 && ownerCount != 0 ); _; } /// @dev Fallback function allows to deposit ether. receive() external payable { if (msg.value > 0) emit Deposit(msg.sender, msg.value); } /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. constructor(address[] memory _owners, uint256 _required) public validRequirement(_owners.length, _required) { _setupRole(DEFAULT_ADMIN_ROLE, address(this)); for (uint256 i = 0; i < _owners.length; i++) { require(!isOwner[_owners[i]] && _owners[i] != address(0)); isOwner[_owners[i]] = true; _setupRole(DEFAULT_ADMIN_ROLE, _owners[i]); } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. // function addOwner(address owner) // public // onlyWallet // ownerDoesNotExist(owner) // notNull(owner) // validRequirement(owners.length + 1, required) // { // isOwner[owner] = true; // owners.push(owner); // _setupRole(DEFAULT_ADMIN_ROLE, owner); // emit OwnerAddition(owner); // } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. // function removeOwner(address owner) public onlyWallet ownerExists(owner) { // isOwner[owner] = false; // for (uint256 i = 0; i < owners.length - 1; i++) // if (owners[i] == owner) { // owners[i] = owners[owners.length - 1]; // break; // } // owners.pop(); // if (required > owners.length) changeRequirement(owners.length); // emit OwnerRemoval(owner); // } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param newOwner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint256 i = 0; i < owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; _revokeRole(DEFAULT_ADMIN_ROLE, owner); isOwner[newOwner] = true; _grantRole(DEFAULT_ADMIN_ROLE, newOwner); emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. // function changeRequirement(uint256 _required) // public // onlyWallet // validRequirement(owners.length, _required) // { // required = _required; // emit RequirementChange(_required); // } /// @dev Allows an owner/admin, minter, burner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId transaction ID. function submitTransaction( address destination, uint256 value, bytes memory data ) public ownerExists(msg.sender) returns (uint256 transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } function submitMintTransaction(address destination, bytes memory data) public returns (uint256 transactionId) { require( hasRole(MINTER_ROLE, msg.sender) || isOwner[msg.sender], "Caller is not a minter or admin" ); bytes memory actionHash = abi.encodePacked(mintActionHash, data); transactionId = addTransaction(destination, 0, actionHash); } function submitBurnTransaction(address destination, bytes memory data) public returns (uint256 transactionId) { require( hasRole(BURNER_ROLE, msg.sender) || isOwner[msg.sender], "Caller is not a burner or admin" ); bytes memory actionHash = abi.encodePacked(burnActionHash, data); transactionId = addTransaction(destination, 0, actionHash); } function grantRoleTransaction(bytes32 _role, address _account) public onlyWallet { grantRole(_role, _account); } function revokeRoleTransaction(bytes32 _role, address _account) public onlyWallet { revokeRole(_role, _account); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint256 transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if ( external_call( txn.destination, txn.value, txn.data.length, txn.data ) ) emit Execution(transactionId); else { emit ExecutionFailure(transactionId); txn.executed = false; } } } // call has been separated into its own function in order to take advantage // of the Solidity's code generator to produce a loop that copies tx.data into memory. function external_call( address destination, uint256 value, uint256 dataLength, bytes memory data ) internal returns (bool) { bool result; assembly { let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention) let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that result := call( sub(gas(), 34710), // 34710 is the value that solidity is currently emitting // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) + // callNewAccountGas (25000, in case the destination address does not exist and needs creating) destination, value, d, dataLength, // Size of the input (in bytes) - this is what fixes the padding problem x, 0 // Output is ignored, therefore the output size is zero ) } return result; } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint256 transactionId) public view returns (bool) { uint256 count = 0; for (uint256 i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId transaction ID. function addTransaction( address destination, uint256 value, bytes memory data ) internal notNull(destination) returns (uint256 transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false, sender: msg.sender, timestamp: now }); transactionCount += 1; emit Submission(transactionId, msg.sender); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return count Number of confirmations. function getConfirmationCount(uint256 transactionId) public view returns (uint256 count) { for (uint256 i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return count Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public view returns (uint256 count) { for (uint256 i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public view returns (address[] memory) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return _confirmations Returns array of owner addresses. function getConfirmations(uint256 transactionId) public view returns (address[] memory _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint256 count = 0; uint256 i; for (i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i = 0; i < count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return _transactionIds Returns array of transaction IDs. function getTransactionIds( uint256 from, uint256 to, bool pending, bool executed ) public view returns (uint256[] memory _transactionIds) { uint256[] memory transactionIdsTemp = new uint256[](transactionCount); uint256 count = 0; uint256 i; for (i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint256[](to - from); for (i = from; i < to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } function renounceRole(bytes32 role, address account) public virtual override { revert("Cannot renounceRole"); } }
/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
NatSpecSingleLine
revokeConfirmation
function revokeConfirmation(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); }
/// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID.
NatSpecSingleLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 8442, 8754 ] }
55,859
MultiSigWallet
MultiSigWallet.sol
0x6d94b2dcdb49e671a39794124dd9361ca2ab3c68
Solidity
MultiSigWallet
contract MultiSigWallet is AccessControl { /* * Events */ event Confirmation(address indexed sender, uint256 indexed transactionId); event Revocation(address indexed sender, uint256 indexed transactionId); event Submission(uint256 indexed transactionId, address indexed sender); event Execution(uint256 indexed transactionId); event ExecutionFailure(uint256 indexed transactionId); event Deposit(address indexed sender, uint256 value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint256 required); /* * Constants */ uint256 public constant MAX_OWNER_COUNT = 3; /* * Storage */ bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); bytes public constant mintActionHash = abi.encodeWithSignature( "mint(uint256)" ); bytes public constant burnActionHash = abi.encodeWithSignature( "burn(uint256)" ); mapping(uint256 => Transaction) public transactions; mapping(uint256 => mapping(address => bool)) public confirmations; mapping(address => bool) public isOwner; address[] public owners; uint256 public required; uint256 public transactionCount; struct Transaction { address destination; uint256 value; bytes data; bool executed; address sender; uint256 timestamp; } /* * Modifiers */ modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint256 transactionId) { require(transactions[transactionId].destination != address(0)); _; } modifier confirmed(uint256 transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint256 transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint256 transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != address(0)); _; } modifier validRequirement(uint256 ownerCount, uint256 _required) { require( ownerCount <= MAX_OWNER_COUNT && _required <= ownerCount && _required != 0 && ownerCount != 0 ); _; } /// @dev Fallback function allows to deposit ether. receive() external payable { if (msg.value > 0) emit Deposit(msg.sender, msg.value); } /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. constructor(address[] memory _owners, uint256 _required) public validRequirement(_owners.length, _required) { _setupRole(DEFAULT_ADMIN_ROLE, address(this)); for (uint256 i = 0; i < _owners.length; i++) { require(!isOwner[_owners[i]] && _owners[i] != address(0)); isOwner[_owners[i]] = true; _setupRole(DEFAULT_ADMIN_ROLE, _owners[i]); } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. // function addOwner(address owner) // public // onlyWallet // ownerDoesNotExist(owner) // notNull(owner) // validRequirement(owners.length + 1, required) // { // isOwner[owner] = true; // owners.push(owner); // _setupRole(DEFAULT_ADMIN_ROLE, owner); // emit OwnerAddition(owner); // } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. // function removeOwner(address owner) public onlyWallet ownerExists(owner) { // isOwner[owner] = false; // for (uint256 i = 0; i < owners.length - 1; i++) // if (owners[i] == owner) { // owners[i] = owners[owners.length - 1]; // break; // } // owners.pop(); // if (required > owners.length) changeRequirement(owners.length); // emit OwnerRemoval(owner); // } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param newOwner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint256 i = 0; i < owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; _revokeRole(DEFAULT_ADMIN_ROLE, owner); isOwner[newOwner] = true; _grantRole(DEFAULT_ADMIN_ROLE, newOwner); emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. // function changeRequirement(uint256 _required) // public // onlyWallet // validRequirement(owners.length, _required) // { // required = _required; // emit RequirementChange(_required); // } /// @dev Allows an owner/admin, minter, burner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId transaction ID. function submitTransaction( address destination, uint256 value, bytes memory data ) public ownerExists(msg.sender) returns (uint256 transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } function submitMintTransaction(address destination, bytes memory data) public returns (uint256 transactionId) { require( hasRole(MINTER_ROLE, msg.sender) || isOwner[msg.sender], "Caller is not a minter or admin" ); bytes memory actionHash = abi.encodePacked(mintActionHash, data); transactionId = addTransaction(destination, 0, actionHash); } function submitBurnTransaction(address destination, bytes memory data) public returns (uint256 transactionId) { require( hasRole(BURNER_ROLE, msg.sender) || isOwner[msg.sender], "Caller is not a burner or admin" ); bytes memory actionHash = abi.encodePacked(burnActionHash, data); transactionId = addTransaction(destination, 0, actionHash); } function grantRoleTransaction(bytes32 _role, address _account) public onlyWallet { grantRole(_role, _account); } function revokeRoleTransaction(bytes32 _role, address _account) public onlyWallet { revokeRole(_role, _account); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint256 transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if ( external_call( txn.destination, txn.value, txn.data.length, txn.data ) ) emit Execution(transactionId); else { emit ExecutionFailure(transactionId); txn.executed = false; } } } // call has been separated into its own function in order to take advantage // of the Solidity's code generator to produce a loop that copies tx.data into memory. function external_call( address destination, uint256 value, uint256 dataLength, bytes memory data ) internal returns (bool) { bool result; assembly { let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention) let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that result := call( sub(gas(), 34710), // 34710 is the value that solidity is currently emitting // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) + // callNewAccountGas (25000, in case the destination address does not exist and needs creating) destination, value, d, dataLength, // Size of the input (in bytes) - this is what fixes the padding problem x, 0 // Output is ignored, therefore the output size is zero ) } return result; } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint256 transactionId) public view returns (bool) { uint256 count = 0; for (uint256 i = 0; i < owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId transaction ID. function addTransaction( address destination, uint256 value, bytes memory data ) internal notNull(destination) returns (uint256 transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false, sender: msg.sender, timestamp: now }); transactionCount += 1; emit Submission(transactionId, msg.sender); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return count Number of confirmations. function getConfirmationCount(uint256 transactionId) public view returns (uint256 count) { for (uint256 i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return count Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public view returns (uint256 count) { for (uint256 i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public view returns (address[] memory) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return _confirmations Returns array of owner addresses. function getConfirmations(uint256 transactionId) public view returns (address[] memory _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint256 count = 0; uint256 i; for (i = 0; i < owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i = 0; i < count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return _transactionIds Returns array of transaction IDs. function getTransactionIds( uint256 from, uint256 to, bool pending, bool executed ) public view returns (uint256[] memory _transactionIds) { uint256[] memory transactionIdsTemp = new uint256[](transactionCount); uint256 count = 0; uint256 i; for (i = 0; i < transactionCount; i++) if ( (pending && !transactions[i].executed) || (executed && transactions[i].executed) ) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint256[](to - from); for (i = from; i < to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } function renounceRole(bytes32 role, address account) public virtual override { revert("Cannot renounceRole"); } }
/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
NatSpecSingleLine
executeTransaction
function executeTransaction(uint256 transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if ( external_call( txn.destination, txn.value, txn.data.length, txn.data ) ) emit Execution(transactionId); else { emit ExecutionFailure(transactionId); txn.executed = false; } } }
/// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID.
NatSpecSingleLine
v0.6.2+commit.bacdbe57
None
ipfs://57f8becce021d274ae37e2dbe1946dec534280eb4930d3398a27909b96ecd4be
{ "func_code_index": [ 8867, 9605 ] }
55,860