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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
InitializableAdminUpgradeabilityProxy | InitializableAdminUpgradeabilityProxy.sol | 0xcd55262c3ea354a58661597f71037d5fa26b72bd | Solidity | InitializableAdminUpgradeabilityProxy | contract InitializableAdminUpgradeabilityProxy is BaseAdminUpgradeabilityProxy, InitializableUpgradeabilityProxy {
/**
* Contract initializer.
* @param _logic address of the initial implementation.
* @param _admin Address of the proxy administrator.
* @param _data Data to send as msg.data to the implementation to initialize the proxied contract.
* It should include the signature and the parameters of the function to be called, as described in
* https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
* This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.
*/
function initialize(address _logic, address _admin, bytes memory _data) public payable {
require(_implementation() == address(0));
InitializableUpgradeabilityProxy.initialize(_logic, _data);
assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
_setAdmin(_admin);
}
/**
* @dev Only fall back when the sender is not the admin.
*/
function _willFallback() internal override(BaseAdminUpgradeabilityProxy, Proxy) {
BaseAdminUpgradeabilityProxy._willFallback();
}
} | /**
* @title InitializableAdminUpgradeabilityProxy
* @dev Extends from BaseAdminUpgradeabilityProxy with an initializer for
* initializing the implementation, admin, and init data.
*/ | NatSpecMultiLine | initialize | function initialize(address _logic, address _admin, bytes memory _data) public payable {
require(_implementation() == address(0));
InitializableUpgradeabilityProxy.initialize(_logic, _data);
assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
_setAdmin(_admin);
}
| /**
* Contract initializer.
* @param _logic address of the initial implementation.
* @param _admin Address of the proxy administrator.
* @param _data Data to send as msg.data to the implementation to initialize the proxied contract.
* It should include the signature and the parameters of the function to be called, as described in
* https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
* This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | Unknown | ipfs://5b70184b910b61c840297871c0fa5a4d6a4c004bea856b7718f824c27cb83b4f | {
"func_code_index": [
699,
1034
]
} | 11,100 |
InitializableAdminUpgradeabilityProxy | InitializableAdminUpgradeabilityProxy.sol | 0xcd55262c3ea354a58661597f71037d5fa26b72bd | Solidity | InitializableAdminUpgradeabilityProxy | contract InitializableAdminUpgradeabilityProxy is BaseAdminUpgradeabilityProxy, InitializableUpgradeabilityProxy {
/**
* Contract initializer.
* @param _logic address of the initial implementation.
* @param _admin Address of the proxy administrator.
* @param _data Data to send as msg.data to the implementation to initialize the proxied contract.
* It should include the signature and the parameters of the function to be called, as described in
* https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
* This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.
*/
function initialize(address _logic, address _admin, bytes memory _data) public payable {
require(_implementation() == address(0));
InitializableUpgradeabilityProxy.initialize(_logic, _data);
assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
_setAdmin(_admin);
}
/**
* @dev Only fall back when the sender is not the admin.
*/
function _willFallback() internal override(BaseAdminUpgradeabilityProxy, Proxy) {
BaseAdminUpgradeabilityProxy._willFallback();
}
} | /**
* @title InitializableAdminUpgradeabilityProxy
* @dev Extends from BaseAdminUpgradeabilityProxy with an initializer for
* initializing the implementation, admin, and init data.
*/ | NatSpecMultiLine | _willFallback | function _willFallback() internal override(BaseAdminUpgradeabilityProxy, Proxy) {
BaseAdminUpgradeabilityProxy._willFallback();
}
| /**
* @dev Only fall back when the sender is not the admin.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | Unknown | ipfs://5b70184b910b61c840297871c0fa5a4d6a4c004bea856b7718f824c27cb83b4f | {
"func_code_index": [
1115,
1263
]
} | 11,101 |
AstronautApes | @openzeppelin/contracts/access/Ownable.sol | 0xfffc8336c1b2ea1265699bd2f029a6a653190b69 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
} | /**
* @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 virtual returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://cecc299085dde543f995524a10c30445377d0d46dd5bbd4aad8e58b20a52454f | {
"func_code_index": [
399,
491
]
} | 11,102 |
AstronautApes | @openzeppelin/contracts/access/Ownable.sol | 0xfffc8336c1b2ea1265699bd2f029a6a653190b69 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
} | /**
* @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 {
_setOwner(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.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://cecc299085dde543f995524a10c30445377d0d46dd5bbd4aad8e58b20a52454f | {
"func_code_index": [
1050,
1149
]
} | 11,103 |
AstronautApes | @openzeppelin/contracts/access/Ownable.sol | 0xfffc8336c1b2ea1265699bd2f029a6a653190b69 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
} | /**
* @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 | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://cecc299085dde543f995524a10c30445377d0d46dd5bbd4aad8e58b20a52454f | {
"func_code_index": [
1299,
1496
]
} | 11,104 |
AstronautApes | @openzeppelin/contracts/access/Ownable.sol | 0xfffc8336c1b2ea1265699bd2f029a6a653190b69 | Solidity | AstronautApes | contract AstronautApes is ERC721Enumerable, Ownable {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
string public notRevealedUri;
uint256 public cost = .06 ether;
uint256 public maxSupply = 10000;
uint256 public maxMintAmount = 20;
uint256 public nftPerAddressLimit = 20;
bool public paused = false;
bool public revealed = false;
bool public onlyWhitelisted = true;
// address payable commissions = payable(0x1Cf11bbD83cab8c85426566d820B3bf2DB4b7827);
address[] public whitelistedAddresses;
mapping(address => uint256) public addressPresaleMinted;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable {
require(!paused, "the contract is paused");
uint256 supply = totalSupply();
require(_mintAmount > 0, "need to mint at least 1 NFT");
require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded");
require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded");
if (msg.sender != owner()) {
if(onlyWhitelisted == true) {
require(isWhitelisted(msg.sender), "user is not whitelisted");
uint256 ownerTokenCount = addressPresaleMinted[msg.sender];
require(ownerTokenCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded");
}
require(msg.value >= cost * _mintAmount, "insufficient funds");
}
for (uint256 i = 1; i <= _mintAmount; i++) {
addressPresaleMinted[msg.sender]++;
_safeMint(msg.sender, supply + i);
}
// (bool success, ) = payable(commissions).call{value: msg.value * 1 / 100}("");
// require(success);
}
function isWhitelisted(address _user) public view returns (bool) {
for (uint i = 0; i < whitelistedAddresses.length; i++) {
if (whitelistedAddresses[i] == _user) {
return true;
}
}
return false;
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if(revealed == false) {
return notRevealedUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
//only owner
function reveal() public onlyOwner() {
revealed = true;
}
function setNftPerAddressLimit(uint256 _limit) public onlyOwner() {
nftPerAddressLimit = _limit;
}
function setCost(uint256 _newCost) public onlyOwner() {
cost = _newCost;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() {
maxMintAmount = _newmaxMintAmount;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedUri = _notRevealedURI;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function setOnlyWhitelisted(bool _state) public onlyOwner {
onlyWhitelisted = _state;
}
function whitelistUsers(address[] calldata _users) public onlyOwner {
delete whitelistedAddresses;
whitelistedAddresses = _users;
}
function withdraw() public payable onlyOwner {
(bool success, ) = payable(msg.sender).call{value: address(this).balance}("");
require(success);
}
} | _baseURI | function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
| // internal | LineComment | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://cecc299085dde543f995524a10c30445377d0d46dd5bbd4aad8e58b20a52454f | {
"func_code_index": [
910,
1015
]
} | 11,105 |
||
AstronautApes | @openzeppelin/contracts/access/Ownable.sol | 0xfffc8336c1b2ea1265699bd2f029a6a653190b69 | Solidity | AstronautApes | contract AstronautApes is ERC721Enumerable, Ownable {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
string public notRevealedUri;
uint256 public cost = .06 ether;
uint256 public maxSupply = 10000;
uint256 public maxMintAmount = 20;
uint256 public nftPerAddressLimit = 20;
bool public paused = false;
bool public revealed = false;
bool public onlyWhitelisted = true;
// address payable commissions = payable(0x1Cf11bbD83cab8c85426566d820B3bf2DB4b7827);
address[] public whitelistedAddresses;
mapping(address => uint256) public addressPresaleMinted;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable {
require(!paused, "the contract is paused");
uint256 supply = totalSupply();
require(_mintAmount > 0, "need to mint at least 1 NFT");
require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded");
require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded");
if (msg.sender != owner()) {
if(onlyWhitelisted == true) {
require(isWhitelisted(msg.sender), "user is not whitelisted");
uint256 ownerTokenCount = addressPresaleMinted[msg.sender];
require(ownerTokenCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded");
}
require(msg.value >= cost * _mintAmount, "insufficient funds");
}
for (uint256 i = 1; i <= _mintAmount; i++) {
addressPresaleMinted[msg.sender]++;
_safeMint(msg.sender, supply + i);
}
// (bool success, ) = payable(commissions).call{value: msg.value * 1 / 100}("");
// require(success);
}
function isWhitelisted(address _user) public view returns (bool) {
for (uint i = 0; i < whitelistedAddresses.length; i++) {
if (whitelistedAddresses[i] == _user) {
return true;
}
}
return false;
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if(revealed == false) {
return notRevealedUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
//only owner
function reveal() public onlyOwner() {
revealed = true;
}
function setNftPerAddressLimit(uint256 _limit) public onlyOwner() {
nftPerAddressLimit = _limit;
}
function setCost(uint256 _newCost) public onlyOwner() {
cost = _newCost;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() {
maxMintAmount = _newmaxMintAmount;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedUri = _notRevealedURI;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function setOnlyWhitelisted(bool _state) public onlyOwner {
onlyWhitelisted = _state;
}
function whitelistUsers(address[] calldata _users) public onlyOwner {
delete whitelistedAddresses;
whitelistedAddresses = _users;
}
function withdraw() public payable onlyOwner {
(bool success, ) = payable(msg.sender).call{value: address(this).balance}("");
require(success);
}
} | mint | function mint(uint256 _mintAmount) public payable {
require(!paused, "the contract is paused");
uint256 supply = totalSupply();
require(_mintAmount > 0, "need to mint at least 1 NFT");
require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded");
require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded");
if (msg.sender != owner()) {
if(onlyWhitelisted == true) {
require(isWhitelisted(msg.sender), "user is not whitelisted");
uint256 ownerTokenCount = addressPresaleMinted[msg.sender];
require(ownerTokenCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded");
}
require(msg.value >= cost * _mintAmount, "insufficient funds");
}
for (uint256 i = 1; i <= _mintAmount; i++) {
addressPresaleMinted[msg.sender]++;
_safeMint(msg.sender, supply + i);
}
// (bool success, ) = payable(commissions).call{value: msg.value * 1 / 100}("");
// require(success);
}
| // public | LineComment | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://cecc299085dde543f995524a10c30445377d0d46dd5bbd4aad8e58b20a52454f | {
"func_code_index": [
1031,
2083
]
} | 11,106 |
||
AstronautApes | @openzeppelin/contracts/access/Ownable.sol | 0xfffc8336c1b2ea1265699bd2f029a6a653190b69 | Solidity | AstronautApes | contract AstronautApes is ERC721Enumerable, Ownable {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
string public notRevealedUri;
uint256 public cost = .06 ether;
uint256 public maxSupply = 10000;
uint256 public maxMintAmount = 20;
uint256 public nftPerAddressLimit = 20;
bool public paused = false;
bool public revealed = false;
bool public onlyWhitelisted = true;
// address payable commissions = payable(0x1Cf11bbD83cab8c85426566d820B3bf2DB4b7827);
address[] public whitelistedAddresses;
mapping(address => uint256) public addressPresaleMinted;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable {
require(!paused, "the contract is paused");
uint256 supply = totalSupply();
require(_mintAmount > 0, "need to mint at least 1 NFT");
require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded");
require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded");
if (msg.sender != owner()) {
if(onlyWhitelisted == true) {
require(isWhitelisted(msg.sender), "user is not whitelisted");
uint256 ownerTokenCount = addressPresaleMinted[msg.sender];
require(ownerTokenCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded");
}
require(msg.value >= cost * _mintAmount, "insufficient funds");
}
for (uint256 i = 1; i <= _mintAmount; i++) {
addressPresaleMinted[msg.sender]++;
_safeMint(msg.sender, supply + i);
}
// (bool success, ) = payable(commissions).call{value: msg.value * 1 / 100}("");
// require(success);
}
function isWhitelisted(address _user) public view returns (bool) {
for (uint i = 0; i < whitelistedAddresses.length; i++) {
if (whitelistedAddresses[i] == _user) {
return true;
}
}
return false;
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if(revealed == false) {
return notRevealedUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
//only owner
function reveal() public onlyOwner() {
revealed = true;
}
function setNftPerAddressLimit(uint256 _limit) public onlyOwner() {
nftPerAddressLimit = _limit;
}
function setCost(uint256 _newCost) public onlyOwner() {
cost = _newCost;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() {
maxMintAmount = _newmaxMintAmount;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedUri = _notRevealedURI;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function setOnlyWhitelisted(bool _state) public onlyOwner {
onlyWhitelisted = _state;
}
function whitelistUsers(address[] calldata _users) public onlyOwner {
delete whitelistedAddresses;
whitelistedAddresses = _users;
}
function withdraw() public payable onlyOwner {
(bool success, ) = payable(msg.sender).call{value: address(this).balance}("");
require(success);
}
} | reveal | function reveal() public onlyOwner() {
revealed = true;
}
| //only owner | LineComment | v0.8.7+commit.e28d00a7 | GNU GPLv3 | ipfs://cecc299085dde543f995524a10c30445377d0d46dd5bbd4aad8e58b20a52454f | {
"func_code_index": [
3206,
3276
]
} | 11,107 |
||
Crypton | Crypton.sol | 0x9214c43b602f68bb0c8968f43d702865bf1b225d | Solidity | Crypton | contract Crypton is StandardToken, Owned {
string public name = "Crypton";
uint256 public decimals = 18;
string public symbol = "CRP";
function Crypton() public {
totalSupply = 100000000e18;
balances[msg.sender] = totalSupply;
}
function() public payable {
revert();
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if (!_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) {
revert();
}
return true;
}
} | approveAndCall | function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if (!_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) {
revert();
}
return true;
}
| /* Approves and then calls the receiving contract */ | Comment | v0.4.19+commit.c4cbbb05 | bzzr://d2fb27ff715c6c04e179a6fddd05639e22485b4ee46963f0bea8664564f4b58b | {
"func_code_index": [
416,
1261
]
} | 11,108 |
|||
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | name | function name() public view virtual returns (string memory) {
return _name;
}
| /**
* @dev Returns the name of the token.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
765,
861
]
} | 11,109 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | symbol | function symbol() public view virtual returns (string memory) {
return _symbol;
}
| /**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
975,
1075
]
} | 11,110 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | decimals | function decimals() public view virtual returns (uint8) {
return 18;
}
| /**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
1709,
1798
]
} | 11,111 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
| /**
* @dev See {IERC20-totalSupply}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
1858,
1971
]
} | 11,112 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
| /**
* @dev See {IERC20-balanceOf}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
2029,
2161
]
} | 11,113 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | transfer | function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
| /**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
2369,
2549
]
} | 11,114 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | allowance | function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
| /**
* @dev See {IERC20-allowance}.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
2607,
2763
]
} | 11,115 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | approve | function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
| /**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
2905,
3079
]
} | 11,116 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
| /**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
3556,
3983
]
} | 11,117 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | increaseAllowance | function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
| /**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
4387,
4607
]
} | 11,118 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | decreaseAllowance | function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
| /**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
5105,
5487
]
} | 11,119 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _transfer | function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
| /**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
5972,
6581
]
} | 11,120 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _mint | function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
| /** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
6858,
7201
]
} | 11,121 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _burn | function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
| /**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
7529,
8028
]
} | 11,122 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _approve | function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
| /**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
8461,
8812
]
} | 11,123 |
ERC20Vested | contracts/token/ERC20/ERC20.sol | 0xcdb9d30a3ba48cdfcb0ecbe19317e6cf783672f1 | Solidity | ERC20 | contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _beforeTokenTransfer | function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
| /**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/ | NatSpecMultiLine | v0.8.1+commit.df193b15 | MIT | ipfs://ff477603eee65922adc0e88083abef1fcda42c119dc941d4d45d38e1cb8f776f | {
"func_code_index": [
9410,
9507
]
} | 11,124 |
UniqGenesis | ./contracts/UniqGenesis.sol | 0xd804c52524f1cfad0fae54d2f2b15871337e96b3 | Solidity | UniqGenesis | contract UniqGenesis is ERC721Claimable, VRFConsumerBase {
// ----- EVENTS ----- //
event PrizeCollected(address indexed _winner, uint256 _tokenId);
// ----- VARIABLES ----- //
//Sale
uint256 internal constant _maxUniqly = 10000;
bool internal _saleStarted;
uint256 internal _tokenPrice;
//VRF + Prizes
bytes32 internal immutable keyHash;
uint256 internal immutable fee;
uint256 public randomResult;
address[] public winners;
// ----- CONSTRUCTOR ----- //
constructor(
string memory _bURI,
string memory _name,
string memory _symbol,
address _vrfCoordinator,
address _link,
bytes32 _keyHash,
uint256 _fee,
address _proxyRegistryAddress,
address _claimingContractAddress,
uint256 _tokenSalePrice,
uint256 _royaltyFee
)
ERC721Claimable(_name, _symbol, _bURI, _proxyRegistryAddress,_claimingContractAddress, _royaltyFee)
VRFConsumerBase(_vrfCoordinator, _link)
{
keyHash = _keyHash;
fee = _fee;
_tokenPrice = _tokenSalePrice;
}
// ----- VIEWS ----- //
function contractURI() public pure returns (string memory) {
return "https://uniqly.io/api/nft-genesis/";
}
function calculateEthPriceForExactUniqs(uint256 _number)
external
view
returns (uint256)
{
return _number * _tokenPrice;
}
function getAllWinners() external view returns (address[] memory) {
uint256 winnersCount = winners.length;
if (winnersCount == 0) {
return new address[](0);
} else {
address[] memory result = new address[](winnersCount);
uint256 index;
for (index = 0; index < winnersCount; index++) {
result[index] = winners[index];
}
return result;
}
}
function getWinner(uint256 _arrayKey) external view returns (address) {
return winners[_arrayKey];
}
function getWinnersCount() external view returns (uint256) {
return winners.length;
}
function checkWin(uint256 _tokenId) external view returns (bool) {
return _isWinner(_tokenId);
}
function isAlreadyRececeivedPrize(address _potWinner)
external
view
returns (bool)
{
return (_isAlreadyRececeivedPrize(_potWinner));
}
function _isAlreadyRececeivedPrize(address _potWinner)
internal
view
returns (bool)
{
uint256 i;
uint256 winnersCount = winners.length;
for (i = 0; i < winnersCount; i++) {
if (winners[i] == _potWinner) return true;
}
return false;
}
// ----- PUBLIC METHODS ----- //
//emits Transfer event
function mintUniqly(uint256 numUniqlies) external payable {
require(_saleStarted, "Sale not started yet");
uint256 requiredValue = numUniqlies * _tokenPrice;
uint256 mintIndex = totalSupply();
require(msg.value >= requiredValue, "Not enough ether");
require(
(numUniqlies + mintIndex) <= _maxUniqly,
"You cannot buy that many tokens"
);
for (uint256 i = 0; i < numUniqlies; i++) {
_safeMint(msg.sender, mintIndex);
mintIndex++;
}
// send back ETH if one overpay by accident
if (requiredValue < msg.value) {
payable(msg.sender).transfer(msg.value - requiredValue);
}
}
function collectPrize(uint256 _tokenId) external {
require(ownerOf(_tokenId) == msg.sender, "Ownership needed");
require(_isWinner(_tokenId), "You did not win");
require(
!_isAlreadyRececeivedPrize(msg.sender),
"Already received a prize"
);
require(winners.length < 10, "Prize limit reached");
winners.push(msg.sender);
emit PrizeCollected(msg.sender, _tokenId);
payable(msg.sender).transfer(1 ether);
}
receive() external payable {}
// ----- PRIVATE METHODS ----- //
function fulfillRandomness(bytes32, uint256 randomness) internal override {
randomResult = randomness;
}
function _isWinner(uint256 id) internal view returns (bool) {
require(randomResult > 0, "Random must be initiated");
uint256 result = (
uint256(keccak256(abi.encodePacked(id, randomResult)))
) % 10000;
if (result <= 20) return true;
return false;
}
// ----- OWNERS METHODS ----- //
function getRandomNumber(uint256 adminProvidedSeed)
external
onlyOwner
returns (bytes32)
{
require(totalSupply() >= _maxUniqly, "Sale must be ended");
require(randomResult == 0, "Random number already initiated");
require(address(this).balance >= 10 ether, "min 10 ETH balance required");
require(
LINK.balanceOf(address(this)) >= fee,
"Not enough LINK"
);
return requestRandomness(keyHash, fee, adminProvidedSeed);
}
function batchMintAsOwner(
uint[] memory _ids,
address[] memory _addresses
) external onlyOwner {
uint len = _ids.length;
require(len == _addresses.length, "Arrays length");
uint256 i = 0;
for (i = 0; i < len; i++) {
_safeMint(_addresses[i], _ids[i]);
}
}
function editSaleStatus(bool _isEnable) external onlyOwner{
_saleStarted = _isEnable;
}
function withdrawAll() external onlyOwner {
require(payable(msg.sender).send(address(this).balance));
}
function recoverERC20(address token) external onlyOwner {
uint256 val = IERC20(token).balanceOf(address(this));
require(val > 0, "Nothing to recover");
// use interface that not return value (USDT case)
Ierc20(token).transfer(owner(), val);
}
function setRandomResualAsAdmin(uint256 _newRandomResult) external onlyOwner{
require(randomResult == 0, "Random number already initiated");
randomResult = _newRandomResult;
}
function editTokenPrice(uint256 _newPrice) external onlyOwner{
_tokenPrice = _newPrice;
}
function editTokenUri(string memory _ttokenUri) external onlyOwner {
_token_uri = _ttokenUri;
}
} | contractURI | function contractURI() public pure returns (string memory) {
return "https://uniqly.io/api/nft-genesis/";
}
| // ----- VIEWS ----- // | LineComment | v0.8.6+commit.11564f7e | MIT | ipfs://5adf4d24848f3e599a1110d0be7c407fa8f355a20311f48c1565b436f59758af | {
"func_code_index": [
1159,
1282
]
} | 11,125 |
||
UniqGenesis | ./contracts/UniqGenesis.sol | 0xd804c52524f1cfad0fae54d2f2b15871337e96b3 | Solidity | UniqGenesis | contract UniqGenesis is ERC721Claimable, VRFConsumerBase {
// ----- EVENTS ----- //
event PrizeCollected(address indexed _winner, uint256 _tokenId);
// ----- VARIABLES ----- //
//Sale
uint256 internal constant _maxUniqly = 10000;
bool internal _saleStarted;
uint256 internal _tokenPrice;
//VRF + Prizes
bytes32 internal immutable keyHash;
uint256 internal immutable fee;
uint256 public randomResult;
address[] public winners;
// ----- CONSTRUCTOR ----- //
constructor(
string memory _bURI,
string memory _name,
string memory _symbol,
address _vrfCoordinator,
address _link,
bytes32 _keyHash,
uint256 _fee,
address _proxyRegistryAddress,
address _claimingContractAddress,
uint256 _tokenSalePrice,
uint256 _royaltyFee
)
ERC721Claimable(_name, _symbol, _bURI, _proxyRegistryAddress,_claimingContractAddress, _royaltyFee)
VRFConsumerBase(_vrfCoordinator, _link)
{
keyHash = _keyHash;
fee = _fee;
_tokenPrice = _tokenSalePrice;
}
// ----- VIEWS ----- //
function contractURI() public pure returns (string memory) {
return "https://uniqly.io/api/nft-genesis/";
}
function calculateEthPriceForExactUniqs(uint256 _number)
external
view
returns (uint256)
{
return _number * _tokenPrice;
}
function getAllWinners() external view returns (address[] memory) {
uint256 winnersCount = winners.length;
if (winnersCount == 0) {
return new address[](0);
} else {
address[] memory result = new address[](winnersCount);
uint256 index;
for (index = 0; index < winnersCount; index++) {
result[index] = winners[index];
}
return result;
}
}
function getWinner(uint256 _arrayKey) external view returns (address) {
return winners[_arrayKey];
}
function getWinnersCount() external view returns (uint256) {
return winners.length;
}
function checkWin(uint256 _tokenId) external view returns (bool) {
return _isWinner(_tokenId);
}
function isAlreadyRececeivedPrize(address _potWinner)
external
view
returns (bool)
{
return (_isAlreadyRececeivedPrize(_potWinner));
}
function _isAlreadyRececeivedPrize(address _potWinner)
internal
view
returns (bool)
{
uint256 i;
uint256 winnersCount = winners.length;
for (i = 0; i < winnersCount; i++) {
if (winners[i] == _potWinner) return true;
}
return false;
}
// ----- PUBLIC METHODS ----- //
//emits Transfer event
function mintUniqly(uint256 numUniqlies) external payable {
require(_saleStarted, "Sale not started yet");
uint256 requiredValue = numUniqlies * _tokenPrice;
uint256 mintIndex = totalSupply();
require(msg.value >= requiredValue, "Not enough ether");
require(
(numUniqlies + mintIndex) <= _maxUniqly,
"You cannot buy that many tokens"
);
for (uint256 i = 0; i < numUniqlies; i++) {
_safeMint(msg.sender, mintIndex);
mintIndex++;
}
// send back ETH if one overpay by accident
if (requiredValue < msg.value) {
payable(msg.sender).transfer(msg.value - requiredValue);
}
}
function collectPrize(uint256 _tokenId) external {
require(ownerOf(_tokenId) == msg.sender, "Ownership needed");
require(_isWinner(_tokenId), "You did not win");
require(
!_isAlreadyRececeivedPrize(msg.sender),
"Already received a prize"
);
require(winners.length < 10, "Prize limit reached");
winners.push(msg.sender);
emit PrizeCollected(msg.sender, _tokenId);
payable(msg.sender).transfer(1 ether);
}
receive() external payable {}
// ----- PRIVATE METHODS ----- //
function fulfillRandomness(bytes32, uint256 randomness) internal override {
randomResult = randomness;
}
function _isWinner(uint256 id) internal view returns (bool) {
require(randomResult > 0, "Random must be initiated");
uint256 result = (
uint256(keccak256(abi.encodePacked(id, randomResult)))
) % 10000;
if (result <= 20) return true;
return false;
}
// ----- OWNERS METHODS ----- //
function getRandomNumber(uint256 adminProvidedSeed)
external
onlyOwner
returns (bytes32)
{
require(totalSupply() >= _maxUniqly, "Sale must be ended");
require(randomResult == 0, "Random number already initiated");
require(address(this).balance >= 10 ether, "min 10 ETH balance required");
require(
LINK.balanceOf(address(this)) >= fee,
"Not enough LINK"
);
return requestRandomness(keyHash, fee, adminProvidedSeed);
}
function batchMintAsOwner(
uint[] memory _ids,
address[] memory _addresses
) external onlyOwner {
uint len = _ids.length;
require(len == _addresses.length, "Arrays length");
uint256 i = 0;
for (i = 0; i < len; i++) {
_safeMint(_addresses[i], _ids[i]);
}
}
function editSaleStatus(bool _isEnable) external onlyOwner{
_saleStarted = _isEnable;
}
function withdrawAll() external onlyOwner {
require(payable(msg.sender).send(address(this).balance));
}
function recoverERC20(address token) external onlyOwner {
uint256 val = IERC20(token).balanceOf(address(this));
require(val > 0, "Nothing to recover");
// use interface that not return value (USDT case)
Ierc20(token).transfer(owner(), val);
}
function setRandomResualAsAdmin(uint256 _newRandomResult) external onlyOwner{
require(randomResult == 0, "Random number already initiated");
randomResult = _newRandomResult;
}
function editTokenPrice(uint256 _newPrice) external onlyOwner{
_tokenPrice = _newPrice;
}
function editTokenUri(string memory _ttokenUri) external onlyOwner {
_token_uri = _ttokenUri;
}
} | mintUniqly | function mintUniqly(uint256 numUniqlies) external payable {
require(_saleStarted, "Sale not started yet");
uint256 requiredValue = numUniqlies * _tokenPrice;
uint256 mintIndex = totalSupply();
require(msg.value >= requiredValue, "Not enough ether");
require(
(numUniqlies + mintIndex) <= _maxUniqly,
"You cannot buy that many tokens"
);
for (uint256 i = 0; i < numUniqlies; i++) {
_safeMint(msg.sender, mintIndex);
mintIndex++;
}
// send back ETH if one overpay by accident
if (requiredValue < msg.value) {
payable(msg.sender).transfer(msg.value - requiredValue);
}
}
| // ----- PUBLIC METHODS ----- //
//emits Transfer event | LineComment | v0.8.6+commit.11564f7e | MIT | ipfs://5adf4d24848f3e599a1110d0be7c407fa8f355a20311f48c1565b436f59758af | {
"func_code_index": [
2829,
3553
]
} | 11,126 |
||
UniqGenesis | ./contracts/UniqGenesis.sol | 0xd804c52524f1cfad0fae54d2f2b15871337e96b3 | Solidity | UniqGenesis | contract UniqGenesis is ERC721Claimable, VRFConsumerBase {
// ----- EVENTS ----- //
event PrizeCollected(address indexed _winner, uint256 _tokenId);
// ----- VARIABLES ----- //
//Sale
uint256 internal constant _maxUniqly = 10000;
bool internal _saleStarted;
uint256 internal _tokenPrice;
//VRF + Prizes
bytes32 internal immutable keyHash;
uint256 internal immutable fee;
uint256 public randomResult;
address[] public winners;
// ----- CONSTRUCTOR ----- //
constructor(
string memory _bURI,
string memory _name,
string memory _symbol,
address _vrfCoordinator,
address _link,
bytes32 _keyHash,
uint256 _fee,
address _proxyRegistryAddress,
address _claimingContractAddress,
uint256 _tokenSalePrice,
uint256 _royaltyFee
)
ERC721Claimable(_name, _symbol, _bURI, _proxyRegistryAddress,_claimingContractAddress, _royaltyFee)
VRFConsumerBase(_vrfCoordinator, _link)
{
keyHash = _keyHash;
fee = _fee;
_tokenPrice = _tokenSalePrice;
}
// ----- VIEWS ----- //
function contractURI() public pure returns (string memory) {
return "https://uniqly.io/api/nft-genesis/";
}
function calculateEthPriceForExactUniqs(uint256 _number)
external
view
returns (uint256)
{
return _number * _tokenPrice;
}
function getAllWinners() external view returns (address[] memory) {
uint256 winnersCount = winners.length;
if (winnersCount == 0) {
return new address[](0);
} else {
address[] memory result = new address[](winnersCount);
uint256 index;
for (index = 0; index < winnersCount; index++) {
result[index] = winners[index];
}
return result;
}
}
function getWinner(uint256 _arrayKey) external view returns (address) {
return winners[_arrayKey];
}
function getWinnersCount() external view returns (uint256) {
return winners.length;
}
function checkWin(uint256 _tokenId) external view returns (bool) {
return _isWinner(_tokenId);
}
function isAlreadyRececeivedPrize(address _potWinner)
external
view
returns (bool)
{
return (_isAlreadyRececeivedPrize(_potWinner));
}
function _isAlreadyRececeivedPrize(address _potWinner)
internal
view
returns (bool)
{
uint256 i;
uint256 winnersCount = winners.length;
for (i = 0; i < winnersCount; i++) {
if (winners[i] == _potWinner) return true;
}
return false;
}
// ----- PUBLIC METHODS ----- //
//emits Transfer event
function mintUniqly(uint256 numUniqlies) external payable {
require(_saleStarted, "Sale not started yet");
uint256 requiredValue = numUniqlies * _tokenPrice;
uint256 mintIndex = totalSupply();
require(msg.value >= requiredValue, "Not enough ether");
require(
(numUniqlies + mintIndex) <= _maxUniqly,
"You cannot buy that many tokens"
);
for (uint256 i = 0; i < numUniqlies; i++) {
_safeMint(msg.sender, mintIndex);
mintIndex++;
}
// send back ETH if one overpay by accident
if (requiredValue < msg.value) {
payable(msg.sender).transfer(msg.value - requiredValue);
}
}
function collectPrize(uint256 _tokenId) external {
require(ownerOf(_tokenId) == msg.sender, "Ownership needed");
require(_isWinner(_tokenId), "You did not win");
require(
!_isAlreadyRececeivedPrize(msg.sender),
"Already received a prize"
);
require(winners.length < 10, "Prize limit reached");
winners.push(msg.sender);
emit PrizeCollected(msg.sender, _tokenId);
payable(msg.sender).transfer(1 ether);
}
receive() external payable {}
// ----- PRIVATE METHODS ----- //
function fulfillRandomness(bytes32, uint256 randomness) internal override {
randomResult = randomness;
}
function _isWinner(uint256 id) internal view returns (bool) {
require(randomResult > 0, "Random must be initiated");
uint256 result = (
uint256(keccak256(abi.encodePacked(id, randomResult)))
) % 10000;
if (result <= 20) return true;
return false;
}
// ----- OWNERS METHODS ----- //
function getRandomNumber(uint256 adminProvidedSeed)
external
onlyOwner
returns (bytes32)
{
require(totalSupply() >= _maxUniqly, "Sale must be ended");
require(randomResult == 0, "Random number already initiated");
require(address(this).balance >= 10 ether, "min 10 ETH balance required");
require(
LINK.balanceOf(address(this)) >= fee,
"Not enough LINK"
);
return requestRandomness(keyHash, fee, adminProvidedSeed);
}
function batchMintAsOwner(
uint[] memory _ids,
address[] memory _addresses
) external onlyOwner {
uint len = _ids.length;
require(len == _addresses.length, "Arrays length");
uint256 i = 0;
for (i = 0; i < len; i++) {
_safeMint(_addresses[i], _ids[i]);
}
}
function editSaleStatus(bool _isEnable) external onlyOwner{
_saleStarted = _isEnable;
}
function withdrawAll() external onlyOwner {
require(payable(msg.sender).send(address(this).balance));
}
function recoverERC20(address token) external onlyOwner {
uint256 val = IERC20(token).balanceOf(address(this));
require(val > 0, "Nothing to recover");
// use interface that not return value (USDT case)
Ierc20(token).transfer(owner(), val);
}
function setRandomResualAsAdmin(uint256 _newRandomResult) external onlyOwner{
require(randomResult == 0, "Random number already initiated");
randomResult = _newRandomResult;
}
function editTokenPrice(uint256 _newPrice) external onlyOwner{
_tokenPrice = _newPrice;
}
function editTokenUri(string memory _ttokenUri) external onlyOwner {
_token_uri = _ttokenUri;
}
} | fulfillRandomness | function fulfillRandomness(bytes32, uint256 randomness) internal override {
randomResult = randomness;
}
| // ----- PRIVATE METHODS ----- // | LineComment | v0.8.6+commit.11564f7e | MIT | ipfs://5adf4d24848f3e599a1110d0be7c407fa8f355a20311f48c1565b436f59758af | {
"func_code_index": [
4129,
4249
]
} | 11,127 |
||
UniqGenesis | ./contracts/UniqGenesis.sol | 0xd804c52524f1cfad0fae54d2f2b15871337e96b3 | Solidity | UniqGenesis | contract UniqGenesis is ERC721Claimable, VRFConsumerBase {
// ----- EVENTS ----- //
event PrizeCollected(address indexed _winner, uint256 _tokenId);
// ----- VARIABLES ----- //
//Sale
uint256 internal constant _maxUniqly = 10000;
bool internal _saleStarted;
uint256 internal _tokenPrice;
//VRF + Prizes
bytes32 internal immutable keyHash;
uint256 internal immutable fee;
uint256 public randomResult;
address[] public winners;
// ----- CONSTRUCTOR ----- //
constructor(
string memory _bURI,
string memory _name,
string memory _symbol,
address _vrfCoordinator,
address _link,
bytes32 _keyHash,
uint256 _fee,
address _proxyRegistryAddress,
address _claimingContractAddress,
uint256 _tokenSalePrice,
uint256 _royaltyFee
)
ERC721Claimable(_name, _symbol, _bURI, _proxyRegistryAddress,_claimingContractAddress, _royaltyFee)
VRFConsumerBase(_vrfCoordinator, _link)
{
keyHash = _keyHash;
fee = _fee;
_tokenPrice = _tokenSalePrice;
}
// ----- VIEWS ----- //
function contractURI() public pure returns (string memory) {
return "https://uniqly.io/api/nft-genesis/";
}
function calculateEthPriceForExactUniqs(uint256 _number)
external
view
returns (uint256)
{
return _number * _tokenPrice;
}
function getAllWinners() external view returns (address[] memory) {
uint256 winnersCount = winners.length;
if (winnersCount == 0) {
return new address[](0);
} else {
address[] memory result = new address[](winnersCount);
uint256 index;
for (index = 0; index < winnersCount; index++) {
result[index] = winners[index];
}
return result;
}
}
function getWinner(uint256 _arrayKey) external view returns (address) {
return winners[_arrayKey];
}
function getWinnersCount() external view returns (uint256) {
return winners.length;
}
function checkWin(uint256 _tokenId) external view returns (bool) {
return _isWinner(_tokenId);
}
function isAlreadyRececeivedPrize(address _potWinner)
external
view
returns (bool)
{
return (_isAlreadyRececeivedPrize(_potWinner));
}
function _isAlreadyRececeivedPrize(address _potWinner)
internal
view
returns (bool)
{
uint256 i;
uint256 winnersCount = winners.length;
for (i = 0; i < winnersCount; i++) {
if (winners[i] == _potWinner) return true;
}
return false;
}
// ----- PUBLIC METHODS ----- //
//emits Transfer event
function mintUniqly(uint256 numUniqlies) external payable {
require(_saleStarted, "Sale not started yet");
uint256 requiredValue = numUniqlies * _tokenPrice;
uint256 mintIndex = totalSupply();
require(msg.value >= requiredValue, "Not enough ether");
require(
(numUniqlies + mintIndex) <= _maxUniqly,
"You cannot buy that many tokens"
);
for (uint256 i = 0; i < numUniqlies; i++) {
_safeMint(msg.sender, mintIndex);
mintIndex++;
}
// send back ETH if one overpay by accident
if (requiredValue < msg.value) {
payable(msg.sender).transfer(msg.value - requiredValue);
}
}
function collectPrize(uint256 _tokenId) external {
require(ownerOf(_tokenId) == msg.sender, "Ownership needed");
require(_isWinner(_tokenId), "You did not win");
require(
!_isAlreadyRececeivedPrize(msg.sender),
"Already received a prize"
);
require(winners.length < 10, "Prize limit reached");
winners.push(msg.sender);
emit PrizeCollected(msg.sender, _tokenId);
payable(msg.sender).transfer(1 ether);
}
receive() external payable {}
// ----- PRIVATE METHODS ----- //
function fulfillRandomness(bytes32, uint256 randomness) internal override {
randomResult = randomness;
}
function _isWinner(uint256 id) internal view returns (bool) {
require(randomResult > 0, "Random must be initiated");
uint256 result = (
uint256(keccak256(abi.encodePacked(id, randomResult)))
) % 10000;
if (result <= 20) return true;
return false;
}
// ----- OWNERS METHODS ----- //
function getRandomNumber(uint256 adminProvidedSeed)
external
onlyOwner
returns (bytes32)
{
require(totalSupply() >= _maxUniqly, "Sale must be ended");
require(randomResult == 0, "Random number already initiated");
require(address(this).balance >= 10 ether, "min 10 ETH balance required");
require(
LINK.balanceOf(address(this)) >= fee,
"Not enough LINK"
);
return requestRandomness(keyHash, fee, adminProvidedSeed);
}
function batchMintAsOwner(
uint[] memory _ids,
address[] memory _addresses
) external onlyOwner {
uint len = _ids.length;
require(len == _addresses.length, "Arrays length");
uint256 i = 0;
for (i = 0; i < len; i++) {
_safeMint(_addresses[i], _ids[i]);
}
}
function editSaleStatus(bool _isEnable) external onlyOwner{
_saleStarted = _isEnable;
}
function withdrawAll() external onlyOwner {
require(payable(msg.sender).send(address(this).balance));
}
function recoverERC20(address token) external onlyOwner {
uint256 val = IERC20(token).balanceOf(address(this));
require(val > 0, "Nothing to recover");
// use interface that not return value (USDT case)
Ierc20(token).transfer(owner(), val);
}
function setRandomResualAsAdmin(uint256 _newRandomResult) external onlyOwner{
require(randomResult == 0, "Random number already initiated");
randomResult = _newRandomResult;
}
function editTokenPrice(uint256 _newPrice) external onlyOwner{
_tokenPrice = _newPrice;
}
function editTokenUri(string memory _ttokenUri) external onlyOwner {
_token_uri = _ttokenUri;
}
} | getRandomNumber | function getRandomNumber(uint256 adminProvidedSeed)
external
onlyOwner
returns (bytes32)
{
require(totalSupply() >= _maxUniqly, "Sale must be ended");
require(randomResult == 0, "Random number already initiated");
require(address(this).balance >= 10 ether, "min 10 ETH balance required");
require(
LINK.balanceOf(address(this)) >= fee,
"Not enough LINK"
);
return requestRandomness(keyHash, fee, adminProvidedSeed);
}
| // ----- OWNERS METHODS ----- // | LineComment | v0.8.6+commit.11564f7e | MIT | ipfs://5adf4d24848f3e599a1110d0be7c407fa8f355a20311f48c1565b436f59758af | {
"func_code_index": [
4598,
5123
]
} | 11,128 |
||
ProxyRoot | @openzeppelin/upgrades/contracts/upgradeability/ProxyAdmin.sol | 0x4d2a5e3b7831156f62c8df47604e321cdaf35fec | Solidity | ProxyAdmin | contract ProxyAdmin is OpenZeppelinUpgradesOwnable {
/**
* @dev Returns the current implementation of a proxy.
* This is needed because only the proxy admin can query it.
* @return The address of the current implementation of the proxy.
*/
function getProxyImplementation(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("implementation()")) == 0x5c60da1b
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
require(success);
return abi.decode(returndata, (address));
}
/**
* @dev Returns the admin of a proxy. Only the admin can query it.
* @return The address of the current admin of the proxy.
*/
function getProxyAdmin(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("admin()")) == 0xf851a440
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
require(success);
return abi.decode(returndata, (address));
}
/**
* @dev Changes the admin of a proxy.
* @param proxy Proxy to change admin.
* @param newAdmin Address to transfer proxy administration to.
*/
function changeProxyAdmin(AdminUpgradeabilityProxy proxy, address newAdmin) public onlyOwner {
proxy.changeAdmin(newAdmin);
}
/**
* @dev Upgrades a proxy to the newest implementation of a contract.
* @param proxy Proxy to be upgraded.
* @param implementation the address of the Implementation.
*/
function upgrade(AdminUpgradeabilityProxy proxy, address implementation) public onlyOwner {
proxy.upgradeTo(implementation);
}
/**
* @dev Upgrades a proxy to the newest implementation of a contract and forwards a function call to it.
* This is useful to initialize the proxied contract.
* @param proxy Proxy to be upgraded.
* @param implementation Address of the Implementation.
* @param data Data to send as msg.data in the low level call.
* It should include the signature and the parameters of the function to be called, as described in
* https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
*/
function upgradeAndCall(AdminUpgradeabilityProxy proxy, address implementation, bytes memory data) payable public onlyOwner {
proxy.upgradeToAndCall.value(msg.value)(implementation, data);
}
} | /**
* @title ProxyAdmin
* @dev This contract is the admin of a proxy, and is in charge
* of upgrading it as well as transferring it to another admin.
*/ | NatSpecMultiLine | getProxyImplementation | function getProxyImplementation(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("implementation()")) == 0x5c60da1b
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
require(success);
return abi.decode(returndata, (address));
}
| /**
* @dev Returns the current implementation of a proxy.
* This is needed because only the proxy admin can query it.
* @return The address of the current implementation of the proxy.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | {
"func_code_index": [
257,
663
]
} | 11,129 |
||
ProxyRoot | @openzeppelin/upgrades/contracts/upgradeability/ProxyAdmin.sol | 0x4d2a5e3b7831156f62c8df47604e321cdaf35fec | Solidity | ProxyAdmin | contract ProxyAdmin is OpenZeppelinUpgradesOwnable {
/**
* @dev Returns the current implementation of a proxy.
* This is needed because only the proxy admin can query it.
* @return The address of the current implementation of the proxy.
*/
function getProxyImplementation(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("implementation()")) == 0x5c60da1b
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
require(success);
return abi.decode(returndata, (address));
}
/**
* @dev Returns the admin of a proxy. Only the admin can query it.
* @return The address of the current admin of the proxy.
*/
function getProxyAdmin(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("admin()")) == 0xf851a440
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
require(success);
return abi.decode(returndata, (address));
}
/**
* @dev Changes the admin of a proxy.
* @param proxy Proxy to change admin.
* @param newAdmin Address to transfer proxy administration to.
*/
function changeProxyAdmin(AdminUpgradeabilityProxy proxy, address newAdmin) public onlyOwner {
proxy.changeAdmin(newAdmin);
}
/**
* @dev Upgrades a proxy to the newest implementation of a contract.
* @param proxy Proxy to be upgraded.
* @param implementation the address of the Implementation.
*/
function upgrade(AdminUpgradeabilityProxy proxy, address implementation) public onlyOwner {
proxy.upgradeTo(implementation);
}
/**
* @dev Upgrades a proxy to the newest implementation of a contract and forwards a function call to it.
* This is useful to initialize the proxied contract.
* @param proxy Proxy to be upgraded.
* @param implementation Address of the Implementation.
* @param data Data to send as msg.data in the low level call.
* It should include the signature and the parameters of the function to be called, as described in
* https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
*/
function upgradeAndCall(AdminUpgradeabilityProxy proxy, address implementation, bytes memory data) payable public onlyOwner {
proxy.upgradeToAndCall.value(msg.value)(implementation, data);
}
} | /**
* @title ProxyAdmin
* @dev This contract is the admin of a proxy, and is in charge
* of upgrading it as well as transferring it to another admin.
*/ | NatSpecMultiLine | getProxyAdmin | function getProxyAdmin(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("admin()")) == 0xf851a440
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
require(success);
return abi.decode(returndata, (address));
}
| /**
* @dev Returns the admin of a proxy. Only the admin can query it.
* @return The address of the current admin of the proxy.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | {
"func_code_index": [
806,
1194
]
} | 11,130 |
||
ProxyRoot | @openzeppelin/upgrades/contracts/upgradeability/ProxyAdmin.sol | 0x4d2a5e3b7831156f62c8df47604e321cdaf35fec | Solidity | ProxyAdmin | contract ProxyAdmin is OpenZeppelinUpgradesOwnable {
/**
* @dev Returns the current implementation of a proxy.
* This is needed because only the proxy admin can query it.
* @return The address of the current implementation of the proxy.
*/
function getProxyImplementation(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("implementation()")) == 0x5c60da1b
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
require(success);
return abi.decode(returndata, (address));
}
/**
* @dev Returns the admin of a proxy. Only the admin can query it.
* @return The address of the current admin of the proxy.
*/
function getProxyAdmin(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("admin()")) == 0xf851a440
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
require(success);
return abi.decode(returndata, (address));
}
/**
* @dev Changes the admin of a proxy.
* @param proxy Proxy to change admin.
* @param newAdmin Address to transfer proxy administration to.
*/
function changeProxyAdmin(AdminUpgradeabilityProxy proxy, address newAdmin) public onlyOwner {
proxy.changeAdmin(newAdmin);
}
/**
* @dev Upgrades a proxy to the newest implementation of a contract.
* @param proxy Proxy to be upgraded.
* @param implementation the address of the Implementation.
*/
function upgrade(AdminUpgradeabilityProxy proxy, address implementation) public onlyOwner {
proxy.upgradeTo(implementation);
}
/**
* @dev Upgrades a proxy to the newest implementation of a contract and forwards a function call to it.
* This is useful to initialize the proxied contract.
* @param proxy Proxy to be upgraded.
* @param implementation Address of the Implementation.
* @param data Data to send as msg.data in the low level call.
* It should include the signature and the parameters of the function to be called, as described in
* https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
*/
function upgradeAndCall(AdminUpgradeabilityProxy proxy, address implementation, bytes memory data) payable public onlyOwner {
proxy.upgradeToAndCall.value(msg.value)(implementation, data);
}
} | /**
* @title ProxyAdmin
* @dev This contract is the admin of a proxy, and is in charge
* of upgrading it as well as transferring it to another admin.
*/ | NatSpecMultiLine | changeProxyAdmin | function changeProxyAdmin(AdminUpgradeabilityProxy proxy, address newAdmin) public onlyOwner {
proxy.changeAdmin(newAdmin);
}
| /**
* @dev Changes the admin of a proxy.
* @param proxy Proxy to change admin.
* @param newAdmin Address to transfer proxy administration to.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | {
"func_code_index": [
1355,
1488
]
} | 11,131 |
||
ProxyRoot | @openzeppelin/upgrades/contracts/upgradeability/ProxyAdmin.sol | 0x4d2a5e3b7831156f62c8df47604e321cdaf35fec | Solidity | ProxyAdmin | contract ProxyAdmin is OpenZeppelinUpgradesOwnable {
/**
* @dev Returns the current implementation of a proxy.
* This is needed because only the proxy admin can query it.
* @return The address of the current implementation of the proxy.
*/
function getProxyImplementation(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("implementation()")) == 0x5c60da1b
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
require(success);
return abi.decode(returndata, (address));
}
/**
* @dev Returns the admin of a proxy. Only the admin can query it.
* @return The address of the current admin of the proxy.
*/
function getProxyAdmin(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("admin()")) == 0xf851a440
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
require(success);
return abi.decode(returndata, (address));
}
/**
* @dev Changes the admin of a proxy.
* @param proxy Proxy to change admin.
* @param newAdmin Address to transfer proxy administration to.
*/
function changeProxyAdmin(AdminUpgradeabilityProxy proxy, address newAdmin) public onlyOwner {
proxy.changeAdmin(newAdmin);
}
/**
* @dev Upgrades a proxy to the newest implementation of a contract.
* @param proxy Proxy to be upgraded.
* @param implementation the address of the Implementation.
*/
function upgrade(AdminUpgradeabilityProxy proxy, address implementation) public onlyOwner {
proxy.upgradeTo(implementation);
}
/**
* @dev Upgrades a proxy to the newest implementation of a contract and forwards a function call to it.
* This is useful to initialize the proxied contract.
* @param proxy Proxy to be upgraded.
* @param implementation Address of the Implementation.
* @param data Data to send as msg.data in the low level call.
* It should include the signature and the parameters of the function to be called, as described in
* https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
*/
function upgradeAndCall(AdminUpgradeabilityProxy proxy, address implementation, bytes memory data) payable public onlyOwner {
proxy.upgradeToAndCall.value(msg.value)(implementation, data);
}
} | /**
* @title ProxyAdmin
* @dev This contract is the admin of a proxy, and is in charge
* of upgrading it as well as transferring it to another admin.
*/ | NatSpecMultiLine | upgrade | function upgrade(AdminUpgradeabilityProxy proxy, address implementation) public onlyOwner {
proxy.upgradeTo(implementation);
}
| /**
* @dev Upgrades a proxy to the newest implementation of a contract.
* @param proxy Proxy to be upgraded.
* @param implementation the address of the Implementation.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | {
"func_code_index": [
1675,
1809
]
} | 11,132 |
||
ProxyRoot | @openzeppelin/upgrades/contracts/upgradeability/ProxyAdmin.sol | 0x4d2a5e3b7831156f62c8df47604e321cdaf35fec | Solidity | ProxyAdmin | contract ProxyAdmin is OpenZeppelinUpgradesOwnable {
/**
* @dev Returns the current implementation of a proxy.
* This is needed because only the proxy admin can query it.
* @return The address of the current implementation of the proxy.
*/
function getProxyImplementation(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("implementation()")) == 0x5c60da1b
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
require(success);
return abi.decode(returndata, (address));
}
/**
* @dev Returns the admin of a proxy. Only the admin can query it.
* @return The address of the current admin of the proxy.
*/
function getProxyAdmin(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("admin()")) == 0xf851a440
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
require(success);
return abi.decode(returndata, (address));
}
/**
* @dev Changes the admin of a proxy.
* @param proxy Proxy to change admin.
* @param newAdmin Address to transfer proxy administration to.
*/
function changeProxyAdmin(AdminUpgradeabilityProxy proxy, address newAdmin) public onlyOwner {
proxy.changeAdmin(newAdmin);
}
/**
* @dev Upgrades a proxy to the newest implementation of a contract.
* @param proxy Proxy to be upgraded.
* @param implementation the address of the Implementation.
*/
function upgrade(AdminUpgradeabilityProxy proxy, address implementation) public onlyOwner {
proxy.upgradeTo(implementation);
}
/**
* @dev Upgrades a proxy to the newest implementation of a contract and forwards a function call to it.
* This is useful to initialize the proxied contract.
* @param proxy Proxy to be upgraded.
* @param implementation Address of the Implementation.
* @param data Data to send as msg.data in the low level call.
* It should include the signature and the parameters of the function to be called, as described in
* https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
*/
function upgradeAndCall(AdminUpgradeabilityProxy proxy, address implementation, bytes memory data) payable public onlyOwner {
proxy.upgradeToAndCall.value(msg.value)(implementation, data);
}
} | /**
* @title ProxyAdmin
* @dev This contract is the admin of a proxy, and is in charge
* of upgrading it as well as transferring it to another admin.
*/ | NatSpecMultiLine | upgradeAndCall | function upgradeAndCall(AdminUpgradeabilityProxy proxy, address implementation, bytes memory data) payable public onlyOwner {
proxy.upgradeToAndCall.value(msg.value)(implementation, data);
}
| /**
* @dev Upgrades a proxy to the newest implementation of a contract and forwards a function call to it.
* This is useful to initialize the proxied contract.
* @param proxy Proxy to be upgraded.
* @param implementation Address of the Implementation.
* @param data Data to send as msg.data in the low level call.
* It should include the signature and the parameters of the function to be called, as described in
* https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | {
"func_code_index": [
2353,
2551
]
} | 11,133 |
||
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | _baseURI | function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
| /*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
1426,
1530
]
} | 11,134 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | pause | function pause() public onlyOwner {
_pause();
}
| /*
* @dev Pauses the contract.
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
2046,
2100
]
} | 11,135 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | resume | function resume() public onlyOwner {
_resume();
}
| /*
* @dev Resumes the contract.
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
2146,
2202
]
} | 11,136 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | disablePreSale | function disablePreSale() public onlyOwner {
_disablePreSale();
}
| /*
* @dev Disables presale.
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
2244,
2316
]
} | 11,137 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | enablePreSale | function enablePreSale() public onlyOwner {
_enablePreSale();
}
| /*
* @dev Enables presale.
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
2357,
2427
]
} | 11,138 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | withdraw | function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
| /*
* @dev Withdraws the contracts balance to owner and DAO.
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
2501,
2856
]
} | 11,139 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | reveal | function reveal() public onlyOwner {
revealed = true;
}
| /*
* @dev Reveals the artwork.
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
2901,
2963
]
} | 11,140 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | hide | function hide() public onlyOwner {
revealed = false;
}
| /*
* @dev Hides the artwork.
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
3006,
3067
]
} | 11,141 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | setUriPrefix | function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
| /*
* @dev Sets uri prefix for revealed tokens
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
3127,
3226
]
} | 11,142 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | setHiddenMetadataUri | function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
| /*
* @dev Sets uri prefix for hidden tokens
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
3284,
3415
]
} | 11,143 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | _mintDoggo | function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
| /*
* @dev Mints a doggo to an address
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
3467,
3560
]
} | 11,144 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | presaleMintDoggo | function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
| /*
* @dev Mints doggos when presale is enabled.
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
3622,
4354
]
} | 11,145 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | mintDoggo | function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
| /*
* @dev Mints doggos when presale is disabled.
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
4417,
4925
]
} | 11,146 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | numberMinted | function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
| /*
* @dev Returns the number of tokens minted by an address
*/ | Comment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
4999,
5107
]
} | 11,147 |
Doggo | contracts/Doggo.sol | 0x46ccb782da782b9e921dd447736ab64fc4fb2636 | Solidity | Doggo | contract Doggo is ERC721A, Ownable, Pausable, PreSaleAware, ReentrancyGuard {
using Strings for uint256;
uint256 public constant COST = 0.08 ether; // the cost per doggo
// the merkle root used for verifying proofs during presale
bytes32 public constant PRE_SALE_MERKLE_ROOT = 0x9f93df4f70710b1cc9fa86ee3c87cc30f77a6709363ccd6bdddeae109330be37;
// packing the next variables as uint16 (max 65535, 2 bytes each, less than 32 bytes = 1 slot)
uint16 public constant MAX_SUPPLY = 8888; // the max total supply
uint16 public constant MAX_PUBLIC_SUPPLY = 8388; // the max public supply
uint16 public constant MAX_MINT_AMOUNT = 10; // the max amount an address can mint
uint16 public constant PRE_SALE_MAX_MINT_AMOUNT = 5; // the max amount an address can mint during presale
// the address of the DAO treasury that will receive percentage of all withdrawls
address public constant DAO_TREASURY_ADDRESS = 0x8C3b934E904b25455F53eFC2beCA8693406E15b1;
string public hiddenMetadataUri;
string public uriPrefix = "";
bool public revealed = false; // determines whether the artwork is revealed
constructor() ERC721A("Doggo Verse", "DV", 500) {
setHiddenMetadataUri("ipfs://QmU3iVT84VGGY5T2jDfgTzqG8VtcRPdtND5Ma6568Pgfhs/unreaveled");
}
/*
* Base URI for computing {tokenURI}. The resulting URI for each token will be
* the concatenation of the `baseURI` and the `tokenId`.
*/
function _baseURI() internal view override(ERC721A) returns (string memory) {
return uriPrefix;
}
function tokenURI(uint256 _tokenId) public view override(ERC721A) returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString())) : "";
}
// The following functions are available only to the owner
/*
* @dev Pauses the contract.
*/
function pause() public onlyOwner {
_pause();
}
/*
* @dev Resumes the contract.
*/
function resume() public onlyOwner {
_resume();
}
/*
* @dev Disables presale.
*/
function disablePreSale() public onlyOwner {
_disablePreSale();
}
/*
* @dev Enables presale.
*/
function enablePreSale() public onlyOwner {
_enablePreSale();
}
/*
* @dev Withdraws the contracts balance to owner and DAO.
*/
function withdraw() public onlyOwner {
// Reserve 30% for DAO treasury
(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
require(hs, "DAO tranfer failed");
// owner only
(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
require(os, "owner transfer failed");
}
/*
* @dev Reveals the artwork.
*/
function reveal() public onlyOwner {
revealed = true;
}
/*
* @dev Hides the artwork.
*/
function hide() public onlyOwner {
revealed = false;
}
/*
* @dev Sets uri prefix for revealed tokens
*/
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
/*
* @dev Sets uri prefix for hidden tokens
*/
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
/*
* @dev Mints a doggo to an address
*/
function _mintDoggo(address to, uint256 quantity) private {
_safeMint(to, quantity);
}
/*
* @dev Mints doggos when presale is enabled.
*/
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
external
payable
whenNotPaused
whenPreSale
nonReentrant
{
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(
MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
"Address not on the list"
);
require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Mints doggos when presale is disabled.
*/
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");
if (_msgSender() != owner()) {
require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
require(msg.value >= COST * quantity, "incorrect ether value");
}
_mintDoggo(_msgSender(), quantity);
}
/*
* @dev Returns the number of tokens minted by an address
*/
function numberMinted(address _owner) public view returns (uint256) {
return _numberMinted(_owner);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | /*
`..:`.
``.-/.::/..```.-----:-`
```....````.-.` `...-:+------..:.
`.:-..``..---` ./+//-`./`+
`/. ``` :: /-`+`+
`+` .::+ /. :+::`
.: `/ -+ `+
`/ /. `o /.`
::` + `o `:-:`
`:---:- `+: ``::`
````` `o. `+
-: :-
+` :-
-: `+`
`/- `-:`
`::. `..-:---...-:-.`
`-:-.....-+-..//`.....`
`......+ -/
`.::-. .:-`
`-:-` .::`
`./- `:-`
`://` `+/`
`/:/` .++`
`+-/ .+/
________ ________ ________ ________ ________ ___ ___ _______ ________ ________ _______
|\ ___ \|\ __ \|\ ____\|\ ____\|\ __ \ |\ \ / /|\ ___ \ |\ __ \|\ ____\|\ ___ \
\ \ \_|\ \ \ \|\ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ / / | \ __/|\ \ \|\ \ \ \___|\ \ __/|
\ \ \ \\ \ \ \\\ \ \ \ __\ \ \ __\ \ \\\ \ \ \ \/ / / \ \ \_|/_\ \ _ _\ \_____ \ \ \_|/__
\ \ \_\\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \\\ \ \ \ / / \ \ \_|\ \ \ \\ \\|____|\ \ \ \_|\ \
\ \_______\ \_______\ \_______\ \_______\ \_______\ \ \__/ / \ \_______\ \__\\ _\ ____\_\ \ \_______\
\|_______|\|_______|\|_______|\|_______|\|_______| \|__|/ \|_______|\|__|\|__|\_________\|_______|
\|_________|
*/ | Comment | supportsInterface | function supportsInterface(bytes4 interfaceId) public view override(ERC721A) returns (bool) {
return super.supportsInterface(interfaceId);
}
| // The following functions are overrides required by Solidity. | LineComment | v0.8.11+commit.d7f03943 | MIT | ipfs://b7bbd7ee9ab1542a8a2cb4bb6c14579b679e08db33719593c8b0618bf852ee99 | {
"func_code_index": [
5177,
5324
]
} | 11,148 |
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | hasSendDirection | function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
| /**
* @dev hasSendDirection
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
435,
593
]
} | 11,149 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | hasReceiveDirection | function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
| /**
* @dev hasReceiveDirection
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
641,
813
]
} | 11,150 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | restriction | function restriction() public view returns (Direction) {
return lock.restriction;
}
| /**
* @dev restriction
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
853,
947
]
} | 11,151 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | scheduledStartAt | function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
| /**
* @dev scheduledStartAt
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
992,
1085
]
} | 11,152 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | scheduledEndAt | function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
| /**
* @dev scheduledEndAt
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
1128,
1217
]
} | 11,153 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | isScheduleInverted | function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
| /**
* @dev lock inverted
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
1259,
1360
]
} | 11,154 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | isLocked | function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
| /**
* @dev isLocked
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
1397,
1623
]
} | 11,155 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | individualPass | function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
| /**
* @dev individualPass
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
1666,
1797
]
} | 11,156 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | canSend | function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
| /**
* @dev can the address send
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
1846,
2063
]
} | 11,157 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | canReceive | function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
| /**
* @dev can the address receive
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
2115,
2341
]
} | 11,158 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | definePass | function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
| /**
* @dev allow authority to provide a pass to an address
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
2417,
2647
]
} | 11,159 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | defineManyPasses | function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
| /**
* @dev allow authority to provide addresses with lock passes
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
2729,
2984
]
} | 11,160 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | scheduleLock | function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
| /**
* @dev schedule lock
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
3026,
3451
]
} | 11,161 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | isAddressValid | function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
| /**
* @dev validates an address
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
3500,
3600
]
} | 11,162 |
|
LockRule | contracts/rule/LockRule.sol | 0x80c26f10fa35a1b5ef3fb96e34920994400aa21f | Solidity | LockRule | contract LockRule is IRule, Authority {
enum Direction {
NONE,
RECEIVE,
SEND,
BOTH
}
struct ScheduledLock {
Direction restriction;
uint256 startAt;
uint256 endAt;
bool scheduleInverted;
}
mapping(address => Direction) individualPasses;
ScheduledLock lock = ScheduledLock(
Direction.NONE,
0,
0,
false
);
/**
* @dev hasSendDirection
*/
function hasSendDirection(Direction _direction) public pure returns (bool) {
return _direction == Direction.SEND || _direction == Direction.BOTH;
}
/**
* @dev hasReceiveDirection
*/
function hasReceiveDirection(Direction _direction)
public pure returns (bool)
{
return _direction == Direction.RECEIVE || _direction == Direction.BOTH;
}
/**
* @dev restriction
*/
function restriction() public view returns (Direction) {
return lock.restriction;
}
/**
* @dev scheduledStartAt
*/
function scheduledStartAt() public view returns (uint256) {
return lock.startAt;
}
/**
* @dev scheduledEndAt
*/
function scheduledEndAt() public view returns (uint256) {
return lock.endAt;
}
/**
* @dev lock inverted
*/
function isScheduleInverted() public view returns (bool) {
return lock.scheduleInverted;
}
/**
* @dev isLocked
*/
function isLocked() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return (lock.startAt <= now && lock.endAt > now)
? !lock.scheduleInverted : lock.scheduleInverted;
}
/**
* @dev individualPass
*/
function individualPass(address _address)
public view returns (Direction)
{
return individualPasses[_address];
}
/**
* @dev can the address send
*/
function canSend(address _address) public view returns (bool) {
if (isLocked() && hasSendDirection(lock.restriction)) {
return hasSendDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev can the address receive
*/
function canReceive(address _address) public view returns (bool) {
if (isLocked() && hasReceiveDirection(lock.restriction)) {
return hasReceiveDirection(individualPasses[_address]);
}
return true;
}
/**
* @dev allow authority to provide a pass to an address
*/
function definePass(address _address, uint256 _lock)
public onlyAuthority returns (bool)
{
individualPasses[_address] = Direction(_lock);
emit PassDefinition(_address, Direction(_lock));
return true;
}
/**
* @dev allow authority to provide addresses with lock passes
*/
function defineManyPasses(address[] _addresses, uint256 _lock)
public onlyAuthority returns (bool)
{
for (uint256 i = 0; i < _addresses.length; i++) {
require(definePass(_addresses[i], _lock), "LOR01");
}
return true;
}
/**
* @dev schedule lock
*/
function scheduleLock(
Direction _restriction,
uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
public onlyAuthority returns (bool)
{
require(_startAt <= _endAt, "LOR02");
lock = ScheduledLock(
_restriction,
_startAt,
_endAt,
_scheduleInverted
);
emit LockDefinition(
lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
}
/**
* @dev validates an address
*/
function isAddressValid(address /*_address*/) public view returns (bool) {
return true;
}
/**
* @dev validates a transfer of ownership
*/
function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
event LockDefinition(
Direction restriction,
uint256 startAt,
uint256 endAt,
bool scheduleInverted
);
event PassDefinition(address _address, Direction pass);
} | /**
* @title LockRule
* @dev LockRule contract
* This rule allow to lock assets for a period of time
* for event such as investment vesting
*
* @author Cyril Lapinte - <[email protected]>
*
* @notice Copyright © 2016 - 2018 Mt Pelerin Group SA - All Rights Reserved
* @notice Please refer to the top of this file for the license.
*
* Error messages
* LOR01: definePass() call have failed
* LOR02: startAt must be before or equal to endAt
*/ | NatSpecMultiLine | isTransferValid | function isTransferValid(address _from, address _to, uint256 /* _amount */)
public view returns (bool)
{
return (canSend(_from) && canReceive(_to));
}
| /**
* @dev validates a transfer of ownership
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://c1f712e9dff61460e0127a4a1f5d3662d216953bc421acfb25d035c986a6c95d | {
"func_code_index": [
3662,
3831
]
} | 11,163 |
|
TulipFloorBidding | contracts/EtherTulip.sol | 0x40ab332dd48f35ebd227708ef381c946c4959eb6 | Solidity | EtherTulip | contract EtherTulip is ERC721("EtherTulip", unicode"🌷") {
struct Tulip {
uint256 listingTime;
uint256 price;
uint256 timesSold;
}
mapping(uint256 => Tulip) public tulips;
uint256 public latestNewTulipForSale;
address public immutable feeRecipient;
event TulipForSale(uint256 tulipNumber, address owner, uint256 price);
event TulipNotForSale(uint256 tulipNumber, address owner);
event TulipSold(uint256 tulipNumber, address buyer, uint256 price);
constructor(address _feeRecipient) {
// set fee recipient
feeRecipient = _feeRecipient;
// mint founder tulip to yours and only
ERC721._mint(address(0x777B0884f97Fd361c55e472530272Be61cEb87c8), 0);
// initialize auction for second tulip
latestNewTulipForSale = 1;
tulips[latestNewTulipForSale].listingTime = block.timestamp;
}
// Dutch-ish Auction
function currentPrice(uint256 tulipNumber) public view returns (uint256 price) {
if (tulipNumber == latestNewTulipForSale) {
// if currently in auction
uint256 initialPrice = 1000 ether;
uint256 decayPeriod = 1 days;
// price = initial_price - initial_price * (current_time - start_time) / decay_period
uint256 elapsedTime = block.timestamp - tulips[tulipNumber].listingTime;
if (elapsedTime >= decayPeriod) return 0;
return initialPrice - ((initialPrice * elapsedTime) / decayPeriod);
} else {
// if not in auction
return tulips[tulipNumber].price;
}
}
// ERC721
function _baseURI() internal pure override returns (string memory) {
return "ipfs://";
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
string memory bulbURI = "bafkreiamkokggzkchkosx5jvz6fduzwcn7qugkp7pytmk327sblrtwa4ze";
string[100] memory tulipURIs = [
"bafkreiajlq3nd3nc7xu245eqwnoqkh4fz25rdkinw7wkjtqp54xcbxdski",
"bafkreickj5f3dw6abk4ezj6vvephroacnizpt474jxjffccklci4bm7ulu",
"bafkreid3ckzlcv3p6zh3o3cwbryno3keqvzyagptnxtoer3awuvyeydz4u",
"bafkreid43dy6zwtnvwo6skonl4tcechlhnu7rihp2gnvoaydpxn3qw6yva",
"bafkreicnjnnu6w3crbzxkoa2g625avmnecrh4ptmuvj2q5izygeqhttjny",
"bafkreiaefcjmmploftqi6ao3dzrpjttnrhay2hqit5pxtzpwkismviwi7e",
"bafkreid2jrk7rquxayxdfvyg3w447wqssoutoybqeihuunmau4n5ourj4i",
"bafkreicvpenpqezcdehpcd2snsgj4ysl2la44fzqdolblr6evpps3uujcm",
"bafkreihuxku32udn2eolrdivdugr2dd5sot2u7cvth3qpsjoqbkllbwkgy",
"bafkreidumlyzcwbuaajaeeycq6e6y2zcr4jwq2amy35nsh7laphiecbyvi",
"bafkreigjkkhwb3rtdgvbhjc6aoarrlqmyfe7f4d67fvtxprqns3r5zu6jm",
"bafkreigmgqiafi4obtmtzzsocylrfcctjtemm3tdvecr3lobo6sqz73o3u",
"bafkreig5b6rx3mdxwyrtnumyehvuetzrs3dwkxv76wtqhfayammh2hlsve",
"bafkreicvhumzmjl7bo4uqhngwxfpk6upry4waxm3csk7wgkkyzjejgcwai",
"bafkreiehn3tovb6wa2nt6nsouavmy6vrijc4z775hk4hjzdn7b5y5lkiya",
"bafkreid6lxzktumy535tvzedks3acaqzrqirim4migkbxrp5erx5g6mfeu",
"bafkreihk3mimxxqimwkowm2arpfaewz7m5o76wcvw4acyixhtun673az34",
"bafkreidrrmeujlvad7oigztu45yeqxwcb6wpo464vwxqst4qo3itwk6ld4",
"bafkreihl6hl2ufborow5cfiypdtkk2segp3vxfetupapsjnjvzwxlq2che",
"bafkreidnv2t75e3kx6ugajs23l4736assxkzrggsocz2dvygsjlvhvntza",
"bafkreih2hhoeruntbfy4ufngko3wbdp4m6gz7otu3hntuvntlflyehkejq",
"bafkreieiqmc2t62t2pgabenfkeiclb4gsifcwgqvmkcwqc7lkaxm4vqvai",
"bafkreieqi56ie7iyl4rne2r7ypnvrbcpvxxqp346c74smgd3vypgspdwdi",
"bafkreidfw4bmdl3rcoehnak43beoeoucbbvtkxlagisvnuchug4foprhpq",
"bafkreiasg674cri4woi2nmf2be27i24gdegxhc5hgahpygd7vqcrqvz4va",
"bafkreidn3ocz3m6lzgu7whiooq74mtczbget5fie7dldzwhafdkty5yje4",
"bafkreieg474qoeg5mykld7dpego4oy4tvjorlgtpjacw3cjrl7oogsfs6a",
"bafkreiclbj3ujgxgh5i3plai5t24p7g2aavfzahu2gxq4mavena5ojxfsm",
"bafkreia2vekumcnyswh2w62htqu7vedtksepokixpqn4qwzxhefj2bdniq",
"bafkreia5456ribmisd555cwt6vzu57oqqkonugozywjuozsoxlo7ffoqxi",
"bafkreiekctvro262pk4uz67jpqivxtniebqk3gyfqkclw2vqy3m3iocw6e",
"bafkreigtxjoh4rx62uzlx4t23txqk3owvn3ckhy766mjiwgvy3fny2ozza",
"bafkreifui4jzaffl74zakibwmt2js2w2qosm7yzgimecwvqpqxpz2psnmu",
"bafkreif7426cefprxiupxwggnkjbtht3f3uiaeci2qc3irlppuy7kqoenq",
"bafkreigdimqwjrkoklbfiigbkfpvmrniealdjr2bv52jb72sfbk6aqorqy",
"bafkreidy2eohxrecrk3si4coolxawlcdmqrvhskhkal4d6bvxjfmds2m24",
"bafkreie3qfepdl4pkse6uu3iqwfb2fqusfp3qsp2rh7ynvptps3bbnqzdm",
"bafkreih2hv3vjipj2kibpynrmulnnoxj5737cbeg2bjl42zc3bhcfdzf2u",
"bafkreiba3227uclzobdglmkvyz4b5da6gp3p3ehtfqznuprlgu3lt7j6nq",
"bafkreiakbrgj7y2hzb7dhrpub6c6i72i3cp6ygsrof55t5ueb7wtg33bae",
"bafkreig5x3r3dqllt2ndhxpahni5fjeeo2obq4ffls4hkbi7a2cfqtappi",
"bafkreihfiplwjo4rdszuhnvjynx7iesij3borjd3rf5onlfgkwlqqjpbou",
"bafkreicpnd4dysoaov3ra3jxsnoanyfyg3d56ntuzljro77a2bpgbzo6nu",
"bafkreicdlambpulyaytsiffl2yra55ejhdcchpzlx3trutkoc4tinkiomq",
"bafkreia57yvsl5esloc7fsn7uiw5q6opkk477f7qgh2sd2mibl66dwgz4m",
"bafkreigpxggeedsw2y7rd5dqzhhf4qxq3hw3y5qqnmzgmbg5225z32ke6e",
"bafkreihnezodqrdgshpkx5mkkebiz472y6r3xjnhjtrea75td6jxobf7ha",
"bafkreiabrwr6bj62rwayp2nvaa7welt24h3rfrsiilj6f6qav4ryjceb4q",
"bafkreiddvsn24iswrmxt3ceo7pngsvm44qzzknqto2hz4meytsbqw2q2yy",
"bafkreibu53ggwhoojqkqws3l6nampmzxyczkymw5ozfz6q4t7tpwimha4y",
"bafkreigwpa25qyx7f23v7t2nbdzywfigwp324dez2kvfrwyibeckl7kmry",
"bafkreidjlqycv7hkvn6zmsnwbjy7l563pya2fwtnj5mmiqzosjzyuvv7ay",
"bafkreibphjjkaarzd6kknwwmjtooccup7p3wyuvahmaemcyfjnbdbjci24",
"bafkreie3unp25d6yx7yvi7bohox2mftpq5rirhl444ylep5ivijovybs5u",
"bafkreifwh5ih76ed44cy545vyjovzre2esgk7a6m2njeb2qo5ofzus6q34",
"bafkreie3h3ltvvnokylzyzcpultd7a5ba5ldp4ui4ejlhr7lbucklj4zfu",
"bafkreiho2ufocna6dgavys6w3hzjudcppni7fnmo5pdes3cn3m7ndiu3b4",
"bafkreigdwveaxxfl4sfdnyedx4nnnfv7fzspjmmr3j4eozjfv7tjsovwma",
"bafkreidfixu2x5svom4aivbzbwyszrt7etpy7vm4deiepxgfyzshzn2ypi",
"bafkreialq7tz66rwqift3hwfhs7mkpjraqp24lk4kk2amlnh535zzkizzy",
"bafkreieay36cd2bsrn2tipb4zijvkylnfj7dinsaz342gnope7wsrrypjq",
"bafkreieo6nbwxyahaafswfbe4sahqby3h7ru2hfitzru6iqyxqgch7nrzq",
"bafkreicsv6fe4ykonns6hxctcjht7bqx5646cbpgbsug4xr6zg5rbthdj4",
"bafkreihsgdzvuirts3jt3g26lto73qqu4bg7n4qu72dgmkujjkenee7e7a",
"bafkreigkjwzzhv4cndw3ehsmsbmixzrxxvrpqj2e2yemxnnlwkew5f6gs4",
"bafkreic5k7u2m4g3yufqpin7ofnb7hgl5vdtmto36l33bw6sjw5hktmo5a",
"bafkreihxcdefq5k4vomblxkuj75d3b3ixasxvhuobag4whkrwyahfyfidq",
"bafkreicjwz7p6dpvcqs7ordhzwslabcwuj3y3hehk4pl63jktebjmncjfy",
"bafkreiakfuy3pabipys3ese6uerduczphy5rdkccguhyhsgyprmn7qz3ke",
"bafkreialjw6gr3smsmhmrvcdvlsxxvgroyubz7fk2wrvpcrmomx7pdnjoe",
"bafkreieqchumy7zibxq4mqppdqcdvfawq6ot7dxpbz3v5fue2bwyp5ivsm",
"bafkreicev7nx7s75yqv2jpttw4rrukztwtr4kubxrs3wv3v4qlkz4nq4uy",
"bafkreid2itljfobnxpvjfxnsas2fqbly5dyn7tkogvcojjxmb7muqiejta",
"bafkreibmiuznmb5lk7gsg6376b4z6orbn2b535u6wnimiq5hwe5scref6u",
"bafkreigxvddcurbaxgubrenqeahen47dktm4om535kaedeqenx7p6zodty",
"bafkreibtwpwhksgskwqshwuqehwfm772pu7rfxjcxpijpu5ikh2cwvczvq",
"bafkreic6j5qpgw326wdt6wyaf6efmbzzcw4rl5zfjiken3uxhu4s65hc2e",
"bafkreibzl22el47bco2hi6wj6zovosteowcdkzifegbg3xncdhd3d3pjnu",
"bafkreiew3gjv2dgldfzw5kfsginkvqz5rzktd5d4n6a2fnmuqjjk7hhcim",
"bafkreigbjzymbt3fmlmfta5oror25swedugp2drdvsjb3juahn6e33r6l4",
"bafkreicpzyumn7fo7negxdwb3anljwf2lqyseqeh7yogcoiyi75kfbtqky",
"bafkreihsznkosxzsgfkutuuzhh442k7esjduylhda5ausfbautruuazzmm",
"bafkreidbg24dnbt5to5vl6m5ektfwstwhp2djhsllf5mtciizlgg4lse6y",
"bafkreidefsxxb5i4nvdblya2mh7h4uo47dwuthb5jqmartgg4svwrvx2xe",
"bafkreic3qsb5mn22xy46gkg3whiqhvb2lqjmucbquiq27fyf76b7gpf3kq",
"bafkreiaej6mkm6jjixeqtheomqtbpc4xp3yrtp66vnmcywxler5qlgidw4",
"bafkreidhgkhkuwp5qqxzdmga7uh52qzeveu53zt4a2ahoauur6gaorf3sq",
"bafkreibbw4oyakigmurscj3aknyq4tq4b43jjk2wsoszo4672shsog4ssu",
"bafkreibbhcuhxye2ga3yblf4vmxsq4n3aofxckbyl66axugczb3e6dansu",
"bafkreibxvv6oipwxyaejwvf4vnftsd6n3bf6ixnvubyus4q5nqud4plcve",
"bafkreiahwdvpwtzcn2t45rswol5gka42yd2zkn37tn4mscq7mesuwngqyq",
"bafkreig3mw4xebzxvrj7w5yvkg6o5a55tf2nlenbpruf7oyo3gauqjhtim",
"bafkreihkaovv3fj2usy3kkzp4hspkisaqymki56pljvqm7yrv2ijta3pbq",
"bafkreicytcw572hqzksn3zrdut22xo7wjxkf4ovjijokhpkx6vnc3nax7i",
"bafkreidsfwztyha6q7i5temqm44mlhslcxerjhasj2kdfqhkssl5yfrgnu",
"bafkreibsvhu3jxeyohswwic7u3xtzwwzbgssqrmmwzyj2fwhnykwpuu7eu",
"bafkreibexexusac5lrtzmk26f4gc7pg2hzdf4upmd7ks37rteazol76ccy",
"bafkreiguleybtirhrwdfp3bmmkm7xwq63so3waxgbwyh277uh62dbh55n4",
"bafkreig7bdme4w26it2vhpdu2ahxbtl2svul5i3h5xhlpbdrxnmrnomqze",
"bafkreicjehn5krr3lcnyl65eyh3njrfw5atepdzfmjaga44fmangdv5t6q"
];
require(tokenId < 100, "Enter a tokenId from 0 to 99. Only 100 tulips.");
if (tokenId >= latestNewTulipForSale) {
return string(abi.encodePacked(_baseURI(), bulbURI));
} else {
return string(abi.encodePacked(_baseURI(), tulipURIs[tokenId]));
}
}
function _beforeTokenTransfer(
address,
address,
uint256 tokenId
) internal override {
// unlist tulip
tulips[tokenId].listingTime = 0;
// emit event
emit TulipNotForSale(tokenId, msg.sender);
}
// ETHERROCK
function getTulipInfo(uint256 tulipNumber)
public
view
returns (
address owner,
uint256 listingTime,
uint256 price,
uint256 timesSold
)
{
return (
ERC721.ownerOf(tulipNumber),
tulips[tulipNumber].listingTime,
currentPrice(tulipNumber),
tulips[tulipNumber].timesSold
);
}
function buyTulip(uint256 tulipNumber) public payable {
// check sellable
require(tulips[tulipNumber].listingTime != 0);
require(tulipNumber < 100, "Enter a tokenId from 0 to 99. Only 100 tulips.");
// check for sufficient payment
require(msg.value >= currentPrice(tulipNumber));
// unlist and update metadata
tulips[tulipNumber].listingTime = 0;
tulips[tulipNumber].timesSold++;
// swap ownership for payment
if (tulipNumber >= latestNewTulipForSale) {
// if new, _mint()
uint256 _latestNewTulipForSale = latestNewTulipForSale;
// update auction
if (latestNewTulipForSale < 99) {
latestNewTulipForSale++;
tulips[latestNewTulipForSale].listingTime = block.timestamp;
} else {
latestNewTulipForSale++;
}
// mint and transfer payment
ERC721._mint(msg.sender, _latestNewTulipForSale);
payable(feeRecipient).transfer(msg.value);
} else {
// if old, _transfer()
address seller = ERC721.ownerOf(tulipNumber);
ERC721._transfer(seller, msg.sender, tulipNumber);
payable(seller).transfer(msg.value);
}
// emit event
emit TulipSold(tulipNumber, msg.sender, msg.value);
}
function sellTulip(uint256 tulipNumber, uint256 price) public {
require(msg.sender == ERC721.ownerOf(tulipNumber));
require(price > 0);
tulips[tulipNumber].price = price;
tulips[tulipNumber].listingTime = block.timestamp;
// emit event
emit TulipForSale(tulipNumber, msg.sender, price);
}
function dontSellTulip(uint256 tulipNumber) public {
require(msg.sender == ERC721.ownerOf(tulipNumber));
tulips[tulipNumber].listingTime = 0;
// emit event
emit TulipNotForSale(tulipNumber, msg.sender);
}
function giftTulip(uint256 tulipNumber, address receiver) public {
ERC721.transferFrom(msg.sender, receiver, tulipNumber);
}
} | // This is a revised version of the revised version of the original EtherRock contract 0x41f28833Be34e6EDe3c58D1f597bef429861c4E2 with all the rocks removed and rock properties replaced by tulips.
// The original contract at 0x41f28833Be34e6EDe3c58D1f597bef429861c4E2 had a simple mistake in the buyRock() function where it would mint a rock and not a tulip. The line:
// require(rocks[rockNumber].currentlyForSale == true);
// Had to check for the existance of a tulip, as follows:
// require(tulips[tulipNumber].currentlyForSale == true);
// Therefore in the original contract, anyone could buy anyone elses rock whereas they should have been buying a tulip (regardless of whether the owner chose to sell it or not) | LineComment | currentPrice | function currentPrice(uint256 tulipNumber) public view returns (uint256 price) {
if (tulipNumber == latestNewTulipForSale) {
// if currently in auction
uint256 initialPrice = 1000 ether;
uint256 decayPeriod = 1 days;
// price = initial_price - initial_price * (current_time - start_time) / decay_period
uint256 elapsedTime = block.timestamp - tulips[tulipNumber].listingTime;
if (elapsedTime >= decayPeriod) return 0;
return initialPrice - ((initialPrice * elapsedTime) / decayPeriod);
} else {
// if not in auction
return tulips[tulipNumber].price;
}
}
| // Dutch-ish Auction | LineComment | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
925,
1618
]
} | 11,164 |
||
TulipFloorBidding | contracts/EtherTulip.sol | 0x40ab332dd48f35ebd227708ef381c946c4959eb6 | Solidity | EtherTulip | contract EtherTulip is ERC721("EtherTulip", unicode"🌷") {
struct Tulip {
uint256 listingTime;
uint256 price;
uint256 timesSold;
}
mapping(uint256 => Tulip) public tulips;
uint256 public latestNewTulipForSale;
address public immutable feeRecipient;
event TulipForSale(uint256 tulipNumber, address owner, uint256 price);
event TulipNotForSale(uint256 tulipNumber, address owner);
event TulipSold(uint256 tulipNumber, address buyer, uint256 price);
constructor(address _feeRecipient) {
// set fee recipient
feeRecipient = _feeRecipient;
// mint founder tulip to yours and only
ERC721._mint(address(0x777B0884f97Fd361c55e472530272Be61cEb87c8), 0);
// initialize auction for second tulip
latestNewTulipForSale = 1;
tulips[latestNewTulipForSale].listingTime = block.timestamp;
}
// Dutch-ish Auction
function currentPrice(uint256 tulipNumber) public view returns (uint256 price) {
if (tulipNumber == latestNewTulipForSale) {
// if currently in auction
uint256 initialPrice = 1000 ether;
uint256 decayPeriod = 1 days;
// price = initial_price - initial_price * (current_time - start_time) / decay_period
uint256 elapsedTime = block.timestamp - tulips[tulipNumber].listingTime;
if (elapsedTime >= decayPeriod) return 0;
return initialPrice - ((initialPrice * elapsedTime) / decayPeriod);
} else {
// if not in auction
return tulips[tulipNumber].price;
}
}
// ERC721
function _baseURI() internal pure override returns (string memory) {
return "ipfs://";
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
string memory bulbURI = "bafkreiamkokggzkchkosx5jvz6fduzwcn7qugkp7pytmk327sblrtwa4ze";
string[100] memory tulipURIs = [
"bafkreiajlq3nd3nc7xu245eqwnoqkh4fz25rdkinw7wkjtqp54xcbxdski",
"bafkreickj5f3dw6abk4ezj6vvephroacnizpt474jxjffccklci4bm7ulu",
"bafkreid3ckzlcv3p6zh3o3cwbryno3keqvzyagptnxtoer3awuvyeydz4u",
"bafkreid43dy6zwtnvwo6skonl4tcechlhnu7rihp2gnvoaydpxn3qw6yva",
"bafkreicnjnnu6w3crbzxkoa2g625avmnecrh4ptmuvj2q5izygeqhttjny",
"bafkreiaefcjmmploftqi6ao3dzrpjttnrhay2hqit5pxtzpwkismviwi7e",
"bafkreid2jrk7rquxayxdfvyg3w447wqssoutoybqeihuunmau4n5ourj4i",
"bafkreicvpenpqezcdehpcd2snsgj4ysl2la44fzqdolblr6evpps3uujcm",
"bafkreihuxku32udn2eolrdivdugr2dd5sot2u7cvth3qpsjoqbkllbwkgy",
"bafkreidumlyzcwbuaajaeeycq6e6y2zcr4jwq2amy35nsh7laphiecbyvi",
"bafkreigjkkhwb3rtdgvbhjc6aoarrlqmyfe7f4d67fvtxprqns3r5zu6jm",
"bafkreigmgqiafi4obtmtzzsocylrfcctjtemm3tdvecr3lobo6sqz73o3u",
"bafkreig5b6rx3mdxwyrtnumyehvuetzrs3dwkxv76wtqhfayammh2hlsve",
"bafkreicvhumzmjl7bo4uqhngwxfpk6upry4waxm3csk7wgkkyzjejgcwai",
"bafkreiehn3tovb6wa2nt6nsouavmy6vrijc4z775hk4hjzdn7b5y5lkiya",
"bafkreid6lxzktumy535tvzedks3acaqzrqirim4migkbxrp5erx5g6mfeu",
"bafkreihk3mimxxqimwkowm2arpfaewz7m5o76wcvw4acyixhtun673az34",
"bafkreidrrmeujlvad7oigztu45yeqxwcb6wpo464vwxqst4qo3itwk6ld4",
"bafkreihl6hl2ufborow5cfiypdtkk2segp3vxfetupapsjnjvzwxlq2che",
"bafkreidnv2t75e3kx6ugajs23l4736assxkzrggsocz2dvygsjlvhvntza",
"bafkreih2hhoeruntbfy4ufngko3wbdp4m6gz7otu3hntuvntlflyehkejq",
"bafkreieiqmc2t62t2pgabenfkeiclb4gsifcwgqvmkcwqc7lkaxm4vqvai",
"bafkreieqi56ie7iyl4rne2r7ypnvrbcpvxxqp346c74smgd3vypgspdwdi",
"bafkreidfw4bmdl3rcoehnak43beoeoucbbvtkxlagisvnuchug4foprhpq",
"bafkreiasg674cri4woi2nmf2be27i24gdegxhc5hgahpygd7vqcrqvz4va",
"bafkreidn3ocz3m6lzgu7whiooq74mtczbget5fie7dldzwhafdkty5yje4",
"bafkreieg474qoeg5mykld7dpego4oy4tvjorlgtpjacw3cjrl7oogsfs6a",
"bafkreiclbj3ujgxgh5i3plai5t24p7g2aavfzahu2gxq4mavena5ojxfsm",
"bafkreia2vekumcnyswh2w62htqu7vedtksepokixpqn4qwzxhefj2bdniq",
"bafkreia5456ribmisd555cwt6vzu57oqqkonugozywjuozsoxlo7ffoqxi",
"bafkreiekctvro262pk4uz67jpqivxtniebqk3gyfqkclw2vqy3m3iocw6e",
"bafkreigtxjoh4rx62uzlx4t23txqk3owvn3ckhy766mjiwgvy3fny2ozza",
"bafkreifui4jzaffl74zakibwmt2js2w2qosm7yzgimecwvqpqxpz2psnmu",
"bafkreif7426cefprxiupxwggnkjbtht3f3uiaeci2qc3irlppuy7kqoenq",
"bafkreigdimqwjrkoklbfiigbkfpvmrniealdjr2bv52jb72sfbk6aqorqy",
"bafkreidy2eohxrecrk3si4coolxawlcdmqrvhskhkal4d6bvxjfmds2m24",
"bafkreie3qfepdl4pkse6uu3iqwfb2fqusfp3qsp2rh7ynvptps3bbnqzdm",
"bafkreih2hv3vjipj2kibpynrmulnnoxj5737cbeg2bjl42zc3bhcfdzf2u",
"bafkreiba3227uclzobdglmkvyz4b5da6gp3p3ehtfqznuprlgu3lt7j6nq",
"bafkreiakbrgj7y2hzb7dhrpub6c6i72i3cp6ygsrof55t5ueb7wtg33bae",
"bafkreig5x3r3dqllt2ndhxpahni5fjeeo2obq4ffls4hkbi7a2cfqtappi",
"bafkreihfiplwjo4rdszuhnvjynx7iesij3borjd3rf5onlfgkwlqqjpbou",
"bafkreicpnd4dysoaov3ra3jxsnoanyfyg3d56ntuzljro77a2bpgbzo6nu",
"bafkreicdlambpulyaytsiffl2yra55ejhdcchpzlx3trutkoc4tinkiomq",
"bafkreia57yvsl5esloc7fsn7uiw5q6opkk477f7qgh2sd2mibl66dwgz4m",
"bafkreigpxggeedsw2y7rd5dqzhhf4qxq3hw3y5qqnmzgmbg5225z32ke6e",
"bafkreihnezodqrdgshpkx5mkkebiz472y6r3xjnhjtrea75td6jxobf7ha",
"bafkreiabrwr6bj62rwayp2nvaa7welt24h3rfrsiilj6f6qav4ryjceb4q",
"bafkreiddvsn24iswrmxt3ceo7pngsvm44qzzknqto2hz4meytsbqw2q2yy",
"bafkreibu53ggwhoojqkqws3l6nampmzxyczkymw5ozfz6q4t7tpwimha4y",
"bafkreigwpa25qyx7f23v7t2nbdzywfigwp324dez2kvfrwyibeckl7kmry",
"bafkreidjlqycv7hkvn6zmsnwbjy7l563pya2fwtnj5mmiqzosjzyuvv7ay",
"bafkreibphjjkaarzd6kknwwmjtooccup7p3wyuvahmaemcyfjnbdbjci24",
"bafkreie3unp25d6yx7yvi7bohox2mftpq5rirhl444ylep5ivijovybs5u",
"bafkreifwh5ih76ed44cy545vyjovzre2esgk7a6m2njeb2qo5ofzus6q34",
"bafkreie3h3ltvvnokylzyzcpultd7a5ba5ldp4ui4ejlhr7lbucklj4zfu",
"bafkreiho2ufocna6dgavys6w3hzjudcppni7fnmo5pdes3cn3m7ndiu3b4",
"bafkreigdwveaxxfl4sfdnyedx4nnnfv7fzspjmmr3j4eozjfv7tjsovwma",
"bafkreidfixu2x5svom4aivbzbwyszrt7etpy7vm4deiepxgfyzshzn2ypi",
"bafkreialq7tz66rwqift3hwfhs7mkpjraqp24lk4kk2amlnh535zzkizzy",
"bafkreieay36cd2bsrn2tipb4zijvkylnfj7dinsaz342gnope7wsrrypjq",
"bafkreieo6nbwxyahaafswfbe4sahqby3h7ru2hfitzru6iqyxqgch7nrzq",
"bafkreicsv6fe4ykonns6hxctcjht7bqx5646cbpgbsug4xr6zg5rbthdj4",
"bafkreihsgdzvuirts3jt3g26lto73qqu4bg7n4qu72dgmkujjkenee7e7a",
"bafkreigkjwzzhv4cndw3ehsmsbmixzrxxvrpqj2e2yemxnnlwkew5f6gs4",
"bafkreic5k7u2m4g3yufqpin7ofnb7hgl5vdtmto36l33bw6sjw5hktmo5a",
"bafkreihxcdefq5k4vomblxkuj75d3b3ixasxvhuobag4whkrwyahfyfidq",
"bafkreicjwz7p6dpvcqs7ordhzwslabcwuj3y3hehk4pl63jktebjmncjfy",
"bafkreiakfuy3pabipys3ese6uerduczphy5rdkccguhyhsgyprmn7qz3ke",
"bafkreialjw6gr3smsmhmrvcdvlsxxvgroyubz7fk2wrvpcrmomx7pdnjoe",
"bafkreieqchumy7zibxq4mqppdqcdvfawq6ot7dxpbz3v5fue2bwyp5ivsm",
"bafkreicev7nx7s75yqv2jpttw4rrukztwtr4kubxrs3wv3v4qlkz4nq4uy",
"bafkreid2itljfobnxpvjfxnsas2fqbly5dyn7tkogvcojjxmb7muqiejta",
"bafkreibmiuznmb5lk7gsg6376b4z6orbn2b535u6wnimiq5hwe5scref6u",
"bafkreigxvddcurbaxgubrenqeahen47dktm4om535kaedeqenx7p6zodty",
"bafkreibtwpwhksgskwqshwuqehwfm772pu7rfxjcxpijpu5ikh2cwvczvq",
"bafkreic6j5qpgw326wdt6wyaf6efmbzzcw4rl5zfjiken3uxhu4s65hc2e",
"bafkreibzl22el47bco2hi6wj6zovosteowcdkzifegbg3xncdhd3d3pjnu",
"bafkreiew3gjv2dgldfzw5kfsginkvqz5rzktd5d4n6a2fnmuqjjk7hhcim",
"bafkreigbjzymbt3fmlmfta5oror25swedugp2drdvsjb3juahn6e33r6l4",
"bafkreicpzyumn7fo7negxdwb3anljwf2lqyseqeh7yogcoiyi75kfbtqky",
"bafkreihsznkosxzsgfkutuuzhh442k7esjduylhda5ausfbautruuazzmm",
"bafkreidbg24dnbt5to5vl6m5ektfwstwhp2djhsllf5mtciizlgg4lse6y",
"bafkreidefsxxb5i4nvdblya2mh7h4uo47dwuthb5jqmartgg4svwrvx2xe",
"bafkreic3qsb5mn22xy46gkg3whiqhvb2lqjmucbquiq27fyf76b7gpf3kq",
"bafkreiaej6mkm6jjixeqtheomqtbpc4xp3yrtp66vnmcywxler5qlgidw4",
"bafkreidhgkhkuwp5qqxzdmga7uh52qzeveu53zt4a2ahoauur6gaorf3sq",
"bafkreibbw4oyakigmurscj3aknyq4tq4b43jjk2wsoszo4672shsog4ssu",
"bafkreibbhcuhxye2ga3yblf4vmxsq4n3aofxckbyl66axugczb3e6dansu",
"bafkreibxvv6oipwxyaejwvf4vnftsd6n3bf6ixnvubyus4q5nqud4plcve",
"bafkreiahwdvpwtzcn2t45rswol5gka42yd2zkn37tn4mscq7mesuwngqyq",
"bafkreig3mw4xebzxvrj7w5yvkg6o5a55tf2nlenbpruf7oyo3gauqjhtim",
"bafkreihkaovv3fj2usy3kkzp4hspkisaqymki56pljvqm7yrv2ijta3pbq",
"bafkreicytcw572hqzksn3zrdut22xo7wjxkf4ovjijokhpkx6vnc3nax7i",
"bafkreidsfwztyha6q7i5temqm44mlhslcxerjhasj2kdfqhkssl5yfrgnu",
"bafkreibsvhu3jxeyohswwic7u3xtzwwzbgssqrmmwzyj2fwhnykwpuu7eu",
"bafkreibexexusac5lrtzmk26f4gc7pg2hzdf4upmd7ks37rteazol76ccy",
"bafkreiguleybtirhrwdfp3bmmkm7xwq63so3waxgbwyh277uh62dbh55n4",
"bafkreig7bdme4w26it2vhpdu2ahxbtl2svul5i3h5xhlpbdrxnmrnomqze",
"bafkreicjehn5krr3lcnyl65eyh3njrfw5atepdzfmjaga44fmangdv5t6q"
];
require(tokenId < 100, "Enter a tokenId from 0 to 99. Only 100 tulips.");
if (tokenId >= latestNewTulipForSale) {
return string(abi.encodePacked(_baseURI(), bulbURI));
} else {
return string(abi.encodePacked(_baseURI(), tulipURIs[tokenId]));
}
}
function _beforeTokenTransfer(
address,
address,
uint256 tokenId
) internal override {
// unlist tulip
tulips[tokenId].listingTime = 0;
// emit event
emit TulipNotForSale(tokenId, msg.sender);
}
// ETHERROCK
function getTulipInfo(uint256 tulipNumber)
public
view
returns (
address owner,
uint256 listingTime,
uint256 price,
uint256 timesSold
)
{
return (
ERC721.ownerOf(tulipNumber),
tulips[tulipNumber].listingTime,
currentPrice(tulipNumber),
tulips[tulipNumber].timesSold
);
}
function buyTulip(uint256 tulipNumber) public payable {
// check sellable
require(tulips[tulipNumber].listingTime != 0);
require(tulipNumber < 100, "Enter a tokenId from 0 to 99. Only 100 tulips.");
// check for sufficient payment
require(msg.value >= currentPrice(tulipNumber));
// unlist and update metadata
tulips[tulipNumber].listingTime = 0;
tulips[tulipNumber].timesSold++;
// swap ownership for payment
if (tulipNumber >= latestNewTulipForSale) {
// if new, _mint()
uint256 _latestNewTulipForSale = latestNewTulipForSale;
// update auction
if (latestNewTulipForSale < 99) {
latestNewTulipForSale++;
tulips[latestNewTulipForSale].listingTime = block.timestamp;
} else {
latestNewTulipForSale++;
}
// mint and transfer payment
ERC721._mint(msg.sender, _latestNewTulipForSale);
payable(feeRecipient).transfer(msg.value);
} else {
// if old, _transfer()
address seller = ERC721.ownerOf(tulipNumber);
ERC721._transfer(seller, msg.sender, tulipNumber);
payable(seller).transfer(msg.value);
}
// emit event
emit TulipSold(tulipNumber, msg.sender, msg.value);
}
function sellTulip(uint256 tulipNumber, uint256 price) public {
require(msg.sender == ERC721.ownerOf(tulipNumber));
require(price > 0);
tulips[tulipNumber].price = price;
tulips[tulipNumber].listingTime = block.timestamp;
// emit event
emit TulipForSale(tulipNumber, msg.sender, price);
}
function dontSellTulip(uint256 tulipNumber) public {
require(msg.sender == ERC721.ownerOf(tulipNumber));
tulips[tulipNumber].listingTime = 0;
// emit event
emit TulipNotForSale(tulipNumber, msg.sender);
}
function giftTulip(uint256 tulipNumber, address receiver) public {
ERC721.transferFrom(msg.sender, receiver, tulipNumber);
}
} | // This is a revised version of the revised version of the original EtherRock contract 0x41f28833Be34e6EDe3c58D1f597bef429861c4E2 with all the rocks removed and rock properties replaced by tulips.
// The original contract at 0x41f28833Be34e6EDe3c58D1f597bef429861c4E2 had a simple mistake in the buyRock() function where it would mint a rock and not a tulip. The line:
// require(rocks[rockNumber].currentlyForSale == true);
// Had to check for the existance of a tulip, as follows:
// require(tulips[tulipNumber].currentlyForSale == true);
// Therefore in the original contract, anyone could buy anyone elses rock whereas they should have been buying a tulip (regardless of whether the owner chose to sell it or not) | LineComment | _baseURI | function _baseURI() internal pure override returns (string memory) {
return "ipfs://";
}
| // ERC721 | LineComment | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
1635,
1739
]
} | 11,165 |
||
TulipFloorBidding | contracts/EtherTulip.sol | 0x40ab332dd48f35ebd227708ef381c946c4959eb6 | Solidity | EtherTulip | contract EtherTulip is ERC721("EtherTulip", unicode"🌷") {
struct Tulip {
uint256 listingTime;
uint256 price;
uint256 timesSold;
}
mapping(uint256 => Tulip) public tulips;
uint256 public latestNewTulipForSale;
address public immutable feeRecipient;
event TulipForSale(uint256 tulipNumber, address owner, uint256 price);
event TulipNotForSale(uint256 tulipNumber, address owner);
event TulipSold(uint256 tulipNumber, address buyer, uint256 price);
constructor(address _feeRecipient) {
// set fee recipient
feeRecipient = _feeRecipient;
// mint founder tulip to yours and only
ERC721._mint(address(0x777B0884f97Fd361c55e472530272Be61cEb87c8), 0);
// initialize auction for second tulip
latestNewTulipForSale = 1;
tulips[latestNewTulipForSale].listingTime = block.timestamp;
}
// Dutch-ish Auction
function currentPrice(uint256 tulipNumber) public view returns (uint256 price) {
if (tulipNumber == latestNewTulipForSale) {
// if currently in auction
uint256 initialPrice = 1000 ether;
uint256 decayPeriod = 1 days;
// price = initial_price - initial_price * (current_time - start_time) / decay_period
uint256 elapsedTime = block.timestamp - tulips[tulipNumber].listingTime;
if (elapsedTime >= decayPeriod) return 0;
return initialPrice - ((initialPrice * elapsedTime) / decayPeriod);
} else {
// if not in auction
return tulips[tulipNumber].price;
}
}
// ERC721
function _baseURI() internal pure override returns (string memory) {
return "ipfs://";
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
string memory bulbURI = "bafkreiamkokggzkchkosx5jvz6fduzwcn7qugkp7pytmk327sblrtwa4ze";
string[100] memory tulipURIs = [
"bafkreiajlq3nd3nc7xu245eqwnoqkh4fz25rdkinw7wkjtqp54xcbxdski",
"bafkreickj5f3dw6abk4ezj6vvephroacnizpt474jxjffccklci4bm7ulu",
"bafkreid3ckzlcv3p6zh3o3cwbryno3keqvzyagptnxtoer3awuvyeydz4u",
"bafkreid43dy6zwtnvwo6skonl4tcechlhnu7rihp2gnvoaydpxn3qw6yva",
"bafkreicnjnnu6w3crbzxkoa2g625avmnecrh4ptmuvj2q5izygeqhttjny",
"bafkreiaefcjmmploftqi6ao3dzrpjttnrhay2hqit5pxtzpwkismviwi7e",
"bafkreid2jrk7rquxayxdfvyg3w447wqssoutoybqeihuunmau4n5ourj4i",
"bafkreicvpenpqezcdehpcd2snsgj4ysl2la44fzqdolblr6evpps3uujcm",
"bafkreihuxku32udn2eolrdivdugr2dd5sot2u7cvth3qpsjoqbkllbwkgy",
"bafkreidumlyzcwbuaajaeeycq6e6y2zcr4jwq2amy35nsh7laphiecbyvi",
"bafkreigjkkhwb3rtdgvbhjc6aoarrlqmyfe7f4d67fvtxprqns3r5zu6jm",
"bafkreigmgqiafi4obtmtzzsocylrfcctjtemm3tdvecr3lobo6sqz73o3u",
"bafkreig5b6rx3mdxwyrtnumyehvuetzrs3dwkxv76wtqhfayammh2hlsve",
"bafkreicvhumzmjl7bo4uqhngwxfpk6upry4waxm3csk7wgkkyzjejgcwai",
"bafkreiehn3tovb6wa2nt6nsouavmy6vrijc4z775hk4hjzdn7b5y5lkiya",
"bafkreid6lxzktumy535tvzedks3acaqzrqirim4migkbxrp5erx5g6mfeu",
"bafkreihk3mimxxqimwkowm2arpfaewz7m5o76wcvw4acyixhtun673az34",
"bafkreidrrmeujlvad7oigztu45yeqxwcb6wpo464vwxqst4qo3itwk6ld4",
"bafkreihl6hl2ufborow5cfiypdtkk2segp3vxfetupapsjnjvzwxlq2che",
"bafkreidnv2t75e3kx6ugajs23l4736assxkzrggsocz2dvygsjlvhvntza",
"bafkreih2hhoeruntbfy4ufngko3wbdp4m6gz7otu3hntuvntlflyehkejq",
"bafkreieiqmc2t62t2pgabenfkeiclb4gsifcwgqvmkcwqc7lkaxm4vqvai",
"bafkreieqi56ie7iyl4rne2r7ypnvrbcpvxxqp346c74smgd3vypgspdwdi",
"bafkreidfw4bmdl3rcoehnak43beoeoucbbvtkxlagisvnuchug4foprhpq",
"bafkreiasg674cri4woi2nmf2be27i24gdegxhc5hgahpygd7vqcrqvz4va",
"bafkreidn3ocz3m6lzgu7whiooq74mtczbget5fie7dldzwhafdkty5yje4",
"bafkreieg474qoeg5mykld7dpego4oy4tvjorlgtpjacw3cjrl7oogsfs6a",
"bafkreiclbj3ujgxgh5i3plai5t24p7g2aavfzahu2gxq4mavena5ojxfsm",
"bafkreia2vekumcnyswh2w62htqu7vedtksepokixpqn4qwzxhefj2bdniq",
"bafkreia5456ribmisd555cwt6vzu57oqqkonugozywjuozsoxlo7ffoqxi",
"bafkreiekctvro262pk4uz67jpqivxtniebqk3gyfqkclw2vqy3m3iocw6e",
"bafkreigtxjoh4rx62uzlx4t23txqk3owvn3ckhy766mjiwgvy3fny2ozza",
"bafkreifui4jzaffl74zakibwmt2js2w2qosm7yzgimecwvqpqxpz2psnmu",
"bafkreif7426cefprxiupxwggnkjbtht3f3uiaeci2qc3irlppuy7kqoenq",
"bafkreigdimqwjrkoklbfiigbkfpvmrniealdjr2bv52jb72sfbk6aqorqy",
"bafkreidy2eohxrecrk3si4coolxawlcdmqrvhskhkal4d6bvxjfmds2m24",
"bafkreie3qfepdl4pkse6uu3iqwfb2fqusfp3qsp2rh7ynvptps3bbnqzdm",
"bafkreih2hv3vjipj2kibpynrmulnnoxj5737cbeg2bjl42zc3bhcfdzf2u",
"bafkreiba3227uclzobdglmkvyz4b5da6gp3p3ehtfqznuprlgu3lt7j6nq",
"bafkreiakbrgj7y2hzb7dhrpub6c6i72i3cp6ygsrof55t5ueb7wtg33bae",
"bafkreig5x3r3dqllt2ndhxpahni5fjeeo2obq4ffls4hkbi7a2cfqtappi",
"bafkreihfiplwjo4rdszuhnvjynx7iesij3borjd3rf5onlfgkwlqqjpbou",
"bafkreicpnd4dysoaov3ra3jxsnoanyfyg3d56ntuzljro77a2bpgbzo6nu",
"bafkreicdlambpulyaytsiffl2yra55ejhdcchpzlx3trutkoc4tinkiomq",
"bafkreia57yvsl5esloc7fsn7uiw5q6opkk477f7qgh2sd2mibl66dwgz4m",
"bafkreigpxggeedsw2y7rd5dqzhhf4qxq3hw3y5qqnmzgmbg5225z32ke6e",
"bafkreihnezodqrdgshpkx5mkkebiz472y6r3xjnhjtrea75td6jxobf7ha",
"bafkreiabrwr6bj62rwayp2nvaa7welt24h3rfrsiilj6f6qav4ryjceb4q",
"bafkreiddvsn24iswrmxt3ceo7pngsvm44qzzknqto2hz4meytsbqw2q2yy",
"bafkreibu53ggwhoojqkqws3l6nampmzxyczkymw5ozfz6q4t7tpwimha4y",
"bafkreigwpa25qyx7f23v7t2nbdzywfigwp324dez2kvfrwyibeckl7kmry",
"bafkreidjlqycv7hkvn6zmsnwbjy7l563pya2fwtnj5mmiqzosjzyuvv7ay",
"bafkreibphjjkaarzd6kknwwmjtooccup7p3wyuvahmaemcyfjnbdbjci24",
"bafkreie3unp25d6yx7yvi7bohox2mftpq5rirhl444ylep5ivijovybs5u",
"bafkreifwh5ih76ed44cy545vyjovzre2esgk7a6m2njeb2qo5ofzus6q34",
"bafkreie3h3ltvvnokylzyzcpultd7a5ba5ldp4ui4ejlhr7lbucklj4zfu",
"bafkreiho2ufocna6dgavys6w3hzjudcppni7fnmo5pdes3cn3m7ndiu3b4",
"bafkreigdwveaxxfl4sfdnyedx4nnnfv7fzspjmmr3j4eozjfv7tjsovwma",
"bafkreidfixu2x5svom4aivbzbwyszrt7etpy7vm4deiepxgfyzshzn2ypi",
"bafkreialq7tz66rwqift3hwfhs7mkpjraqp24lk4kk2amlnh535zzkizzy",
"bafkreieay36cd2bsrn2tipb4zijvkylnfj7dinsaz342gnope7wsrrypjq",
"bafkreieo6nbwxyahaafswfbe4sahqby3h7ru2hfitzru6iqyxqgch7nrzq",
"bafkreicsv6fe4ykonns6hxctcjht7bqx5646cbpgbsug4xr6zg5rbthdj4",
"bafkreihsgdzvuirts3jt3g26lto73qqu4bg7n4qu72dgmkujjkenee7e7a",
"bafkreigkjwzzhv4cndw3ehsmsbmixzrxxvrpqj2e2yemxnnlwkew5f6gs4",
"bafkreic5k7u2m4g3yufqpin7ofnb7hgl5vdtmto36l33bw6sjw5hktmo5a",
"bafkreihxcdefq5k4vomblxkuj75d3b3ixasxvhuobag4whkrwyahfyfidq",
"bafkreicjwz7p6dpvcqs7ordhzwslabcwuj3y3hehk4pl63jktebjmncjfy",
"bafkreiakfuy3pabipys3ese6uerduczphy5rdkccguhyhsgyprmn7qz3ke",
"bafkreialjw6gr3smsmhmrvcdvlsxxvgroyubz7fk2wrvpcrmomx7pdnjoe",
"bafkreieqchumy7zibxq4mqppdqcdvfawq6ot7dxpbz3v5fue2bwyp5ivsm",
"bafkreicev7nx7s75yqv2jpttw4rrukztwtr4kubxrs3wv3v4qlkz4nq4uy",
"bafkreid2itljfobnxpvjfxnsas2fqbly5dyn7tkogvcojjxmb7muqiejta",
"bafkreibmiuznmb5lk7gsg6376b4z6orbn2b535u6wnimiq5hwe5scref6u",
"bafkreigxvddcurbaxgubrenqeahen47dktm4om535kaedeqenx7p6zodty",
"bafkreibtwpwhksgskwqshwuqehwfm772pu7rfxjcxpijpu5ikh2cwvczvq",
"bafkreic6j5qpgw326wdt6wyaf6efmbzzcw4rl5zfjiken3uxhu4s65hc2e",
"bafkreibzl22el47bco2hi6wj6zovosteowcdkzifegbg3xncdhd3d3pjnu",
"bafkreiew3gjv2dgldfzw5kfsginkvqz5rzktd5d4n6a2fnmuqjjk7hhcim",
"bafkreigbjzymbt3fmlmfta5oror25swedugp2drdvsjb3juahn6e33r6l4",
"bafkreicpzyumn7fo7negxdwb3anljwf2lqyseqeh7yogcoiyi75kfbtqky",
"bafkreihsznkosxzsgfkutuuzhh442k7esjduylhda5ausfbautruuazzmm",
"bafkreidbg24dnbt5to5vl6m5ektfwstwhp2djhsllf5mtciizlgg4lse6y",
"bafkreidefsxxb5i4nvdblya2mh7h4uo47dwuthb5jqmartgg4svwrvx2xe",
"bafkreic3qsb5mn22xy46gkg3whiqhvb2lqjmucbquiq27fyf76b7gpf3kq",
"bafkreiaej6mkm6jjixeqtheomqtbpc4xp3yrtp66vnmcywxler5qlgidw4",
"bafkreidhgkhkuwp5qqxzdmga7uh52qzeveu53zt4a2ahoauur6gaorf3sq",
"bafkreibbw4oyakigmurscj3aknyq4tq4b43jjk2wsoszo4672shsog4ssu",
"bafkreibbhcuhxye2ga3yblf4vmxsq4n3aofxckbyl66axugczb3e6dansu",
"bafkreibxvv6oipwxyaejwvf4vnftsd6n3bf6ixnvubyus4q5nqud4plcve",
"bafkreiahwdvpwtzcn2t45rswol5gka42yd2zkn37tn4mscq7mesuwngqyq",
"bafkreig3mw4xebzxvrj7w5yvkg6o5a55tf2nlenbpruf7oyo3gauqjhtim",
"bafkreihkaovv3fj2usy3kkzp4hspkisaqymki56pljvqm7yrv2ijta3pbq",
"bafkreicytcw572hqzksn3zrdut22xo7wjxkf4ovjijokhpkx6vnc3nax7i",
"bafkreidsfwztyha6q7i5temqm44mlhslcxerjhasj2kdfqhkssl5yfrgnu",
"bafkreibsvhu3jxeyohswwic7u3xtzwwzbgssqrmmwzyj2fwhnykwpuu7eu",
"bafkreibexexusac5lrtzmk26f4gc7pg2hzdf4upmd7ks37rteazol76ccy",
"bafkreiguleybtirhrwdfp3bmmkm7xwq63so3waxgbwyh277uh62dbh55n4",
"bafkreig7bdme4w26it2vhpdu2ahxbtl2svul5i3h5xhlpbdrxnmrnomqze",
"bafkreicjehn5krr3lcnyl65eyh3njrfw5atepdzfmjaga44fmangdv5t6q"
];
require(tokenId < 100, "Enter a tokenId from 0 to 99. Only 100 tulips.");
if (tokenId >= latestNewTulipForSale) {
return string(abi.encodePacked(_baseURI(), bulbURI));
} else {
return string(abi.encodePacked(_baseURI(), tulipURIs[tokenId]));
}
}
function _beforeTokenTransfer(
address,
address,
uint256 tokenId
) internal override {
// unlist tulip
tulips[tokenId].listingTime = 0;
// emit event
emit TulipNotForSale(tokenId, msg.sender);
}
// ETHERROCK
function getTulipInfo(uint256 tulipNumber)
public
view
returns (
address owner,
uint256 listingTime,
uint256 price,
uint256 timesSold
)
{
return (
ERC721.ownerOf(tulipNumber),
tulips[tulipNumber].listingTime,
currentPrice(tulipNumber),
tulips[tulipNumber].timesSold
);
}
function buyTulip(uint256 tulipNumber) public payable {
// check sellable
require(tulips[tulipNumber].listingTime != 0);
require(tulipNumber < 100, "Enter a tokenId from 0 to 99. Only 100 tulips.");
// check for sufficient payment
require(msg.value >= currentPrice(tulipNumber));
// unlist and update metadata
tulips[tulipNumber].listingTime = 0;
tulips[tulipNumber].timesSold++;
// swap ownership for payment
if (tulipNumber >= latestNewTulipForSale) {
// if new, _mint()
uint256 _latestNewTulipForSale = latestNewTulipForSale;
// update auction
if (latestNewTulipForSale < 99) {
latestNewTulipForSale++;
tulips[latestNewTulipForSale].listingTime = block.timestamp;
} else {
latestNewTulipForSale++;
}
// mint and transfer payment
ERC721._mint(msg.sender, _latestNewTulipForSale);
payable(feeRecipient).transfer(msg.value);
} else {
// if old, _transfer()
address seller = ERC721.ownerOf(tulipNumber);
ERC721._transfer(seller, msg.sender, tulipNumber);
payable(seller).transfer(msg.value);
}
// emit event
emit TulipSold(tulipNumber, msg.sender, msg.value);
}
function sellTulip(uint256 tulipNumber, uint256 price) public {
require(msg.sender == ERC721.ownerOf(tulipNumber));
require(price > 0);
tulips[tulipNumber].price = price;
tulips[tulipNumber].listingTime = block.timestamp;
// emit event
emit TulipForSale(tulipNumber, msg.sender, price);
}
function dontSellTulip(uint256 tulipNumber) public {
require(msg.sender == ERC721.ownerOf(tulipNumber));
tulips[tulipNumber].listingTime = 0;
// emit event
emit TulipNotForSale(tulipNumber, msg.sender);
}
function giftTulip(uint256 tulipNumber, address receiver) public {
ERC721.transferFrom(msg.sender, receiver, tulipNumber);
}
} | // This is a revised version of the revised version of the original EtherRock contract 0x41f28833Be34e6EDe3c58D1f597bef429861c4E2 with all the rocks removed and rock properties replaced by tulips.
// The original contract at 0x41f28833Be34e6EDe3c58D1f597bef429861c4E2 had a simple mistake in the buyRock() function where it would mint a rock and not a tulip. The line:
// require(rocks[rockNumber].currentlyForSale == true);
// Had to check for the existance of a tulip, as follows:
// require(tulips[tulipNumber].currentlyForSale == true);
// Therefore in the original contract, anyone could buy anyone elses rock whereas they should have been buying a tulip (regardless of whether the owner chose to sell it or not) | LineComment | getTulipInfo | function getTulipInfo(uint256 tulipNumber)
public
view
returns (
address owner,
uint256 listingTime,
uint256 price,
uint256 timesSold
)
{
return (
ERC721.ownerOf(tulipNumber),
tulips[tulipNumber].listingTime,
currentPrice(tulipNumber),
tulips[tulipNumber].timesSold
);
}
| // ETHERROCK | LineComment | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
10062,
10488
]
} | 11,166 |
||
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
92,
152
]
} | 11,167 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
233,
306
]
} | 11,168 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | 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.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
524,
606
]
} | 11,169 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | 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.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
879,
967
]
} | 11,170 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | 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.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
1618,
1697
]
} | 11,171 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | 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.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
2002,
2104
]
} | 11,172 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* 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).
*
* 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) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | tryAdd | function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
| /**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
157,
384
]
} | 11,173 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* 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).
*
* 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) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | trySub | function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
| /**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
528,
727
]
} | 11,174 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* 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).
*
* 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) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | tryMul | function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
| /**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
873,
1381
]
} | 11,175 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* 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).
*
* 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) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | tryDiv | function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
| /**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
1528,
1728
]
} | 11,176 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* 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).
*
* 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) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | tryMod | function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
| /**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
1885,
2085
]
} | 11,177 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* 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).
*
* 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) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
2318,
2421
]
} | 11,178 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* 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).
*
* 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) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
3193,
3296
]
} | 11,179 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* 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).
*
* 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) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
3758,
3969
]
} | 11,180 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* 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).
*
* 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) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
| /**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* 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).
*
* 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.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
4674,
4884
]
} | 11,181 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* 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).
*
* 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) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | mod | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
5528,
5738
]
} | 11,182 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | 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 on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | isContract | function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
| /**
* @dev 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.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
590,
1017
]
} | 11,183 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | 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 on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @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.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
1932,
2334
]
} | 11,184 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | 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 on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @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.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
3073,
3251
]
} | 11,185 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | 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 on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @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.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
3471,
3671
]
} | 11,186 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | 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 on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @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.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
4031,
4262
]
} | 11,187 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | 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 on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @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");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
4508,
5043
]
} | 11,188 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | 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 on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionStaticCall | function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
5218,
5422
]
} | 11,189 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | 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 on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionStaticCall | function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
5604,
6031
]
} | 11,190 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | 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 on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionDelegateCall | function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
6208,
6413
]
} | 11,191 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | 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 on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionDelegateCall | function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
6597,
7025
]
} | 11,192 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
_owner = _msgSender();
emit OwnershipTransferred(address(0), _owner);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | /**
* @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 virtual returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
450,
542
]
} | 11,193 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
_owner = _msgSender();
emit OwnershipTransferred(address(0), _owner);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | /**
* @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.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
1093,
1246
]
} | 11,194 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
_owner = _msgSender();
emit OwnershipTransferred(address(0), _owner);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | /**
* @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 | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
1393,
1642
]
} | 11,195 |
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | maruinu | contract maruinu is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
uint8 private _decimals = 9;
//
string private _name = "Maru Inu"; // name
string private _symbol = "$MARU"; // symbol
uint256 private _tTotal = 1000 * 10**9 * 10**uint256(_decimals);
// % to holders
uint256 public defaultTaxFee = 0;
uint256 public _taxFee = defaultTaxFee;
uint256 private _previousTaxFee = _taxFee;
// % to swap & send to marketing wallet
uint256 public defaultMarketingFee = 9;
uint256 public _marketingFee = defaultMarketingFee;
uint256 private _previousMarketingFee = _marketingFee;
uint256 public _marketingFee4Sellers = 9;
bool public feesOnSellersAndBuyers = true;
uint256 public _maxTxAmount = _tTotal.div(1).div(49);
uint256 public numTokensToExchangeForMarketing = _tTotal.div(100).div(100);
address payable public marketingWallet = payable(0xdbd6671f47A55bb810783114838C2a3c6de62b39);
//
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) public _isBlacklisted;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tFeeTotal;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwapAndSend;
bool public SwapAndSendEnabled = true;
event SwapAndSendEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwapAndSend = true;
_;
inSwapAndSend = false;
}
constructor () {
_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;
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 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 excludeFromFee(address account) public onlyOwner() {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner() {
_isExcludedFromFee[account] = false;
}
function removeAllFee() private {
if(_taxFee == 0 && _marketingFee == 0) return;
_previousTaxFee = _taxFee;
_previousMarketingFee = _marketingFee;
_taxFee = 0;
_marketingFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_marketingFee = _previousMarketingFee;
}
//to recieve ETH
receive() external payable {}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function addToBlackList(address[] calldata addresses) external onlyOwner {
for (uint256 i; i < addresses.length; ++i) {
_isBlacklisted[addresses[i]] = true;
}
}
function removeFromBlackList(address account) external onlyOwner {
_isBlacklisted[account] = false;
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tMarketing, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tMarketing = calculateMarketingFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing);
return (tTransferAmount, tFee, tMarketing);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tMarketing, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rMarketing = tMarketing.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rMarketing);
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 _takeMarketing(uint256 tMarketing) private {
uint256 currentRate = _getRate();
uint256 rMarketing = tMarketing.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rMarketing);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tMarketing);
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_taxFee).div(
10**2
);
}
function calculateMarketingFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_marketingFee).div(
10**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(amount > 0, "Transfer amount must be greater than zero");
require(!_isBlacklisted[from] && !_isBlacklisted[to], "This address is blacklisted");
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 + send lock?
// also, don't get caught in a circular sending event.
// also, don't swap & liquify if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
if (
overMinTokenBalance &&
!inSwapAndSend &&
from != uniswapV2Pair &&
SwapAndSendEnabled
) {
SwapAndSend(contractTokenBalance);
}
if(feesOnSellersAndBuyers) {
setFees(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]) {
takeFee = false;
}
_tokenTransfer(from,to,amount,takeFee);
}
function setFees(address recipient) private {
_taxFee = defaultTaxFee;
_marketingFee = defaultMarketingFee;
if (recipient == uniswapV2Pair) { // sell
_marketingFee = _marketingFee4Sellers;
}
}
function SwapAndSend(uint256 contractTokenBalance) private lockTheSwap {
// 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), contractTokenBalance);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
contractTokenBalance,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
marketingWallet.transfer(contractETHBalance);
}
}
//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 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_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 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_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 tMarketing) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _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);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function setDefaultMarketingFee(uint256 marketingFee) external onlyOwner() {
defaultMarketingFee = marketingFee;
}
function setMarketingFee4Sellers(uint256 marketingFee4Sellers) external onlyOwner() {
_marketingFee4Sellers = marketingFee4Sellers;
}
function setFeesOnSellersAndBuyers(bool _enabled) public onlyOwner() {
feesOnSellersAndBuyers = _enabled;
}
function setSwapAndSendEnabled(bool _enabled) public onlyOwner() {
SwapAndSendEnabled = _enabled;
emit SwapAndSendEnabledUpdated(_enabled);
}
function setnumTokensToExchangeForMarketing(uint256 _numTokensToExchangeForMarketing) public onlyOwner() {
numTokensToExchangeForMarketing = _numTokensToExchangeForMarketing;
}
function _setMarketingWallet(address payable wallet) external onlyOwner() {
marketingWallet = wallet;
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
_maxTxAmount = maxTxAmount;
}
} | //to recieve ETH | LineComment | v0.8.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
7100,
7134
]
} | 11,196 |
||||
maruinu | maruinu.sol | 0x7bf4581c5507f1df0e9587cdc18841e0ed4ee884 | Solidity | maruinu | contract maruinu is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
uint8 private _decimals = 9;
//
string private _name = "Maru Inu"; // name
string private _symbol = "$MARU"; // symbol
uint256 private _tTotal = 1000 * 10**9 * 10**uint256(_decimals);
// % to holders
uint256 public defaultTaxFee = 0;
uint256 public _taxFee = defaultTaxFee;
uint256 private _previousTaxFee = _taxFee;
// % to swap & send to marketing wallet
uint256 public defaultMarketingFee = 9;
uint256 public _marketingFee = defaultMarketingFee;
uint256 private _previousMarketingFee = _marketingFee;
uint256 public _marketingFee4Sellers = 9;
bool public feesOnSellersAndBuyers = true;
uint256 public _maxTxAmount = _tTotal.div(1).div(49);
uint256 public numTokensToExchangeForMarketing = _tTotal.div(100).div(100);
address payable public marketingWallet = payable(0xdbd6671f47A55bb810783114838C2a3c6de62b39);
//
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) public _isBlacklisted;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tFeeTotal;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwapAndSend;
bool public SwapAndSendEnabled = true;
event SwapAndSendEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwapAndSend = true;
_;
inSwapAndSend = false;
}
constructor () {
_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;
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 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 excludeFromFee(address account) public onlyOwner() {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner() {
_isExcludedFromFee[account] = false;
}
function removeAllFee() private {
if(_taxFee == 0 && _marketingFee == 0) return;
_previousTaxFee = _taxFee;
_previousMarketingFee = _marketingFee;
_taxFee = 0;
_marketingFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_marketingFee = _previousMarketingFee;
}
//to recieve ETH
receive() external payable {}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function addToBlackList(address[] calldata addresses) external onlyOwner {
for (uint256 i; i < addresses.length; ++i) {
_isBlacklisted[addresses[i]] = true;
}
}
function removeFromBlackList(address account) external onlyOwner {
_isBlacklisted[account] = false;
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tMarketing, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tMarketing = calculateMarketingFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing);
return (tTransferAmount, tFee, tMarketing);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tMarketing, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rMarketing = tMarketing.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rMarketing);
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 _takeMarketing(uint256 tMarketing) private {
uint256 currentRate = _getRate();
uint256 rMarketing = tMarketing.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rMarketing);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tMarketing);
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_taxFee).div(
10**2
);
}
function calculateMarketingFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_marketingFee).div(
10**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(amount > 0, "Transfer amount must be greater than zero");
require(!_isBlacklisted[from] && !_isBlacklisted[to], "This address is blacklisted");
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 + send lock?
// also, don't get caught in a circular sending event.
// also, don't swap & liquify if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
if (
overMinTokenBalance &&
!inSwapAndSend &&
from != uniswapV2Pair &&
SwapAndSendEnabled
) {
SwapAndSend(contractTokenBalance);
}
if(feesOnSellersAndBuyers) {
setFees(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]) {
takeFee = false;
}
_tokenTransfer(from,to,amount,takeFee);
}
function setFees(address recipient) private {
_taxFee = defaultTaxFee;
_marketingFee = defaultMarketingFee;
if (recipient == uniswapV2Pair) { // sell
_marketingFee = _marketingFee4Sellers;
}
}
function SwapAndSend(uint256 contractTokenBalance) private lockTheSwap {
// 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), contractTokenBalance);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
contractTokenBalance,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
marketingWallet.transfer(contractETHBalance);
}
}
//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 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_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 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_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 tMarketing) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _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);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function setDefaultMarketingFee(uint256 marketingFee) external onlyOwner() {
defaultMarketingFee = marketingFee;
}
function setMarketingFee4Sellers(uint256 marketingFee4Sellers) external onlyOwner() {
_marketingFee4Sellers = marketingFee4Sellers;
}
function setFeesOnSellersAndBuyers(bool _enabled) public onlyOwner() {
feesOnSellersAndBuyers = _enabled;
}
function setSwapAndSendEnabled(bool _enabled) public onlyOwner() {
SwapAndSendEnabled = _enabled;
emit SwapAndSendEnabledUpdated(_enabled);
}
function setnumTokensToExchangeForMarketing(uint256 _numTokensToExchangeForMarketing) public onlyOwner() {
numTokensToExchangeForMarketing = _numTokensToExchangeForMarketing;
}
function _setMarketingWallet(address payable wallet) external onlyOwner() {
marketingWallet = wallet;
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
_maxTxAmount = maxTxAmount;
}
} | _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.9+commit.e5eed63a | None | ipfs://a23930b8ccc2ecc6e8dcdb0daba89afd1da21e66d1c484edc1aa0b3e77f91cfd | {
"func_code_index": [
13642,
14465
]
} | 11,197 |
||
BSB_Locking_Development | BSB_Locking_Development.sol | 0x16933f45201c9db038fc573afaed02d79ca8d209 | Solidity | Ownable | contract Ownable {
address public owner ;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() {
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 transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {
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) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = 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.8.7+commit.e28d00a7 | BSD-3-Clause | ipfs://cb9d98819010829312628b5bebffdfa48219a57a0201b81be9e62c2a6420b4a8 | {
"func_code_index": [
634,
815
]
} | 11,198 |
CryptoverseBit | contracts/CryptoverseBit.sol | 0x66733bccdc2ea3019a0683c1e7435a30ccb79549 | Solidity | CryptoverseBit | contract CryptoverseBit is ERC1155, Ownable {
/**
* Emitted when prediction is submitted to the chain.
*/
event PredictionMinted(address indexed player, uint256 tokenId, string series, uint256 seriesNumber, string nickname,
uint64 lucky, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6);
/**
* Emitted when result is submitted to the chain.
*/
event ResultSet(address indexed operator, uint256 tokenId, string series, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6);
/**
* Emitted when series is set.
*/
event SeriesSet(address indexed operator, string series, uint256 limit, uint256 mintPrice);
/**
* Prediction structure.
*/
struct Prediction {
uint256 timestamp;
string series;
uint256 seriesNumber;
string nickname;
uint64 lucky;
uint64 predict_1;
uint64 predict_2;
uint64 predict_3;
uint64 predict_4;
uint64 predict_5;
uint64 predict_6;
}
/**
* Result structure.
*/
struct Result {
uint64 result_0;
uint64 result_1;
uint64 result_2;
uint64 result_3;
uint64 result_4;
uint64 result_5;
uint64 result_6;
}
/**
* Result with score structure.
*/
struct ScoredResult {
uint64 totalScore;
uint64 result_0;
uint64 result_1;
uint64 score_1;
uint64 result_2;
uint64 score_2;
uint64 result_3;
uint64 score_3;
uint64 result_4;
uint64 score_4;
uint64 result_5;
uint64 score_5;
uint64 result_6;
uint64 score_6;
}
/**
* Name for contract identification.
*/
string private _name;
/**
* Number of decimals.
*/
uint8 private _numDecimals;
/**
* Total number of tokens minted so far.
*/
uint256 private _numTokens;
/**
* Mapping from token ID to predictions.
*/
mapping(uint256 => Prediction) private _predictions;
/**
* Mapping from token ID to results.
*/
mapping(uint256 => Result) private _results;
/**
* Mapping from series to the maximum amounts that can be minted.
*/
mapping(string => uint256) private _seriesLimits;
/**
* Mapping from series to the mint prices.
*/
mapping(string => uint256) private _seriesMintPrices;
/**
* Mapping from series to the number of so far minted tokens.
*/
mapping(string => uint256) private _seriesMints;
/**
* Creates new instance.
*
* @param name_ contract name
* @param numDecimals_ number of decimals this contract operates with
*/
constructor(string memory name_, uint8 numDecimals_) ERC1155("") {
_name = name_;
_numDecimals = numDecimals_;
}
/**
* Returns the contract name.
*
* @return contract name
*/
function name() public view returns (string memory) {
return _name;
}
/**
* Returns the number of decimal places this contract work with.
*
* @return number of decimal points this contract work with
*/
function numDecimals() public view returns (uint8) {
return _numDecimals;
}
/**
* Sets uri base.
*
* @param uriBase uri base
*/
function setUriBase(string memory uriBase) public onlyOwner {
_setURI(uriBase);
}
/**
* Return uri.
*
* @param tokenId token id
* @return token url
*/
function uri(uint256 tokenId) public override view returns (string memory) {
return strConcat(
super.uri(tokenId),
Strings.toString(tokenId)
);
}
/**
* Sets series limit.
*
* @param series series name
* @param limit limit of the tokens that can be under this series
* @param mintPrice price to mint the token
*/
function setSeries(string memory series, uint256 limit, uint256 mintPrice) public onlyOwner {
require(bytes(series).length > bytes("").length, "series cannot be empty string");
_seriesLimits[series] = limit;
_seriesMintPrices[series] = mintPrice;
emit SeriesSet(msg.sender, series, limit, mintPrice);
}
/**
* Returns the series limit.
*
* @param series series name
* @return series limit
*/
function seriesLimit(string memory series) public view returns (uint256) {
return _seriesLimits[series];
}
/**
* Returns the series mint prices.
*
* @param series series name
* @return series mint price
*/
function seriesMintPrice(string memory series) public view returns (uint256) {
return _seriesMintPrices[series];
}
/**
* Returns the number of mints for series.
*
* @param series series name
* @return number of mints already done withing the series
*/
function seriesMints(string memory series) public view returns (uint256) {
return _seriesMints[series];
}
/**
* Mints the token with predictions. This method will produce the logs so the user can find out the tokenId once transaction is written to the chain.
*
* @param series series name
* @param nickname space for user to put the identifier
* @param predict_1 prediction 1
* @param predict_2 prediction 2
* @param predict_3 prediction 3
* @param predict_4 prediction 4
* @param predict_5 prediction 5
* @param predict_6 prediction 6
*
*/
function mint(string memory series, string memory nickname, uint64 predict_1, uint64 predict_2, uint64 predict_3, uint64 predict_4, uint64 predict_5, uint64 predict_6)
public payable
{
require(_seriesMints[series] < _seriesLimits[series], "Series limit has been reached");
require(msg.value == _seriesMintPrices[series], "ETH value does not match the series mint price");
bytes memory b = new bytes(0);
_mint(msg.sender, _numTokens, 1, b);
uint64 luck = generateLuckyNum(_numTokens, _numDecimals);
uint256 seriesNumber = _seriesMints[series] + 1;
_predictions[_numTokens] = Prediction(block.timestamp, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
emit PredictionMinted(msg.sender, _numTokens, series, seriesNumber, nickname, luck, predict_1, predict_2, predict_3, predict_4, predict_5, predict_6);
_numTokens = _numTokens + 1;
_seriesMints[series] = seriesNumber;
}
/**
*
* Sets the result for the given token.
*
* @param tokenId token id
* @param result_0 the actual value at the time of when prediction had been written to the chain
* @param result_1 the actual value to the prediction_1
* @param result_2 the actual value to the prediction_2
* @param result_3 the actual value to the prediction_3
* @param result_4 the actual value to the prediction_4
* @param result_5 the actual value to the prediction_5
* @param result_6 the actual value to the prediction_6
*/
function setResult(uint256 tokenId, uint64 result_0, uint64 result_1, uint64 result_2, uint64 result_3, uint64 result_4, uint64 result_5, uint64 result_6)
public onlyOwner
{
require(bytes(_predictions[tokenId].series).length > bytes("").length, "prediction must be minted before result can be set");
_results[tokenId] = Result(result_0, result_1, result_2, result_3, result_4, result_5, result_6);
emit ResultSet(msg.sender, tokenId, _predictions[tokenId].series, result_0, result_1, result_2, result_3, result_4, result_5, result_6);
}
/**
* Returns the prediction data under the specified token.
*
* @param tokenId token id
* @return prediction data for the given token
*/
function prediction(uint256 tokenId) public view returns (Prediction memory) {
return _predictions[tokenId];
}
/**
* Returns the result data under the specified token.
*
* @param tokenId token id
* @return result data for the given token
*/
function result(uint256 tokenId) public view returns (ScoredResult memory) {
uint64 score_1 = calculateScore(_predictions[tokenId].predict_1, _results[tokenId].result_1, _numDecimals);
uint64 score_2 = calculateScore(_predictions[tokenId].predict_2, _results[tokenId].result_2, _numDecimals);
uint64 score_3 = calculateScore(_predictions[tokenId].predict_3, _results[tokenId].result_3, _numDecimals);
uint64 score_4 = calculateScore(_predictions[tokenId].predict_4, _results[tokenId].result_4, _numDecimals);
uint64 score_5 = calculateScore(_predictions[tokenId].predict_5, _results[tokenId].result_5, _numDecimals);
uint64 score_6 = calculateScore(_predictions[tokenId].predict_6, _results[tokenId].result_6, _numDecimals);
uint64 totalScore = calculateTotalScore(score_1, score_2, score_3, score_4, score_5, score_6);
return ScoredResult(totalScore, _results[tokenId].result_0,
_results[tokenId].result_1, score_1,
_results[tokenId].result_2, score_2,
_results[tokenId].result_3, score_3,
_results[tokenId].result_4, score_4,
_results[tokenId].result_5, score_5,
_results[tokenId].result_6, score_6);
}
/**
* Returns balance of this contract.
*
* @return contract balance
*/
function balance() public view returns (uint256) {
return address(this).balance;
}
/**
* Withdraws the balance.
*/
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
/**
* Generates lucky number. This is a pseudo random number. This is 0-100% (bounds included), with the given number of decimals.
*
* @param seed seed number
* @param nd number of decimal points to work with
* @return generated number
*/
function generateLuckyNum(uint256 seed, uint8 nd) internal pure returns (uint64) {
uint256 fact = (100 * (10**nd)) + 1;
uint256 kc = uint256(keccak256(abi.encodePacked(seed)));
uint256 rn = kc % fact;
return uint64(rn);
}
/**
* Calculates score from prediction and results.
*
* @param pred preduction
* @param res the actual value
* @param nd number of decimal points
* @return calculated score as 0-100% witgh decimals
*/
function calculateScore(uint64 pred, uint64 res, uint8 nd) internal pure returns (uint64) {
if (pred == 0 && res == 0) {
return 0;
}
uint256 fact = 10**nd;
if (pred >= res) {
uint256 p2 = pred;
uint256 r2 = 100 * res * fact;
uint256 r = r2 / p2;
return uint64(r);
}
else {
uint256 p2 = 100 * pred * fact;
uint256 r2 = res;
uint256 r = p2 / r2;
return uint64(r);
}
}
/**
* Calculates total score from the 6 scores.
*
* @param s1 score 1
* @param s2 score 2
* @param s3 score 3
* @param s4 score 4
* @param s5 score 5
* @param s6 score 6
* @return total score as a weigted average
*/
function calculateTotalScore(uint64 s1, uint64 s2, uint64 s3, uint64 s4, uint64 s5, uint64 s6) internal pure returns (uint64) {
uint256 s1a = s1 * 11;
uint256 s2a = s2 * 12;
uint256 s3a = s3 * 13;
uint256 s4a = s4 * 14;
uint256 s5a = s5 * 15;
uint256 s6a = s6 * 16;
uint256 res = (s1a + s2a + s3a + s4a + s5a + s6a) / 81;
return uint64(res);
}
/**
* Concatenates strings.
*
* @param a string a
* @param b string b
* @return concatenateds string
*/
function strConcat(string memory a, string memory b) internal pure returns (string memory) {
bytes memory ba = bytes(a);
bytes memory bb = bytes(b);
string memory ab = new string(ba.length + bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < ba.length; i++) bab[k++] = ba[i];
for (uint i = 0; i < bb.length; i++) bab[k++] = bb[i];
return string(bab);
}
} | /**
* @author radek.hecl
* @title Cryptoverse BIT contract.
*/ | NatSpecMultiLine | name | function name() public view returns (string memory) {
return _name;
}
| /**
* Returns the contract name.
*
* @return contract name
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
3101,
3186
]
} | 11,199 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.