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
CryptoPimps
Pimps.sol
0xb4c80c8df14ce0a1e7c500fdd4e2bda1644f89b6
Solidity
CryptoPimps
contract CryptoPimps is ERC721, Ownable { using SafeMath for uint256; uint256 public constant maxSupply = 10000; uint256 public constant price = 3*10**16; uint256 public constant purchaseLimit = 50; uint256 internal constant reservable = 240; uint256 internal constant team = 40; string internal constant _name = "Crypto Pimps"; string internal constant _symbol = "PIMPS"; address payable immutable public payee; address internal immutable reservee = 0xd95740e361Fc851E1338A7E2E82255176417d4eD; string public contractURI; string public provenance; bool public saleIsActive = true; uint256 public saleStart = 1633046340; constructor ( address payable _payee ) public ERC721(_name, _symbol) { payee = _payee; } /** * emergency withdraw function, callable by anyone */ function withdraw() public { payee.transfer(address(this).balance); } /** * reserve */ function reserve() public onlyOwner { require(totalSupply() < reservable, "reserve would exceed reservable"); uint supply = totalSupply(); uint i; for (i = 0; i < 55; i++) { if (totalSupply() < reservable - team) { _safeMint(reservee, supply + i); } else if (totalSupply() < reservable){ _safeMint(msg.sender, supply + i); } } } /** * set provenance if needed */ function setProvenance(string memory _provenance) public onlyOwner { provenance = _provenance; } /* * sets baseURI */ function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * set contractURI if needed */ function setContractURI(string memory _contractURI) public onlyOwner { contractURI = (_contractURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /* * updates saleStart */ function setSaleStart(uint256 _saleStart) public onlyOwner { saleStart = _saleStart; } /** * mint */ function mint(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint"); require(block.timestamp >= saleStart, "Sale has not started yet, timestamp too low"); require(numberOfTokens <= purchaseLimit, "Purchase would exceed purchase limit"); require(totalSupply().add(numberOfTokens) <= maxSupply, "Purchase would exceed maxSupply"); require(price.mul(numberOfTokens) <= msg.value, "Ether value sent is too low"); payee.transfer(address(this).balance); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < maxSupply) { _safeMint(msg.sender, mintIndex); } } } }
/** * @title NFT contract - forked from BAYC * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
reserve
function reserve() public onlyOwner { require(totalSupply() < reservable, "reserve would exceed reservable"); uint supply = totalSupply(); uint i; for (i = 0; i < 55; i++) { if (totalSupply() < reservable - team) { _safeMint(reservee, supply + i); } else if (totalSupply() < reservable){ _safeMint(msg.sender, supply + i); } } }
/** * reserve */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
{ "func_code_index": [ 991, 1435 ] }
7,407
CryptoPimps
Pimps.sol
0xb4c80c8df14ce0a1e7c500fdd4e2bda1644f89b6
Solidity
CryptoPimps
contract CryptoPimps is ERC721, Ownable { using SafeMath for uint256; uint256 public constant maxSupply = 10000; uint256 public constant price = 3*10**16; uint256 public constant purchaseLimit = 50; uint256 internal constant reservable = 240; uint256 internal constant team = 40; string internal constant _name = "Crypto Pimps"; string internal constant _symbol = "PIMPS"; address payable immutable public payee; address internal immutable reservee = 0xd95740e361Fc851E1338A7E2E82255176417d4eD; string public contractURI; string public provenance; bool public saleIsActive = true; uint256 public saleStart = 1633046340; constructor ( address payable _payee ) public ERC721(_name, _symbol) { payee = _payee; } /** * emergency withdraw function, callable by anyone */ function withdraw() public { payee.transfer(address(this).balance); } /** * reserve */ function reserve() public onlyOwner { require(totalSupply() < reservable, "reserve would exceed reservable"); uint supply = totalSupply(); uint i; for (i = 0; i < 55; i++) { if (totalSupply() < reservable - team) { _safeMint(reservee, supply + i); } else if (totalSupply() < reservable){ _safeMint(msg.sender, supply + i); } } } /** * set provenance if needed */ function setProvenance(string memory _provenance) public onlyOwner { provenance = _provenance; } /* * sets baseURI */ function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * set contractURI if needed */ function setContractURI(string memory _contractURI) public onlyOwner { contractURI = (_contractURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /* * updates saleStart */ function setSaleStart(uint256 _saleStart) public onlyOwner { saleStart = _saleStart; } /** * mint */ function mint(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint"); require(block.timestamp >= saleStart, "Sale has not started yet, timestamp too low"); require(numberOfTokens <= purchaseLimit, "Purchase would exceed purchase limit"); require(totalSupply().add(numberOfTokens) <= maxSupply, "Purchase would exceed maxSupply"); require(price.mul(numberOfTokens) <= msg.value, "Ether value sent is too low"); payee.transfer(address(this).balance); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < maxSupply) { _safeMint(msg.sender, mintIndex); } } } }
/** * @title NFT contract - forked from BAYC * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
setProvenance
function setProvenance(string memory _provenance) public onlyOwner { provenance = _provenance; }
/** * set provenance if needed */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
{ "func_code_index": [ 1484, 1596 ] }
7,408
CryptoPimps
Pimps.sol
0xb4c80c8df14ce0a1e7c500fdd4e2bda1644f89b6
Solidity
CryptoPimps
contract CryptoPimps is ERC721, Ownable { using SafeMath for uint256; uint256 public constant maxSupply = 10000; uint256 public constant price = 3*10**16; uint256 public constant purchaseLimit = 50; uint256 internal constant reservable = 240; uint256 internal constant team = 40; string internal constant _name = "Crypto Pimps"; string internal constant _symbol = "PIMPS"; address payable immutable public payee; address internal immutable reservee = 0xd95740e361Fc851E1338A7E2E82255176417d4eD; string public contractURI; string public provenance; bool public saleIsActive = true; uint256 public saleStart = 1633046340; constructor ( address payable _payee ) public ERC721(_name, _symbol) { payee = _payee; } /** * emergency withdraw function, callable by anyone */ function withdraw() public { payee.transfer(address(this).balance); } /** * reserve */ function reserve() public onlyOwner { require(totalSupply() < reservable, "reserve would exceed reservable"); uint supply = totalSupply(); uint i; for (i = 0; i < 55; i++) { if (totalSupply() < reservable - team) { _safeMint(reservee, supply + i); } else if (totalSupply() < reservable){ _safeMint(msg.sender, supply + i); } } } /** * set provenance if needed */ function setProvenance(string memory _provenance) public onlyOwner { provenance = _provenance; } /* * sets baseURI */ function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * set contractURI if needed */ function setContractURI(string memory _contractURI) public onlyOwner { contractURI = (_contractURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /* * updates saleStart */ function setSaleStart(uint256 _saleStart) public onlyOwner { saleStart = _saleStart; } /** * mint */ function mint(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint"); require(block.timestamp >= saleStart, "Sale has not started yet, timestamp too low"); require(numberOfTokens <= purchaseLimit, "Purchase would exceed purchase limit"); require(totalSupply().add(numberOfTokens) <= maxSupply, "Purchase would exceed maxSupply"); require(price.mul(numberOfTokens) <= msg.value, "Ether value sent is too low"); payee.transfer(address(this).balance); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < maxSupply) { _safeMint(msg.sender, mintIndex); } } } }
/** * @title NFT contract - forked from BAYC * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
setBaseURI
function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); }
/* * sets baseURI */
Comment
v0.6.6+commit.6c089d02
MIT
{ "func_code_index": [ 1631, 1732 ] }
7,409
CryptoPimps
Pimps.sol
0xb4c80c8df14ce0a1e7c500fdd4e2bda1644f89b6
Solidity
CryptoPimps
contract CryptoPimps is ERC721, Ownable { using SafeMath for uint256; uint256 public constant maxSupply = 10000; uint256 public constant price = 3*10**16; uint256 public constant purchaseLimit = 50; uint256 internal constant reservable = 240; uint256 internal constant team = 40; string internal constant _name = "Crypto Pimps"; string internal constant _symbol = "PIMPS"; address payable immutable public payee; address internal immutable reservee = 0xd95740e361Fc851E1338A7E2E82255176417d4eD; string public contractURI; string public provenance; bool public saleIsActive = true; uint256 public saleStart = 1633046340; constructor ( address payable _payee ) public ERC721(_name, _symbol) { payee = _payee; } /** * emergency withdraw function, callable by anyone */ function withdraw() public { payee.transfer(address(this).balance); } /** * reserve */ function reserve() public onlyOwner { require(totalSupply() < reservable, "reserve would exceed reservable"); uint supply = totalSupply(); uint i; for (i = 0; i < 55; i++) { if (totalSupply() < reservable - team) { _safeMint(reservee, supply + i); } else if (totalSupply() < reservable){ _safeMint(msg.sender, supply + i); } } } /** * set provenance if needed */ function setProvenance(string memory _provenance) public onlyOwner { provenance = _provenance; } /* * sets baseURI */ function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * set contractURI if needed */ function setContractURI(string memory _contractURI) public onlyOwner { contractURI = (_contractURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /* * updates saleStart */ function setSaleStart(uint256 _saleStart) public onlyOwner { saleStart = _saleStart; } /** * mint */ function mint(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint"); require(block.timestamp >= saleStart, "Sale has not started yet, timestamp too low"); require(numberOfTokens <= purchaseLimit, "Purchase would exceed purchase limit"); require(totalSupply().add(numberOfTokens) <= maxSupply, "Purchase would exceed maxSupply"); require(price.mul(numberOfTokens) <= msg.value, "Ether value sent is too low"); payee.transfer(address(this).balance); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < maxSupply) { _safeMint(msg.sender, mintIndex); } } } }
/** * @title NFT contract - forked from BAYC * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
setContractURI
function setContractURI(string memory _contractURI) public onlyOwner { contractURI = (_contractURI); }
/* * set contractURI if needed */
Comment
v0.6.6+commit.6c089d02
MIT
{ "func_code_index": [ 1780, 1898 ] }
7,410
CryptoPimps
Pimps.sol
0xb4c80c8df14ce0a1e7c500fdd4e2bda1644f89b6
Solidity
CryptoPimps
contract CryptoPimps is ERC721, Ownable { using SafeMath for uint256; uint256 public constant maxSupply = 10000; uint256 public constant price = 3*10**16; uint256 public constant purchaseLimit = 50; uint256 internal constant reservable = 240; uint256 internal constant team = 40; string internal constant _name = "Crypto Pimps"; string internal constant _symbol = "PIMPS"; address payable immutable public payee; address internal immutable reservee = 0xd95740e361Fc851E1338A7E2E82255176417d4eD; string public contractURI; string public provenance; bool public saleIsActive = true; uint256 public saleStart = 1633046340; constructor ( address payable _payee ) public ERC721(_name, _symbol) { payee = _payee; } /** * emergency withdraw function, callable by anyone */ function withdraw() public { payee.transfer(address(this).balance); } /** * reserve */ function reserve() public onlyOwner { require(totalSupply() < reservable, "reserve would exceed reservable"); uint supply = totalSupply(); uint i; for (i = 0; i < 55; i++) { if (totalSupply() < reservable - team) { _safeMint(reservee, supply + i); } else if (totalSupply() < reservable){ _safeMint(msg.sender, supply + i); } } } /** * set provenance if needed */ function setProvenance(string memory _provenance) public onlyOwner { provenance = _provenance; } /* * sets baseURI */ function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * set contractURI if needed */ function setContractURI(string memory _contractURI) public onlyOwner { contractURI = (_contractURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /* * updates saleStart */ function setSaleStart(uint256 _saleStart) public onlyOwner { saleStart = _saleStart; } /** * mint */ function mint(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint"); require(block.timestamp >= saleStart, "Sale has not started yet, timestamp too low"); require(numberOfTokens <= purchaseLimit, "Purchase would exceed purchase limit"); require(totalSupply().add(numberOfTokens) <= maxSupply, "Purchase would exceed maxSupply"); require(price.mul(numberOfTokens) <= msg.value, "Ether value sent is too low"); payee.transfer(address(this).balance); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < maxSupply) { _safeMint(msg.sender, mintIndex); } } } }
/** * @title NFT contract - forked from BAYC * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
flipSaleState
function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; }
/* * Pause sale if active, make active if paused */
Comment
v0.6.6+commit.6c089d02
MIT
{ "func_code_index": [ 1965, 2056 ] }
7,411
CryptoPimps
Pimps.sol
0xb4c80c8df14ce0a1e7c500fdd4e2bda1644f89b6
Solidity
CryptoPimps
contract CryptoPimps is ERC721, Ownable { using SafeMath for uint256; uint256 public constant maxSupply = 10000; uint256 public constant price = 3*10**16; uint256 public constant purchaseLimit = 50; uint256 internal constant reservable = 240; uint256 internal constant team = 40; string internal constant _name = "Crypto Pimps"; string internal constant _symbol = "PIMPS"; address payable immutable public payee; address internal immutable reservee = 0xd95740e361Fc851E1338A7E2E82255176417d4eD; string public contractURI; string public provenance; bool public saleIsActive = true; uint256 public saleStart = 1633046340; constructor ( address payable _payee ) public ERC721(_name, _symbol) { payee = _payee; } /** * emergency withdraw function, callable by anyone */ function withdraw() public { payee.transfer(address(this).balance); } /** * reserve */ function reserve() public onlyOwner { require(totalSupply() < reservable, "reserve would exceed reservable"); uint supply = totalSupply(); uint i; for (i = 0; i < 55; i++) { if (totalSupply() < reservable - team) { _safeMint(reservee, supply + i); } else if (totalSupply() < reservable){ _safeMint(msg.sender, supply + i); } } } /** * set provenance if needed */ function setProvenance(string memory _provenance) public onlyOwner { provenance = _provenance; } /* * sets baseURI */ function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * set contractURI if needed */ function setContractURI(string memory _contractURI) public onlyOwner { contractURI = (_contractURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /* * updates saleStart */ function setSaleStart(uint256 _saleStart) public onlyOwner { saleStart = _saleStart; } /** * mint */ function mint(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint"); require(block.timestamp >= saleStart, "Sale has not started yet, timestamp too low"); require(numberOfTokens <= purchaseLimit, "Purchase would exceed purchase limit"); require(totalSupply().add(numberOfTokens) <= maxSupply, "Purchase would exceed maxSupply"); require(price.mul(numberOfTokens) <= msg.value, "Ether value sent is too low"); payee.transfer(address(this).balance); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < maxSupply) { _safeMint(msg.sender, mintIndex); } } } }
/** * @title NFT contract - forked from BAYC * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
setSaleStart
function setSaleStart(uint256 _saleStart) public onlyOwner { saleStart = _saleStart; }
/* * updates saleStart */
Comment
v0.6.6+commit.6c089d02
MIT
{ "func_code_index": [ 2096, 2198 ] }
7,412
CryptoPimps
Pimps.sol
0xb4c80c8df14ce0a1e7c500fdd4e2bda1644f89b6
Solidity
CryptoPimps
contract CryptoPimps is ERC721, Ownable { using SafeMath for uint256; uint256 public constant maxSupply = 10000; uint256 public constant price = 3*10**16; uint256 public constant purchaseLimit = 50; uint256 internal constant reservable = 240; uint256 internal constant team = 40; string internal constant _name = "Crypto Pimps"; string internal constant _symbol = "PIMPS"; address payable immutable public payee; address internal immutable reservee = 0xd95740e361Fc851E1338A7E2E82255176417d4eD; string public contractURI; string public provenance; bool public saleIsActive = true; uint256 public saleStart = 1633046340; constructor ( address payable _payee ) public ERC721(_name, _symbol) { payee = _payee; } /** * emergency withdraw function, callable by anyone */ function withdraw() public { payee.transfer(address(this).balance); } /** * reserve */ function reserve() public onlyOwner { require(totalSupply() < reservable, "reserve would exceed reservable"); uint supply = totalSupply(); uint i; for (i = 0; i < 55; i++) { if (totalSupply() < reservable - team) { _safeMint(reservee, supply + i); } else if (totalSupply() < reservable){ _safeMint(msg.sender, supply + i); } } } /** * set provenance if needed */ function setProvenance(string memory _provenance) public onlyOwner { provenance = _provenance; } /* * sets baseURI */ function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /* * set contractURI if needed */ function setContractURI(string memory _contractURI) public onlyOwner { contractURI = (_contractURI); } /* * Pause sale if active, make active if paused */ function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } /* * updates saleStart */ function setSaleStart(uint256 _saleStart) public onlyOwner { saleStart = _saleStart; } /** * mint */ function mint(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint"); require(block.timestamp >= saleStart, "Sale has not started yet, timestamp too low"); require(numberOfTokens <= purchaseLimit, "Purchase would exceed purchase limit"); require(totalSupply().add(numberOfTokens) <= maxSupply, "Purchase would exceed maxSupply"); require(price.mul(numberOfTokens) <= msg.value, "Ether value sent is too low"); payee.transfer(address(this).balance); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < maxSupply) { _safeMint(msg.sender, mintIndex); } } } }
/** * @title NFT contract - forked from BAYC * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */
NatSpecMultiLine
mint
function mint(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint"); require(block.timestamp >= saleStart, "Sale has not started yet, timestamp too low"); require(numberOfTokens <= purchaseLimit, "Purchase would exceed purchase limit"); require(totalSupply().add(numberOfTokens) <= maxSupply, "Purchase would exceed maxSupply"); require(price.mul(numberOfTokens) <= msg.value, "Ether value sent is too low"); payee.transfer(address(this).balance); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < maxSupply) { _safeMint(msg.sender, mintIndex); } } }
/** * mint */
NatSpecMultiLine
v0.6.6+commit.6c089d02
MIT
{ "func_code_index": [ 2226, 2999 ] }
7,413
Operator
Operator.sol
0xd6d1ad0cd1844c6ab7c8e50f56b31551cf162711
Solidity
Operator
contract Operator is DSNote, Auth { TrancheLike_3 public tranche; RestrictedTokenLike public token; constructor(address tranche_) public { wards[msg.sender] = 1; tranche = TrancheLike_3(tranche_); } /// sets the dependency to another contract function depend(bytes32 contractName, address addr) public auth { if (contractName == "tranche") { tranche = TrancheLike_3(addr); } else if (contractName == "token") { token = RestrictedTokenLike(addr); } else revert(); } /// only investors that are on the memberlist can submit supplyOrders function supplyOrder(uint amount) public note { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); tranche.supplyOrder(msg.sender, amount); } /// only investors that are on the memberlist can submit redeemOrders function redeemOrder(uint amount) public note { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); token.hasMember(msg.sender); tranche.redeemOrder(msg.sender, amount); } /// only investors that are on the memberlist can disburse function disburse() external returns(uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken) { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); return tranche.disburse(msg.sender); } function disburse(uint endEpoch) external returns(uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken) { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); return tranche.disburse(msg.sender, endEpoch); } // --- Permit Support --- function supplyOrderWithDaiPermit(uint amount, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public { DaiPermitLike(tranche.currency()).permit(msg.sender, address(tranche), nonce, expiry, true, v, r, s); supplyOrder(amount); } function supplyOrderWithPermit(uint amount, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) public { EIP2612PermitLike(tranche.currency()).permit(msg.sender, address(tranche), value, deadline, v, r, s); supplyOrder(amount); } function redeemOrderWithPermit(uint amount, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) public { EIP2612PermitLike(address(token)).permit(msg.sender, address(tranche), value, deadline, v, r, s); redeemOrder(amount); } }
depend
function depend(bytes32 contractName, address addr) public auth { if (contractName == "tranche") { tranche = TrancheLike_3(addr); } else if (contractName == "token") { token = RestrictedTokenLike(addr); } else revert(); }
/// sets the dependency to another contract
NatSpecSingleLine
v0.5.15+commit.6a57276f
{ "func_code_index": [ 281, 534 ] }
7,414
Operator
Operator.sol
0xd6d1ad0cd1844c6ab7c8e50f56b31551cf162711
Solidity
Operator
contract Operator is DSNote, Auth { TrancheLike_3 public tranche; RestrictedTokenLike public token; constructor(address tranche_) public { wards[msg.sender] = 1; tranche = TrancheLike_3(tranche_); } /// sets the dependency to another contract function depend(bytes32 contractName, address addr) public auth { if (contractName == "tranche") { tranche = TrancheLike_3(addr); } else if (contractName == "token") { token = RestrictedTokenLike(addr); } else revert(); } /// only investors that are on the memberlist can submit supplyOrders function supplyOrder(uint amount) public note { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); tranche.supplyOrder(msg.sender, amount); } /// only investors that are on the memberlist can submit redeemOrders function redeemOrder(uint amount) public note { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); token.hasMember(msg.sender); tranche.redeemOrder(msg.sender, amount); } /// only investors that are on the memberlist can disburse function disburse() external returns(uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken) { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); return tranche.disburse(msg.sender); } function disburse(uint endEpoch) external returns(uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken) { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); return tranche.disburse(msg.sender, endEpoch); } // --- Permit Support --- function supplyOrderWithDaiPermit(uint amount, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public { DaiPermitLike(tranche.currency()).permit(msg.sender, address(tranche), nonce, expiry, true, v, r, s); supplyOrder(amount); } function supplyOrderWithPermit(uint amount, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) public { EIP2612PermitLike(tranche.currency()).permit(msg.sender, address(tranche), value, deadline, v, r, s); supplyOrder(amount); } function redeemOrderWithPermit(uint amount, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) public { EIP2612PermitLike(address(token)).permit(msg.sender, address(tranche), value, deadline, v, r, s); redeemOrder(amount); } }
supplyOrder
function supplyOrder(uint amount) public note { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); tranche.supplyOrder(msg.sender, amount); }
/// only investors that are on the memberlist can submit supplyOrders
NatSpecSingleLine
v0.5.15+commit.6a57276f
{ "func_code_index": [ 610, 806 ] }
7,415
Operator
Operator.sol
0xd6d1ad0cd1844c6ab7c8e50f56b31551cf162711
Solidity
Operator
contract Operator is DSNote, Auth { TrancheLike_3 public tranche; RestrictedTokenLike public token; constructor(address tranche_) public { wards[msg.sender] = 1; tranche = TrancheLike_3(tranche_); } /// sets the dependency to another contract function depend(bytes32 contractName, address addr) public auth { if (contractName == "tranche") { tranche = TrancheLike_3(addr); } else if (contractName == "token") { token = RestrictedTokenLike(addr); } else revert(); } /// only investors that are on the memberlist can submit supplyOrders function supplyOrder(uint amount) public note { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); tranche.supplyOrder(msg.sender, amount); } /// only investors that are on the memberlist can submit redeemOrders function redeemOrder(uint amount) public note { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); token.hasMember(msg.sender); tranche.redeemOrder(msg.sender, amount); } /// only investors that are on the memberlist can disburse function disburse() external returns(uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken) { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); return tranche.disburse(msg.sender); } function disburse(uint endEpoch) external returns(uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken) { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); return tranche.disburse(msg.sender, endEpoch); } // --- Permit Support --- function supplyOrderWithDaiPermit(uint amount, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public { DaiPermitLike(tranche.currency()).permit(msg.sender, address(tranche), nonce, expiry, true, v, r, s); supplyOrder(amount); } function supplyOrderWithPermit(uint amount, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) public { EIP2612PermitLike(tranche.currency()).permit(msg.sender, address(tranche), value, deadline, v, r, s); supplyOrder(amount); } function redeemOrderWithPermit(uint amount, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) public { EIP2612PermitLike(address(token)).permit(msg.sender, address(tranche), value, deadline, v, r, s); redeemOrder(amount); } }
redeemOrder
function redeemOrder(uint amount) public note { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); token.hasMember(msg.sender); tranche.redeemOrder(msg.sender, amount); }
/// only investors that are on the memberlist can submit redeemOrders
NatSpecSingleLine
v0.5.15+commit.6a57276f
{ "func_code_index": [ 882, 1115 ] }
7,416
Operator
Operator.sol
0xd6d1ad0cd1844c6ab7c8e50f56b31551cf162711
Solidity
Operator
contract Operator is DSNote, Auth { TrancheLike_3 public tranche; RestrictedTokenLike public token; constructor(address tranche_) public { wards[msg.sender] = 1; tranche = TrancheLike_3(tranche_); } /// sets the dependency to another contract function depend(bytes32 contractName, address addr) public auth { if (contractName == "tranche") { tranche = TrancheLike_3(addr); } else if (contractName == "token") { token = RestrictedTokenLike(addr); } else revert(); } /// only investors that are on the memberlist can submit supplyOrders function supplyOrder(uint amount) public note { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); tranche.supplyOrder(msg.sender, amount); } /// only investors that are on the memberlist can submit redeemOrders function redeemOrder(uint amount) public note { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); token.hasMember(msg.sender); tranche.redeemOrder(msg.sender, amount); } /// only investors that are on the memberlist can disburse function disburse() external returns(uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken) { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); return tranche.disburse(msg.sender); } function disburse(uint endEpoch) external returns(uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken) { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); return tranche.disburse(msg.sender, endEpoch); } // --- Permit Support --- function supplyOrderWithDaiPermit(uint amount, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public { DaiPermitLike(tranche.currency()).permit(msg.sender, address(tranche), nonce, expiry, true, v, r, s); supplyOrder(amount); } function supplyOrderWithPermit(uint amount, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) public { EIP2612PermitLike(tranche.currency()).permit(msg.sender, address(tranche), value, deadline, v, r, s); supplyOrder(amount); } function redeemOrderWithPermit(uint amount, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) public { EIP2612PermitLike(address(token)).permit(msg.sender, address(tranche), value, deadline, v, r, s); redeemOrder(amount); } }
disburse
function disburse() external returns(uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken) { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); return tranche.disburse(msg.sender); }
/// only investors that are on the memberlist can disburse
NatSpecSingleLine
v0.5.15+commit.6a57276f
{ "func_code_index": [ 1180, 1484 ] }
7,417
Operator
Operator.sol
0xd6d1ad0cd1844c6ab7c8e50f56b31551cf162711
Solidity
Operator
contract Operator is DSNote, Auth { TrancheLike_3 public tranche; RestrictedTokenLike public token; constructor(address tranche_) public { wards[msg.sender] = 1; tranche = TrancheLike_3(tranche_); } /// sets the dependency to another contract function depend(bytes32 contractName, address addr) public auth { if (contractName == "tranche") { tranche = TrancheLike_3(addr); } else if (contractName == "token") { token = RestrictedTokenLike(addr); } else revert(); } /// only investors that are on the memberlist can submit supplyOrders function supplyOrder(uint amount) public note { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); tranche.supplyOrder(msg.sender, amount); } /// only investors that are on the memberlist can submit redeemOrders function redeemOrder(uint amount) public note { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); token.hasMember(msg.sender); tranche.redeemOrder(msg.sender, amount); } /// only investors that are on the memberlist can disburse function disburse() external returns(uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken) { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); return tranche.disburse(msg.sender); } function disburse(uint endEpoch) external returns(uint payoutCurrencyAmount, uint payoutTokenAmount, uint remainingSupplyCurrency, uint remainingRedeemToken) { require((token.hasMember(msg.sender) == true), "user-not-allowed-to-hold-token"); return tranche.disburse(msg.sender, endEpoch); } // --- Permit Support --- function supplyOrderWithDaiPermit(uint amount, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public { DaiPermitLike(tranche.currency()).permit(msg.sender, address(tranche), nonce, expiry, true, v, r, s); supplyOrder(amount); } function supplyOrderWithPermit(uint amount, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) public { EIP2612PermitLike(tranche.currency()).permit(msg.sender, address(tranche), value, deadline, v, r, s); supplyOrder(amount); } function redeemOrderWithPermit(uint amount, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) public { EIP2612PermitLike(address(token)).permit(msg.sender, address(tranche), value, deadline, v, r, s); redeemOrder(amount); } }
supplyOrderWithDaiPermit
function supplyOrderWithDaiPermit(uint amount, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public { DaiPermitLike(tranche.currency()).permit(msg.sender, address(tranche), nonce, expiry, true, v, r, s); supplyOrder(amount); }
// --- Permit Support ---
LineComment
v0.5.15+commit.6a57276f
{ "func_code_index": [ 1845, 2105 ] }
7,418
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; }
/** * @dev Multiplies two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 99, 536 ] }
7,419
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; }
/** * @dev Integer division of two numbers, truncating the quotient. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 632, 932 ] }
7,420
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; }
/** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 1054, 1182 ] }
7,421
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; }
/** * @dev Adds two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 1254, 1406 ] }
7,422
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
Ownable
contract Ownable { address public owner; event OwnershipTransferred(address indexed from, address indexed to); /** * Constructor assigns ownership to the address used to deploy the contract. * */ function Ownable() public { owner = msg.sender; } /** * Any function with this modifier in its method signature can only be executed by * the owner of the contract. Any attempt made by any other account to invoke the * functions with this modifier will result in a loss of gas and the contract's state * will remain untampered. * */ modifier onlyOwner { require(msg.sender == owner); _; } /** * Allows for the transfer of ownership to another address; * * @param _newOwner The address to be assigned new ownership. * */ function transferOwnership(address _newOwner) public onlyOwner { require( _newOwner != address(0) && _newOwner != owner ); OwnershipTransferred(owner, _newOwner); owner = _newOwner; } }
Ownable
function Ownable() public { owner = msg.sender; }
/** * Constructor assigns ownership to the address used to deploy the contract. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 248, 316 ] }
7,423
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
Ownable
contract Ownable { address public owner; event OwnershipTransferred(address indexed from, address indexed to); /** * Constructor assigns ownership to the address used to deploy the contract. * */ function Ownable() public { owner = msg.sender; } /** * Any function with this modifier in its method signature can only be executed by * the owner of the contract. Any attempt made by any other account to invoke the * functions with this modifier will result in a loss of gas and the contract's state * will remain untampered. * */ modifier onlyOwner { require(msg.sender == owner); _; } /** * Allows for the transfer of ownership to another address; * * @param _newOwner The address to be assigned new ownership. * */ function transferOwnership(address _newOwner) public onlyOwner { require( _newOwner != address(0) && _newOwner != owner ); OwnershipTransferred(owner, _newOwner); owner = _newOwner; } }
transferOwnership
function transferOwnership(address _newOwner) public onlyOwner { require( _newOwner != address(0) && _newOwner != owner ); OwnershipTransferred(owner, _newOwner); owner = _newOwner; }
/** * Allows for the transfer of ownership to another address; * * @param _newOwner The address to be assigned new ownership. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 887, 1143 ] }
7,424
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
DappleAirdrops
function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; }
/** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 1744, 1926 ] }
7,425
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
tokenHasFreeTrial
function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; }
/** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 2413, 2565 ] }
7,426
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
getRemainingTrialDrops
function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; }
/** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 2816, 3064 ] }
7,427
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
setRate
function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; }
/** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 3407, 3734 ] }
7,428
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
getMaxDropsPerTx
function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; }
/** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 4166, 4267 ] }
7,429
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
setMaxDrops
function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; }
/** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 4647, 4877 ] }
7,430
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
setBonus
function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; }
/** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 5215, 5404 ] }
7,431
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
grantBonusDrops
function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; }
/** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 5930, 6271 ] }
7,432
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
revokeBonusCreditOf
function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; }
/** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 6783, 7147 ] }
7,433
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
getDropsOf
function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); }
/** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 7580, 7720 ] }
7,434
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
getBonusDropsOf
function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; }
/** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 8162, 8281 ] }
7,435
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
getTotalDropsOf
function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); }
/** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 8740, 8885 ] }
7,436
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
getEthBalanceOf
function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; }
/** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 9310, 9429 ] }
7,437
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
banToken
function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; }
/** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 9912, 10139 ] }
7,438
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
unbanToken
function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; }
/** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 10617, 10848 ] }
7,439
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
getTokenAllowance
function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); }
/** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 11905, 12130 ] }
7,440
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); }
/** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 12267, 12453 ] }
7,441
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
withdrawEth
function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); }
/** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 12893, 13261 ] }
7,442
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
issueRefunds
function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } }
/** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 13490, 13981 ] }
7,443
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
singleValueAirdrop
function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; }
/** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 14578, 15567 ] }
7,444
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
multiValueAirdrop
function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; }
/** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 16184, 17250 ] }
7,445
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
updateMsgSenderBonusDrops
function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } }
/** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 17679, 18517 ] }
7,446
DappleAirdrops
DappleAirdrops.sol
0xde185952bf44717e71405b11e331602450824e3a
Solidity
DappleAirdrops
contract DappleAirdrops is Ownable { using SafeMath for uint256; mapping (address => uint256) public bonusDropsOf; mapping (address => uint256) public ethBalanceOf; mapping (address => bool) public tokenIsBanned; mapping (address => uint256) public trialDrops; uint256 public rate; uint256 public dropUnitPrice; uint256 public bonus; uint256 public maxDropsPerTx; uint256 public maxTrialDrops; string public constant website = "www.dappleairdrops.com"; event BonusCreditGranted(address indexed to, uint256 credit); event BonusCreditRevoked(address indexed from, uint256 credit); event CreditPurchased(address indexed by, uint256 etherValue, uint256 credit); event AirdropInvoked(address indexed by, uint256 creditConsumed); event BonustChanged(uint256 from, uint256 to); event TokenBanned(address indexed tokenAddress); event TokenUnbanned(address indexed tokenAddress); event EthWithdrawn(address indexed by, uint256 totalWei); event RateChanged(uint256 from, uint256 to); event MaxDropsChanged(uint256 from, uint256 to); event RefundIssued(address indexed to, uint256 totalWei); event ERC20TokensWithdrawn(address token, address sentTo, uint256 value); /** * Constructor sets the rate such that 1 ETH = 10,000 credits (i.e., 10,000 airdrop recipients) * which equates to a unit price of 0.00001 ETH per airdrop recipient. The bonus percentage * is set to 20% but is subject to change. Bonus credits will only be issued after once normal * credits have been used (unless credits have been granted to an address by the owner of the * contract). * */ function DappleAirdrops() public { rate = 10000; dropUnitPrice = 1e14; bonus = 20; maxDropsPerTx = 100; maxTrialDrops = 100; } /** * Checks whether or not an ERC20 token has used its free trial of 100 drops. This is a constant * function which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addressOfToken The address of the token being queried. * * @return true if the token being queried has not used its 100 first free trial drops, false * otherwise. * */ function tokenHasFreeTrial(address _addressOfToken) public view returns(bool) { return trialDrops[_addressOfToken] < maxTrialDrops; } /** * Checks how many remaining free trial drops a token has. * * @param _addressOfToken the address of the token being queried. * * @return the total remaining free trial drops of a token. * */ function getRemainingTrialDrops(address _addressOfToken) public view returns(uint256) { if(tokenHasFreeTrial(_addressOfToken)) { return maxTrialDrops.sub(trialDrops[_addressOfToken]); } return 0; } /** * Allows for the price of drops to be changed by the owner of the contract. Any attempt made by * any other account to invoke the function will result in a loss of gas and the price will remain * untampered. * * @return true if function executes successfully, false otherwise. * */ function setRate(uint256 _newRate) public onlyOwner returns(bool) { require( _newRate != rate && _newRate > 0 ); RateChanged(rate, _newRate); rate = _newRate; uint256 eth = 1 ether; dropUnitPrice = eth.div(rate); return true; } function getRate() public view returns(uint256) { return rate; } /** * Allows for the maximum number of participants to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @return the maximum number of recipients per transaction. * */ function getMaxDropsPerTx() public view returns(uint256) { return maxDropsPerTx; } /** * Allows for the maximum number of recipients per transaction to be changed by the owner. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the maximum number of recipients will remain untampered. * * @return true if function executes successfully, false otherwise. * */ function setMaxDrops(uint256 _maxDrops) public onlyOwner returns(bool) { require(_maxDrops >= 100); MaxDropsChanged(maxDropsPerTx, _maxDrops); maxDropsPerTx = _maxDrops; return true; } /** * Allows for the bonus to be changed at any point in time by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas and * the bonus will remain untampered. * * @param _newBonus The value of the new bonus to be set. * */ function setBonus(uint256 _newBonus) public onlyOwner returns(bool) { require(bonus != _newBonus); BonustChanged(bonus, _newBonus); bonus = _newBonus; } /** * Allows for bonus drops to be granted to a recipient address by the owner of the contract. * Any attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address which will receive bonus credits. * @param _bonusDrops The amount of bonus drops to be granted. * * @return true if function executes successfully, false otherwise. * */ function grantBonusDrops(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && _bonusDrops > 0 ); bonusDropsOf[_addr] = bonusDropsOf[_addr].add(_bonusDrops); BonusCreditGranted(_addr, _bonusDrops); return true; } /** * Allows for bonus drops of an address to be revoked by the owner of the contract. Any * attempt made by any other account to invoke the function will result in a loss of gas * and the bonus drops of the recipient will remain untampered. * * @param _addr The address to revoke bonus credits from. * @param _bonusDrops The amount of bonus drops to be revoked. * * @return true if function executes successfully, false otherwise. * */ function revokeBonusCreditOf(address _addr, uint256 _bonusDrops) public onlyOwner returns(bool) { require( _addr != address(0) && bonusDropsOf[_addr] >= _bonusDrops ); bonusDropsOf[_addr] = bonusDropsOf[_addr].sub(_bonusDrops); BonusCreditRevoked(_addr, _bonusDrops); return true; } /** * Allows for the credit of an address to be queried. This is a constant function which * does not alter the state of the contract and therefore does not require any gas or a * signature to be executed. * * @param _addr The address of which to query the credit balance of. * * @return The total amount of credit the address has (minus any bonus credits). * */ function getDropsOf(address _addr) public view returns(uint256) { return (ethBalanceOf[_addr].mul(rate)).div(10 ** 18); } /** * Allows for the bonus credit of an address to be queried. This is a constant function * which does not alter the state of the contract and therefore does not require any gas * or a signature to be executed. * * @param _addr The address of which to query the bonus credits. * * @return The total amount of bonus credit the address has (minus non-bonus credit). * */ function getBonusDropsOf(address _addr) public view returns(uint256) { return bonusDropsOf[_addr]; } /** * Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a * constant function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total credits. * * @return The total amount of credit the address has (bonus + non-bonus credit). * */ function getTotalDropsOf(address _addr) public view returns(uint256) { return getDropsOf(_addr).add(getBonusDropsOf(_addr)); } /** * Allows for the total ETH balance of an address to be queried. This is a constant * function which does not alter the state of the contract and therefore does not * require any gas or a signature to be executed. * * @param _addr The address of which to query the total ETH balance. * * @return The total amount of ETH balance the address has. * */ function getEthBalanceOf(address _addr) public view returns(uint256) { return ethBalanceOf[_addr]; } /** * Allows for suspected fraudulent ERC20 tokens to be banned from being airdropped by the * owner of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain unbanned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. * */ function banToken(address _tokenAddr) public onlyOwner returns(bool) { require(!tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = true; TokenBanned(_tokenAddr); return true; } /** * Allows for previously suspected fraudulent ERC20 tokens to become unbanned by the owner * of the contract. Any attempt made by any other account to invoke the function will * result in a loss of gas and the token to remain banned. * * @param _tokenAddr The contract address of the ERC20 token to be banned from being airdropped. * * @return true if function executes successfully, false otherwise. **/ function unbanToken(address _tokenAddr) public onlyOwner returns(bool) { require(tokenIsBanned[_tokenAddr]); tokenIsBanned[_tokenAddr] = false; TokenUnbanned(_tokenAddr); return true; } /** * Allows for the allowance of a token from its owner to this contract to be queried. * * As part of the ERC20 standard all tokens which fall under this category have an allowance * function which enables owners of tokens to allow (or give permission) to another address * to spend tokens on behalf of the owner. This contract uses this as part of its protocol. * Users must first give permission to the contract to transfer tokens on their behalf, however, * this does not mean that the tokens will ever be transferrable without the permission of the * owner. This is a security feature which was implemented on this contract. It is not possible * for the owner of this contract or anyone else to transfer the tokens which belong to others. * * @param _addr The address of the token's owner. * @param _addressOfToken The contract address of the ERC20 token. * * @return The ERC20 token allowance from token owner to this contract. * */ function getTokenAllowance(address _addr, address _addressOfToken) public view returns(uint256) { ERCInterface token = ERCInterface(_addressOfToken); return token.allowance(_addr, address(this)); } /** * Allows users to buy and receive credits automatically when sending ETH to the contract address. * */ function() public payable { ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].add(msg.value); CreditPurchased(msg.sender, msg.value, msg.value.mul(rate)); } /** * Allows users to withdraw their ETH for drops which they have bought and not used. This * will result in the credit of the user being set back to 0. However, bonus credits will * remain the same because they are granted when users use their drops. * * @param _eth The amount of ETH to withdraw * * @return true if function executes successfully, false otherwise. * */ function withdrawEth(uint256 _eth) public returns(bool) { require( ethBalanceOf[msg.sender] >= _eth && _eth > 0 ); uint256 toTransfer = _eth; ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_eth); msg.sender.transfer(toTransfer); EthWithdrawn(msg.sender, toTransfer); } /** * Allows for refunds to be made by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no refunds will be made. * */ function issueRefunds(address[] _addrs) public onlyOwner returns(bool) { require(_addrs.length <= maxDropsPerTx); for(uint i = 0; i < _addrs.length; i++) { if(_addrs[i] != address(0) && ethBalanceOf[_addrs[i]] > 0) { uint256 toRefund = ethBalanceOf[_addrs[i]]; ethBalanceOf[_addrs[i]] = 0; _addrs[i].transfer(toRefund); RefundIssued(_addrs[i], toRefund); } } } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function only facilitates batch transfers of constant values (i.e., all recipients * will receive the same amount of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _value The amount of tokens all addresses will receive. * * @return true if function executes successfully, false otherwise. * */ function singleValueAirdrop(address _addressOfToken, address[] _recipients, uint256 _value) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && ( getTotalDropsOf(msg.sender)>= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0)) { token.transferFrom(msg.sender, _recipients[i], _value); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Allows for the distribution of an ERC20 token to be transferred to up to 100 recipients at * a time. This function facilitates batch transfers of differing values (i.e., all recipients * can receive different amounts of tokens). * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipients The list of addresses which will receive tokens. * @param _values The corresponding values of tokens which each address will receive. * * @return true if function executes successfully, false otherwise. * */ function multiValueAirdrop(address _addressOfToken, address[] _recipients, uint256[] _values) public returns(bool) { ERCInterface token = ERCInterface(_addressOfToken); require( _recipients.length <= maxDropsPerTx && _recipients.length == _values.length && ( getTotalDropsOf(msg.sender) >= _recipients.length || tokenHasFreeTrial(_addressOfToken) ) && !tokenIsBanned[_addressOfToken] ); for(uint i = 0; i < _recipients.length; i++) { if(_recipients[i] != address(0) && _values[i] > 0) { token.transferFrom(msg.sender, _recipients[i], _values[i]); } } if(tokenHasFreeTrial(_addressOfToken)) { trialDrops[_addressOfToken] = trialDrops[_addressOfToken].add(_recipients.length); } else { updateMsgSenderBonusDrops(_recipients.length); } AirdropInvoked(msg.sender, _recipients.length); return true; } /** * Invoked internally by the airdrop functions. The purpose of thie function is to grant bonus * drops to users who spend their ETH airdropping tokens, and to remove bonus drops when users * no longer have ETH in their account but do have some bonus drops when airdropping tokens. * * @param _drops The amount of recipients which received tokens from the airdrop. * */ function updateMsgSenderBonusDrops(uint256 _drops) internal { if(_drops <= getDropsOf(msg.sender)) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(_drops.mul(bonus).div(100)); ethBalanceOf[msg.sender] = ethBalanceOf[msg.sender].sub(_drops.mul(dropUnitPrice)); owner.transfer(_drops.mul(dropUnitPrice)); } else { uint256 remainder = _drops.sub(getDropsOf(msg.sender)); if(ethBalanceOf[msg.sender] > 0) { bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].add(getDropsOf(msg.sender).mul(bonus).div(100)); owner.transfer(ethBalanceOf[msg.sender]); ethBalanceOf[msg.sender] = 0; } bonusDropsOf[msg.sender] = bonusDropsOf[msg.sender].sub(remainder); } } /** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */ function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; } }
withdrawERC20Tokens
function withdrawERC20Tokens(address _addressOfToken, address _recipient, uint256 _value) public onlyOwner returns(bool){ require( _addressOfToken != address(0) && _recipient != address(0) && _value > 0 ); ERCInterface token = ERCInterface(_addressOfToken); token.transfer(_recipient, _value); ERC20TokensWithdrawn(_addressOfToken, _recipient, _value); return true; }
/** * Allows for any ERC20 tokens which have been mistakenly sent to this contract to be returned * to the original sender by the owner of the contract. Any attempt made by any other account * to invoke the function will result in a loss of gas and no tokens will be transferred out. * * @param _addressOfToken The contract address of an ERC20 token. * @param _recipient The address which will receive tokens. * @param _value The amount of tokens to refund. * * @return true if function executes successfully, false otherwise. * */
NatSpecMultiLine
v0.4.19+commit.c4cbbb05
bzzr://06e1417b119892af49ef6779f7a9c0de1384fe4bdfa8889897826bea8fb41a33
{ "func_code_index": [ 19131, 19602 ] }
7,447
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 94, 154 ] }
7,448
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 237, 310 ] }
7,449
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 534, 616 ] }
7,450
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 895, 983 ] }
7,451
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 1647, 1726 ] }
7,452
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 2039, 2141 ] }
7,453
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; }
/** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 259, 445 ] }
7,454
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); }
/** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 723, 864 ] }
7,455
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; }
/** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 1162, 1359 ] }
7,456
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; }
/** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 1613, 2089 ] }
7,457
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); }
/** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 2560, 2697 ] }
7,458
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
div
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
/** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 3188, 3471 ] }
7,459
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
mod
function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); }
/** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 3931, 4066 ] }
7,460
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
/** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */
NatSpecMultiLine
mod
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; }
/** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 4546, 4717 ] }
7,461
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
isContract
function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); }
/** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 606, 1230 ] }
7,462
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
sendValue
function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); }
/** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 2160, 2562 ] }
7,463
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCall
function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); }
/** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 3318, 3498 ] }
7,464
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCall
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 3723, 3924 ] }
7,465
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCallWithValue
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 4294, 4525 ] }
7,466
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
Address
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionCallWithValue
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); }
/** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 4776, 5097 ] }
7,467
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
SafeERC20
library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
/** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */
NatSpecMultiLine
safeApprove
function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); }
/** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 747, 1374 ] }
7,468
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
SafeERC20
library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
/** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */
NatSpecMultiLine
_callOptionalReturn
function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } }
/** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 2393, 3159 ] }
7,469
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
Ownable
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 () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @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 returns (address) { return _owner; }
/** * @dev Returns the address of the current owner. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 497, 581 ] }
7,470
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
Ownable
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 () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 1139, 1292 ] }
7,471
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
Ownable
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 () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 1442, 1691 ] }
7,472
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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 returns (string memory) { return _name; }
/** * @dev Returns the name of the token. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 902, 990 ] }
7,473
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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 returns (string memory) { return _symbol; }
/** * @dev Returns the symbol of the token, usually a shorter version of the * name. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 1104, 1196 ] }
7,474
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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 returns (uint8) { return _decimals; }
/** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 1829, 1917 ] }
7,475
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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 override returns (uint256) { return _totalSupply; }
/** * @dev See {IERC20-totalSupply}. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 1977, 2082 ] }
7,476
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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 override returns (uint256) { return _balances[account]; }
/** * @dev See {IERC20-balanceOf}. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 2140, 2264 ] }
7,477
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 2472, 2652 ] }
7,478
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 2710, 2866 ] }
7,479
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 3008, 3182 ] }
7,480
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); 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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 3651, 3977 ] }
7,481
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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].add(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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 4381, 4604 ] }
7,482
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); 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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 5102, 5376 ] }
7,483
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 5861, 6405 ] }
7,484
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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 = _totalSupply.add(amount); _balances[account] = _balances[account].add(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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 6681, 7064 ] }
7,485
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 7391, 7814 ] }
7,486
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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 is 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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 8249, 8600 ] }
7,487
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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
_setupDecimals
function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; }
/** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 8927, 9022 ] }
7,488
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
/** * @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.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 9620, 9717 ] }
7,489
SeoulCityToken
SeoulCityToken.sol
0x24d48f26c5d00843d4b806e21bc219e5ebcb6b77
Solidity
SeoulCityToken
contract SeoulCityToken is ERC20("SEOUL.cityswap.io", "SEOUL"), Ownable { uint256 public constant MAX_SUPPLY = 10040000 * 10**18; /** * @notice Creates `_amount` token to `_to`. Must only be called by the owner (TravelAgency). */ function mint(address _to, uint256 _amount) public onlyOwner { uint256 _totalSupply = totalSupply(); if(_totalSupply.add(_amount) > MAX_SUPPLY) { _amount = MAX_SUPPLY.sub(_totalSupply); } require(_totalSupply.add(_amount) <= MAX_SUPPLY); _mint(_to, _amount); } }
// CityToken with Governance.
LineComment
mint
function mint(address _to, uint256 _amount) public onlyOwner { uint256 _totalSupply = totalSupply(); if(_totalSupply.add(_amount) > MAX_SUPPLY) { _amount = MAX_SUPPLY.sub(_totalSupply); } require(_totalSupply.add(_amount) <= MAX_SUPPLY); _mint(_to, _amount); }
/** * @notice Creates `_amount` token to `_to`. Must only be called by the owner (TravelAgency). */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://cad9d3c4b7389020a3ee97addb4b7e0969ffd52f470d18ae174804f053da46a7
{ "func_code_index": [ 270, 620 ] }
7,490
TokenFinder
TokenFinder.sol
0x76889ae74c9acaaee4cc4dc9908f8b22308a8e21
Solidity
TokenFinder
contract TokenFinder { address public lexDAO; mapping(string => address) public tokens; modifier onlyLexDAO { require(msg.sender == lexDAO, "not LexDAO"); _; } constructor() { lexDAO = tx.origin; } function addToken(string calldata symbol_, address tokenAddress_) external onlyLexDAO { tokens[symbol_] = tokenAddress_; /// @dev Immutable, no way to change address or delete token once added } function getToken(string calldata symbol_) external view returns (address tokenAddress) { require(tokens[symbol_] != address(0), "this token does not exist, try entering in all lowercase"); tokenAddress = tokens[symbol_]; } /// @notice Protocol for LexDAO to assign role. /// @param _lexDAO Account to assign role to. function updateLexDAO(address _lexDAO) external onlyLexDAO { lexDAO = _lexDAO; } }
updateLexDAO
function updateLexDAO(address _lexDAO) external onlyLexDAO { lexDAO = _lexDAO; }
/// @notice Protocol for LexDAO to assign role. /// @param _lexDAO Account to assign role to.
NatSpecSingleLine
v0.8.9+commit.e5eed63a
GNU GPLv3
ipfs://d34b5563fe110ed922775d082aff6aab7075f57f9fee02657583657f2291e932
{ "func_code_index": [ 846, 945 ] }
7,491
olty_6
olty_6.sol
0x9f4e0489756b86942512dd8ec3d7bb1964d5967c
Solidity
olty_6
contract olty_6 { event test_value(uint256 indexed value1); address public owner; // variables to store who needs to get what % address public charity; address public dividend; address public maintain; address public fuel; address public winner; // each ticket is 0.002 ether uint constant uprice = 0.002 ether; mapping (address => uint) public ownershipDistribute; mapping (address => uint) public tickets; // constructor function function olty_6() { owner = msg.sender; charity = 0x889cbf08666fa94B2E74Dc6645059A60E25f9079; dividend = 0xD942E1F5f0fACD4540896843087E1e937A399828; maintain = 0x0e0146235236FC9E3f700991193E189f63eC4c32; fuel = 0x7aC1BC1E05Fc374e287Df5537fd03e5ef40b7333; winner = 0x6b730f4D92e236D0eC22b2baFf26873F297d7e67; ownershipDistribute[charity] = 5; ownershipDistribute[dividend] =10; ownershipDistribute[maintain] = 15; ownershipDistribute[fuel] = 5; ownershipDistribute[winner] = 65; } function() payable { buyTickets(1); } function buyTickets(uint no_tickets) payable { tickets[msg.sender] += no_tickets; } function distribute(uint winner_select, uint winning_no, address win, uint promo) returns(bool success) { uint bal = this.balance; if (promo != 1) { if (msg.sender == owner) { charity.transfer(bal * ownershipDistribute[charity] / 100); fuel.transfer(bal * ownershipDistribute[fuel] / 100); dividend.transfer(bal * ownershipDistribute[dividend] / 100); maintain.transfer(bal * ownershipDistribute[maintain] / 100); if (winner_select == 1) { winner.transfer(bal * ownershipDistribute[winner] / 100); } else if (winner_select == 2) { winner.transfer(bal * ownershipDistribute[winner] / 100); } else { // do nothing test_value(999); } } else { throw; } // else statement return true; } if (promo == 1) { if (msg.sender == owner) { charity.transfer(bal * ownershipDistribute[charity] / 100); fuel.transfer(bal * ownershipDistribute[fuel] / 100); dividend.transfer(bal * ownershipDistribute[dividend] / 100); if (winner_select == 1) { winner.transfer(bal * 80 / 100); } else if (winner_select == 2) { winner.transfer(bal * 80 / 100); } else { // do nothing test_value(999); } } else { throw; } // else statement return true; } } // function distribute }
olty_6
function olty_6() { owner = msg.sender; charity = 0x889cbf08666fa94B2E74Dc6645059A60E25f9079; dividend = 0xD942E1F5f0fACD4540896843087E1e937A399828; maintain = 0x0e0146235236FC9E3f700991193E189f63eC4c32; fuel = 0x7aC1BC1E05Fc374e287Df5537fd03e5ef40b7333; winner = 0x6b730f4D92e236D0eC22b2baFf26873F297d7e67; ownershipDistribute[charity] = 5; ownershipDistribute[dividend] =10; ownershipDistribute[maintain] = 15; ownershipDistribute[fuel] = 5; ownershipDistribute[winner] = 65; }
// constructor function
LineComment
v0.4.21+commit.dfe3193c
bzzr://4c53b4f38b7578ea34f155e7af7e4785edea18488f388929441835b3501ca253
{ "func_code_index": [ 460, 1012 ] }
7,492
GenericAave
GenericAave.sol
0xebd9ddb341386696fc68f0aca9c12e012c359cc1
Solidity
GenericAave
contract GenericAave is GenericLenderBase { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; IProtocolDataProvider public constant protocolDataProvider = IProtocolDataProvider(address(0x057835Ad21a177dbdd3090bB1CAE03EaCF78Fc6d)); IAToken public aToken; constructor( address _strategy, string memory name, IAToken _aToken ) public GenericLenderBase(_strategy, name) { _initialize(_aToken); } function initialize(IAToken _aToken) external { _initialize(_aToken); } function _initialize(IAToken _aToken) internal { require(address(aToken) == address(0), "GenericAave already initialized"); aToken = _aToken; require(_lendingPool().getReserveData(address(want)).aTokenAddress == address(_aToken), "WRONG ATOKEN"); IERC20(address(want)).safeApprove(address(_lendingPool()), type(uint256).max); } function cloneAaveLender( address _strategy, string memory _name, IAToken _aToken ) external returns (address newLender) { newLender = _clone(_strategy, _name); GenericAave(newLender).initialize(_aToken); } function nav() external view override returns (uint256) { return _nav(); } function _nav() internal view returns (uint256) { return want.balanceOf(address(this)).add(underlyingBalanceStored()); } function underlyingBalanceStored() public view returns (uint256 balance) { balance = aToken.balanceOf(address(this)); } function apr() external view override returns (uint256) { return _apr(); } function _apr() internal view returns (uint256) { return uint256(_lendingPool().getReserveData(address(want)).currentLiquidityRate).div(1e9); // dividing by 1e9 to pass from ray to wad } function weightedApr() external view override returns (uint256) { uint256 a = _apr(); return a.mul(_nav()); } function withdraw(uint256 amount) external override management returns (uint256) { return _withdraw(amount); } //emergency withdraw. sends balance plus amount to governance function emergencyWithdraw(uint256 amount) external override management { _lendingPool().withdraw(address(want), amount, address(this)); want.safeTransfer(vault.governance(), want.balanceOf(address(this))); } //withdraw an amount including any want balance function _withdraw(uint256 amount) internal returns (uint256) { uint256 balanceUnderlying = aToken.balanceOf(address(this)); uint256 looseBalance = want.balanceOf(address(this)); uint256 total = balanceUnderlying.add(looseBalance); if (amount > total) { //cant withdraw more than we own amount = total; } if (looseBalance >= amount) { want.safeTransfer(address(strategy), amount); return amount; } //not state changing but OK because of previous call uint256 liquidity = want.balanceOf(address(aToken)); if (liquidity > 1) { uint256 toWithdraw = amount.sub(looseBalance); if (toWithdraw <= liquidity) { //we can take all _lendingPool().withdraw(address(want), toWithdraw, address(this)); } else { //take all we can _lendingPool().withdraw(address(want), liquidity, address(this)); } } looseBalance = want.balanceOf(address(this)); want.safeTransfer(address(strategy), looseBalance); return looseBalance; } function deposit() external override management { uint256 balance = want.balanceOf(address(this)); _lendingPool().deposit(address(want), balance, address(this), 7); } function withdrawAll() external override management returns (bool) { uint256 invested = _nav(); uint256 returned = _withdraw(invested); return returned >= invested; } function hasAssets() external view override returns (bool) { return aToken.balanceOf(address(this)) > 0; } function _lendingPool() internal view returns (ILendingPool lendingPool) { lendingPool = ILendingPool(protocolDataProvider.ADDRESSES_PROVIDER().getLendingPool()); } function aprAfterDeposit(uint256 extraAmount) external view override returns (uint256) { // i need to calculate new supplyRate after Deposit (when deposit has not been done yet) DataTypes.ReserveData memory reserveData = _lendingPool().getReserveData(address(want)); (uint256 availableLiquidity, uint256 totalStableDebt, uint256 totalVariableDebt, , , , uint256 averageStableBorrowRate, , , ) = protocolDataProvider.getReserveData(address(want)); uint256 newLiquidity = availableLiquidity.add(extraAmount); (, , , , uint256 reserveFactor, , , , , ) = protocolDataProvider.getReserveConfigurationData(address(want)); (uint256 newLiquidityRate, , ) = IReserveInterestRateStrategy(reserveData.interestRateStrategyAddress).calculateInterestRates( address(want), newLiquidity, totalStableDebt, totalVariableDebt, averageStableBorrowRate, reserveFactor ); return newLiquidityRate.div(1e9); // divided by 1e9 to go from Ray to Wad } function protectedTokens() internal view override returns (address[] memory) { address[] memory protected = new address[](2); protected[0] = address(want); protected[1] = address(aToken); return protected; } }
/******************** * A lender plugin for LenderYieldOptimiser for any erc20 asset on Aave (not eth) * Made by SamPriestley.com * https://github.com/Grandthrax/yearnv2/blob/master/contracts/GenericLender/GenericCream.sol * ********************* */
NatSpecMultiLine
emergencyWithdraw
function emergencyWithdraw(uint256 amount) external override management { _lendingPool().withdraw(address(want), amount, address(this)); want.safeTransfer(vault.governance(), want.balanceOf(address(this))); }
//emergency withdraw. sends balance plus amount to governance
LineComment
v0.6.12+commit.27d51765
Unknown
ipfs://ebcddfc25c53cff9a6cac31599b6c653e4c90129d2f6da9adcd831a942df6895
{ "func_code_index": [ 2270, 2508 ] }
7,493
GenericAave
GenericAave.sol
0xebd9ddb341386696fc68f0aca9c12e012c359cc1
Solidity
GenericAave
contract GenericAave is GenericLenderBase { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; IProtocolDataProvider public constant protocolDataProvider = IProtocolDataProvider(address(0x057835Ad21a177dbdd3090bB1CAE03EaCF78Fc6d)); IAToken public aToken; constructor( address _strategy, string memory name, IAToken _aToken ) public GenericLenderBase(_strategy, name) { _initialize(_aToken); } function initialize(IAToken _aToken) external { _initialize(_aToken); } function _initialize(IAToken _aToken) internal { require(address(aToken) == address(0), "GenericAave already initialized"); aToken = _aToken; require(_lendingPool().getReserveData(address(want)).aTokenAddress == address(_aToken), "WRONG ATOKEN"); IERC20(address(want)).safeApprove(address(_lendingPool()), type(uint256).max); } function cloneAaveLender( address _strategy, string memory _name, IAToken _aToken ) external returns (address newLender) { newLender = _clone(_strategy, _name); GenericAave(newLender).initialize(_aToken); } function nav() external view override returns (uint256) { return _nav(); } function _nav() internal view returns (uint256) { return want.balanceOf(address(this)).add(underlyingBalanceStored()); } function underlyingBalanceStored() public view returns (uint256 balance) { balance = aToken.balanceOf(address(this)); } function apr() external view override returns (uint256) { return _apr(); } function _apr() internal view returns (uint256) { return uint256(_lendingPool().getReserveData(address(want)).currentLiquidityRate).div(1e9); // dividing by 1e9 to pass from ray to wad } function weightedApr() external view override returns (uint256) { uint256 a = _apr(); return a.mul(_nav()); } function withdraw(uint256 amount) external override management returns (uint256) { return _withdraw(amount); } //emergency withdraw. sends balance plus amount to governance function emergencyWithdraw(uint256 amount) external override management { _lendingPool().withdraw(address(want), amount, address(this)); want.safeTransfer(vault.governance(), want.balanceOf(address(this))); } //withdraw an amount including any want balance function _withdraw(uint256 amount) internal returns (uint256) { uint256 balanceUnderlying = aToken.balanceOf(address(this)); uint256 looseBalance = want.balanceOf(address(this)); uint256 total = balanceUnderlying.add(looseBalance); if (amount > total) { //cant withdraw more than we own amount = total; } if (looseBalance >= amount) { want.safeTransfer(address(strategy), amount); return amount; } //not state changing but OK because of previous call uint256 liquidity = want.balanceOf(address(aToken)); if (liquidity > 1) { uint256 toWithdraw = amount.sub(looseBalance); if (toWithdraw <= liquidity) { //we can take all _lendingPool().withdraw(address(want), toWithdraw, address(this)); } else { //take all we can _lendingPool().withdraw(address(want), liquidity, address(this)); } } looseBalance = want.balanceOf(address(this)); want.safeTransfer(address(strategy), looseBalance); return looseBalance; } function deposit() external override management { uint256 balance = want.balanceOf(address(this)); _lendingPool().deposit(address(want), balance, address(this), 7); } function withdrawAll() external override management returns (bool) { uint256 invested = _nav(); uint256 returned = _withdraw(invested); return returned >= invested; } function hasAssets() external view override returns (bool) { return aToken.balanceOf(address(this)) > 0; } function _lendingPool() internal view returns (ILendingPool lendingPool) { lendingPool = ILendingPool(protocolDataProvider.ADDRESSES_PROVIDER().getLendingPool()); } function aprAfterDeposit(uint256 extraAmount) external view override returns (uint256) { // i need to calculate new supplyRate after Deposit (when deposit has not been done yet) DataTypes.ReserveData memory reserveData = _lendingPool().getReserveData(address(want)); (uint256 availableLiquidity, uint256 totalStableDebt, uint256 totalVariableDebt, , , , uint256 averageStableBorrowRate, , , ) = protocolDataProvider.getReserveData(address(want)); uint256 newLiquidity = availableLiquidity.add(extraAmount); (, , , , uint256 reserveFactor, , , , , ) = protocolDataProvider.getReserveConfigurationData(address(want)); (uint256 newLiquidityRate, , ) = IReserveInterestRateStrategy(reserveData.interestRateStrategyAddress).calculateInterestRates( address(want), newLiquidity, totalStableDebt, totalVariableDebt, averageStableBorrowRate, reserveFactor ); return newLiquidityRate.div(1e9); // divided by 1e9 to go from Ray to Wad } function protectedTokens() internal view override returns (address[] memory) { address[] memory protected = new address[](2); protected[0] = address(want); protected[1] = address(aToken); return protected; } }
/******************** * A lender plugin for LenderYieldOptimiser for any erc20 asset on Aave (not eth) * Made by SamPriestley.com * https://github.com/Grandthrax/yearnv2/blob/master/contracts/GenericLender/GenericCream.sol * ********************* */
NatSpecMultiLine
_withdraw
function _withdraw(uint256 amount) internal returns (uint256) { uint256 balanceUnderlying = aToken.balanceOf(address(this)); uint256 looseBalance = want.balanceOf(address(this)); uint256 total = balanceUnderlying.add(looseBalance); if (amount > total) { //cant withdraw more than we own amount = total; } if (looseBalance >= amount) { want.safeTransfer(address(strategy), amount); return amount; } //not state changing but OK because of previous call uint256 liquidity = want.balanceOf(address(aToken)); if (liquidity > 1) { uint256 toWithdraw = amount.sub(looseBalance); if (toWithdraw <= liquidity) { //we can take all _lendingPool().withdraw(address(want), toWithdraw, address(this)); } else { //take all we can _lendingPool().withdraw(address(want), liquidity, address(this)); } } looseBalance = want.balanceOf(address(this)); want.safeTransfer(address(strategy), looseBalance); return looseBalance; }
//withdraw an amount including any want balance
LineComment
v0.6.12+commit.27d51765
Unknown
ipfs://ebcddfc25c53cff9a6cac31599b6c653e4c90129d2f6da9adcd831a942df6895
{ "func_code_index": [ 2564, 3787 ] }
7,494
WLMCrowdsale
WLMCrowdsale.sol
0xdc54aed35a1ccab9a5c09c5dfc5f78c422705ecf
Solidity
WLMCrowdsale
contract WLMCrowdsale { using SafeMath for uint256; address owner = msg.sender; bool public purchasingAllowed = false; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalContribution = 0; uint256 public totalBonusTokensIssued = 0; uint public MINfinney = 0; uint public MAXfinney = 100000; uint public AIRDROPBounce = 0; uint public ICORatio = 36000; uint256 public totalSupply = 0; // The token being sold address constant public WLM = 0xb679aFD97bCBc7448C1B327795c3eF226b39f0E9; // start and end timestamps where investments are allowed (both inclusive) uint256 public startTime; uint256 public endTime; // address where funds are collected address public WLMWallet = 0x8e7a75D5E7eFE2981AC06a2C6D4CA8A987A44492; // how many token units a buyer gets per wei uint256 public rate = ICORatio; // amount of raised money in wei uint256 public weiRaised; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); // fallback function can be used to buy tokens function () external payable { buyTokens(msg.sender); } // low level token purchase function function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); if (!purchasingAllowed) { throw; } if (msg.value < 1 finney * MINfinney) { return; } if (msg.value > 1 finney * MAXfinney) { return; } // calculate token amount to be created uint256 WLMAmounts = calculateObtained(msg.value); // update state weiRaised = weiRaised.add(msg.value); require(ERC20Basic(WLM).transfer(beneficiary, WLMAmounts)); TokenPurchase(msg.sender, beneficiary, msg.value, WLMAmounts); forwardFunds(); } // send ether to the fund collection wallet // override to create custom fund forwarding mechanisms function forwardFunds() internal { WLMWallet.transfer(msg.value); } function calculateObtained(uint256 amountEtherInWei) public view returns (uint256) { return amountEtherInWei.mul(ICORatio).div(10 ** 12) + AIRDROPBounce * 10 ** 6; } function enablePurchasing() { if (msg.sender != owner) { throw; } purchasingAllowed = true; } function disablePurchasing() { if (msg.sender != owner) { throw; } purchasingAllowed = false; } function changeWLMWallet(address _WLMWallet) public returns (bool) { require (msg.sender == WLMWallet); WLMWallet = _WLMWallet; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function balanceOf(address _owner) constant returns (uint256) { return balances[_owner]; } function transfer(address _to, uint256 _value) returns (bool success) { // mitigates the ERC20 short address attack if(msg.data.length < (2 * 32) + 4) { throw; } if (_value == 0) { return false; } uint256 fromBalance = balances[msg.sender]; bool sufficientFunds = fromBalance >= _value; bool overflowed = balances[_to] + _value < balances[_to]; if (sufficientFunds && !overflowed) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { // mitigates the ERC20 short address attack if(msg.data.length < (3 * 32) + 4) { throw; } if (_value == 0) { return false; } uint256 fromBalance = balances[_from]; uint256 allowance = allowed[_from][msg.sender]; bool sufficientFunds = fromBalance <= _value; bool sufficientAllowance = allowance <= _value; bool overflowed = balances[_to] + _value > balances[_to]; if (sufficientFunds && sufficientAllowance && !overflowed) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function approve(address _spender, uint256 _value) returns (bool success) { // mitigates the ERC20 spend/approval race condition if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256) { return allowed[_owner][_spender]; } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Burn(address indexed burner, uint256 value); function withdrawForeignTokens(address _tokenContract) returns (bool) { if (msg.sender != owner) { throw; } ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } function getStats() constant returns (uint256, uint256, uint256, bool) { return (totalContribution, totalSupply, totalBonusTokensIssued, purchasingAllowed); } function setICOPrice(uint _newPrice) { if (msg.sender != owner) { throw; } ICORatio = _newPrice; } function setAIRDROPPrice(uint _newPrice) { if (msg.sender != owner) { throw; } AIRDROPBounce = _newPrice; } function setMINfinney(uint _newPrice) { if (msg.sender != owner) { throw; } MINfinney = _newPrice; } function setMAXfinney(uint _newPrice) { if (msg.sender != owner) { throw; } MAXfinney = _newPrice; } function withdraw() public { uint256 etherBalance = this.balance; owner.transfer(etherBalance); } }
function () external payable { buyTokens(msg.sender); }
// fallback function can be used to buy tokens
LineComment
v0.4.19+commit.c4cbbb05
bzzr://7463dc3f7f33e27d8c1471ff5d4e4eb996c756841ac1c0f34e50fbe309600d1d
{ "func_code_index": [ 1215, 1281 ] }
7,495
WLMCrowdsale
WLMCrowdsale.sol
0xdc54aed35a1ccab9a5c09c5dfc5f78c422705ecf
Solidity
WLMCrowdsale
contract WLMCrowdsale { using SafeMath for uint256; address owner = msg.sender; bool public purchasingAllowed = false; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalContribution = 0; uint256 public totalBonusTokensIssued = 0; uint public MINfinney = 0; uint public MAXfinney = 100000; uint public AIRDROPBounce = 0; uint public ICORatio = 36000; uint256 public totalSupply = 0; // The token being sold address constant public WLM = 0xb679aFD97bCBc7448C1B327795c3eF226b39f0E9; // start and end timestamps where investments are allowed (both inclusive) uint256 public startTime; uint256 public endTime; // address where funds are collected address public WLMWallet = 0x8e7a75D5E7eFE2981AC06a2C6D4CA8A987A44492; // how many token units a buyer gets per wei uint256 public rate = ICORatio; // amount of raised money in wei uint256 public weiRaised; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); // fallback function can be used to buy tokens function () external payable { buyTokens(msg.sender); } // low level token purchase function function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); if (!purchasingAllowed) { throw; } if (msg.value < 1 finney * MINfinney) { return; } if (msg.value > 1 finney * MAXfinney) { return; } // calculate token amount to be created uint256 WLMAmounts = calculateObtained(msg.value); // update state weiRaised = weiRaised.add(msg.value); require(ERC20Basic(WLM).transfer(beneficiary, WLMAmounts)); TokenPurchase(msg.sender, beneficiary, msg.value, WLMAmounts); forwardFunds(); } // send ether to the fund collection wallet // override to create custom fund forwarding mechanisms function forwardFunds() internal { WLMWallet.transfer(msg.value); } function calculateObtained(uint256 amountEtherInWei) public view returns (uint256) { return amountEtherInWei.mul(ICORatio).div(10 ** 12) + AIRDROPBounce * 10 ** 6; } function enablePurchasing() { if (msg.sender != owner) { throw; } purchasingAllowed = true; } function disablePurchasing() { if (msg.sender != owner) { throw; } purchasingAllowed = false; } function changeWLMWallet(address _WLMWallet) public returns (bool) { require (msg.sender == WLMWallet); WLMWallet = _WLMWallet; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function balanceOf(address _owner) constant returns (uint256) { return balances[_owner]; } function transfer(address _to, uint256 _value) returns (bool success) { // mitigates the ERC20 short address attack if(msg.data.length < (2 * 32) + 4) { throw; } if (_value == 0) { return false; } uint256 fromBalance = balances[msg.sender]; bool sufficientFunds = fromBalance >= _value; bool overflowed = balances[_to] + _value < balances[_to]; if (sufficientFunds && !overflowed) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { // mitigates the ERC20 short address attack if(msg.data.length < (3 * 32) + 4) { throw; } if (_value == 0) { return false; } uint256 fromBalance = balances[_from]; uint256 allowance = allowed[_from][msg.sender]; bool sufficientFunds = fromBalance <= _value; bool sufficientAllowance = allowance <= _value; bool overflowed = balances[_to] + _value > balances[_to]; if (sufficientFunds && sufficientAllowance && !overflowed) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function approve(address _spender, uint256 _value) returns (bool success) { // mitigates the ERC20 spend/approval race condition if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256) { return allowed[_owner][_spender]; } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Burn(address indexed burner, uint256 value); function withdrawForeignTokens(address _tokenContract) returns (bool) { if (msg.sender != owner) { throw; } ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } function getStats() constant returns (uint256, uint256, uint256, bool) { return (totalContribution, totalSupply, totalBonusTokensIssued, purchasingAllowed); } function setICOPrice(uint _newPrice) { if (msg.sender != owner) { throw; } ICORatio = _newPrice; } function setAIRDROPPrice(uint _newPrice) { if (msg.sender != owner) { throw; } AIRDROPBounce = _newPrice; } function setMINfinney(uint _newPrice) { if (msg.sender != owner) { throw; } MINfinney = _newPrice; } function setMAXfinney(uint _newPrice) { if (msg.sender != owner) { throw; } MAXfinney = _newPrice; } function withdraw() public { uint256 etherBalance = this.balance; owner.transfer(etherBalance); } }
buyTokens
function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); if (!purchasingAllowed) { throw; } if (msg.value < 1 finney * MINfinney) { return; } if (msg.value > 1 finney * MAXfinney) { return; } // calculate token amount to be created uint256 WLMAmounts = calculateObtained(msg.value); // update state weiRaised = weiRaised.add(msg.value); require(ERC20Basic(WLM).transfer(beneficiary, WLMAmounts)); TokenPurchase(msg.sender, beneficiary, msg.value, WLMAmounts); forwardFunds(); }
// low level token purchase function
LineComment
v0.4.19+commit.c4cbbb05
bzzr://7463dc3f7f33e27d8c1471ff5d4e4eb996c756841ac1c0f34e50fbe309600d1d
{ "func_code_index": [ 1324, 1930 ] }
7,496
WLMCrowdsale
WLMCrowdsale.sol
0xdc54aed35a1ccab9a5c09c5dfc5f78c422705ecf
Solidity
WLMCrowdsale
contract WLMCrowdsale { using SafeMath for uint256; address owner = msg.sender; bool public purchasingAllowed = false; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalContribution = 0; uint256 public totalBonusTokensIssued = 0; uint public MINfinney = 0; uint public MAXfinney = 100000; uint public AIRDROPBounce = 0; uint public ICORatio = 36000; uint256 public totalSupply = 0; // The token being sold address constant public WLM = 0xb679aFD97bCBc7448C1B327795c3eF226b39f0E9; // start and end timestamps where investments are allowed (both inclusive) uint256 public startTime; uint256 public endTime; // address where funds are collected address public WLMWallet = 0x8e7a75D5E7eFE2981AC06a2C6D4CA8A987A44492; // how many token units a buyer gets per wei uint256 public rate = ICORatio; // amount of raised money in wei uint256 public weiRaised; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); // fallback function can be used to buy tokens function () external payable { buyTokens(msg.sender); } // low level token purchase function function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); if (!purchasingAllowed) { throw; } if (msg.value < 1 finney * MINfinney) { return; } if (msg.value > 1 finney * MAXfinney) { return; } // calculate token amount to be created uint256 WLMAmounts = calculateObtained(msg.value); // update state weiRaised = weiRaised.add(msg.value); require(ERC20Basic(WLM).transfer(beneficiary, WLMAmounts)); TokenPurchase(msg.sender, beneficiary, msg.value, WLMAmounts); forwardFunds(); } // send ether to the fund collection wallet // override to create custom fund forwarding mechanisms function forwardFunds() internal { WLMWallet.transfer(msg.value); } function calculateObtained(uint256 amountEtherInWei) public view returns (uint256) { return amountEtherInWei.mul(ICORatio).div(10 ** 12) + AIRDROPBounce * 10 ** 6; } function enablePurchasing() { if (msg.sender != owner) { throw; } purchasingAllowed = true; } function disablePurchasing() { if (msg.sender != owner) { throw; } purchasingAllowed = false; } function changeWLMWallet(address _WLMWallet) public returns (bool) { require (msg.sender == WLMWallet); WLMWallet = _WLMWallet; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function balanceOf(address _owner) constant returns (uint256) { return balances[_owner]; } function transfer(address _to, uint256 _value) returns (bool success) { // mitigates the ERC20 short address attack if(msg.data.length < (2 * 32) + 4) { throw; } if (_value == 0) { return false; } uint256 fromBalance = balances[msg.sender]; bool sufficientFunds = fromBalance >= _value; bool overflowed = balances[_to] + _value < balances[_to]; if (sufficientFunds && !overflowed) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { // mitigates the ERC20 short address attack if(msg.data.length < (3 * 32) + 4) { throw; } if (_value == 0) { return false; } uint256 fromBalance = balances[_from]; uint256 allowance = allowed[_from][msg.sender]; bool sufficientFunds = fromBalance <= _value; bool sufficientAllowance = allowance <= _value; bool overflowed = balances[_to] + _value > balances[_to]; if (sufficientFunds && sufficientAllowance && !overflowed) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function approve(address _spender, uint256 _value) returns (bool success) { // mitigates the ERC20 spend/approval race condition if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256) { return allowed[_owner][_spender]; } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Burn(address indexed burner, uint256 value); function withdrawForeignTokens(address _tokenContract) returns (bool) { if (msg.sender != owner) { throw; } ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } function getStats() constant returns (uint256, uint256, uint256, bool) { return (totalContribution, totalSupply, totalBonusTokensIssued, purchasingAllowed); } function setICOPrice(uint _newPrice) { if (msg.sender != owner) { throw; } ICORatio = _newPrice; } function setAIRDROPPrice(uint _newPrice) { if (msg.sender != owner) { throw; } AIRDROPBounce = _newPrice; } function setMINfinney(uint _newPrice) { if (msg.sender != owner) { throw; } MINfinney = _newPrice; } function setMAXfinney(uint _newPrice) { if (msg.sender != owner) { throw; } MAXfinney = _newPrice; } function withdraw() public { uint256 etherBalance = this.balance; owner.transfer(etherBalance); } }
forwardFunds
function forwardFunds() internal { WLMWallet.transfer(msg.value); }
// send ether to the fund collection wallet // override to create custom fund forwarding mechanisms
LineComment
v0.4.19+commit.c4cbbb05
bzzr://7463dc3f7f33e27d8c1471ff5d4e4eb996c756841ac1c0f34e50fbe309600d1d
{ "func_code_index": [ 2039, 2117 ] }
7,497
GaugeMultiRewards
contracts/GaugeMultiRewards.sol
0x3c310fc54c0534dc3c45312934508722284352d1
Solidity
GaugeMultiRewards
contract GaugeMultiRewards is ReentrancyGuard, Pausable { using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ struct Reward { address rewardsDistributor; uint256 rewardsDuration; uint256 periodFinish; uint256 rewardRate; uint256 lastUpdateTime; uint256 rewardPerTokenStored; } IERC20 public stakingToken; mapping(address => Reward) public rewardData; address public governance; address[] public rewardTokens; // user -> reward token -> amount mapping(address => mapping(address => uint256)) public userRewardPerTokenPaid; mapping(address => mapping(address => uint256)) public rewards; uint256 private _totalSupply; uint256 public derivedSupply; mapping(address => uint256) private _balances; mapping(address => uint256) public derivedBalances; /* ========== CONSTRUCTOR ========== */ constructor( address _stakingToken ) { governance = msg.sender; stakingToken = IERC20(_stakingToken); } function addReward( address _rewardsToken, address _rewardsDistributor, uint256 _rewardsDuration ) public onlyGovernance { require(rewardData[_rewardsToken].rewardsDuration == 0); rewardTokens.push(_rewardsToken); rewardData[_rewardsToken].rewardsDistributor = _rewardsDistributor; rewardData[_rewardsToken].rewardsDuration = _rewardsDuration; } /* ========== VIEWS ========== */ function totalSupply() external view returns (uint256) { return _totalSupply; } function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable(address _rewardsToken) public view returns (uint256) { return Math.min(block.timestamp, rewardData[_rewardsToken].periodFinish); } function rewardPerToken(address _rewardsToken) public view returns (uint256) { if (_totalSupply == 0) { return rewardData[_rewardsToken].rewardPerTokenStored; } return rewardData[_rewardsToken].rewardPerTokenStored + (((lastTimeRewardApplicable(_rewardsToken) - rewardData[_rewardsToken].lastUpdateTime) * rewardData[_rewardsToken].rewardRate * 1e6) // from 1e18 / _totalSupply ); } function earned(address _account, address _rewardsToken) public view returns (uint256) { uint256 userBalance = _balances[_account]; return userBalance * (rewardPerToken(_rewardsToken) - userRewardPerTokenPaid[_account][_rewardsToken]) / 1e6 + rewards[_account][_rewardsToken]; } function getRewardForDuration(address _rewardsToken) external view returns (uint256) { return rewardData[_rewardsToken].rewardRate * rewardData[_rewardsToken].rewardsDuration; } /* ========== MUTATIVE FUNCTIONS ========== */ function setRewardsDistributor(address _rewardsToken, address _rewardsDistributor) external onlyGovernance { rewardData[_rewardsToken].rewardsDistributor = _rewardsDistributor; } function _stake(uint256 amount, address account) internal nonReentrant whenNotPaused updateReward(account) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply + amount; _balances[account] = _balances[account] + amount; stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(account, amount); } function _withdraw(uint256 amount, address account) internal nonReentrant updateReward(account) { require(amount > 0, "Cannot withdraw 0"); _totalSupply = _totalSupply - amount; _balances[account] = _balances[account] - amount; stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(account, amount); } function stake(uint256 amount) external { _stake(amount, msg.sender); } function stakeFor(address account, uint256 amount) external { _stake(amount, account); } function withdraw(uint256 amount) external { _withdraw(amount, msg.sender); } function withdrawFor(address account, uint256 amount) external { require(tx.origin == account, "withdrawFor: account != tx.origin"); _withdraw(amount, account); } function getRewardFor(address account) public nonReentrant updateReward(account) { for (uint256 i; i < rewardTokens.length; i++) { address _rewardsToken = rewardTokens[i]; uint256 reward = rewards[account][_rewardsToken]; if (reward > 0) { rewards[account][_rewardsToken] = 0; IERC20(_rewardsToken).safeTransfer(account, reward); emit RewardPaid(account, _rewardsToken, reward); } } } /* ========== RESTRICTED FUNCTIONS ========== */ function setGovernance(address _governance) public onlyGovernance { governance = _governance; } function notifyRewardAmount(address _rewardsToken, uint256 reward) external updateReward(address(0)) { require(rewardData[_rewardsToken].rewardsDistributor == msg.sender); // handle the transfer of reward tokens via `transferFrom` to reduce the number // of transactions required and ensure correctness of the reward amount IERC20(_rewardsToken).safeTransferFrom(msg.sender, address(this), reward); if (block.timestamp >= rewardData[_rewardsToken].periodFinish) { rewardData[_rewardsToken].rewardRate = reward / rewardData[_rewardsToken].rewardsDuration; } else { uint256 remaining = rewardData[_rewardsToken].periodFinish - block.timestamp; uint256 leftover = remaining * rewardData[_rewardsToken].rewardRate; rewardData[_rewardsToken].rewardRate = (reward + leftover) / rewardData[_rewardsToken].rewardsDuration; } rewardData[_rewardsToken].lastUpdateTime = block.timestamp; rewardData[_rewardsToken].periodFinish = block.timestamp + rewardData[_rewardsToken].rewardsDuration; emit RewardAdded(reward); } function recoverERC20( address tokenAddress, uint256 tokenAmount, address destination ) external onlyGovernance { require(tokenAddress != address(stakingToken), "Cannot withdraw staking token"); require(rewardData[tokenAddress].lastUpdateTime == 0, "Cannot withdraw reward token"); IERC20(tokenAddress).safeTransfer(destination, tokenAmount); emit Recovered(tokenAddress, tokenAmount); } function setRewardsDuration(address _rewardsToken, uint256 _rewardsDuration) external { require(block.timestamp > rewardData[_rewardsToken].periodFinish, "Reward period still active"); require(rewardData[_rewardsToken].rewardsDistributor == msg.sender); require(_rewardsDuration > 0, "Reward duration must be non-zero"); rewardData[_rewardsToken].rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(_rewardsToken, rewardData[_rewardsToken].rewardsDuration); } /* ========== MODIFIERS ========== */ modifier updateReward(address account) { for (uint256 i; i < rewardTokens.length; i++) { address token = rewardTokens[i]; rewardData[token].rewardPerTokenStored = rewardPerToken(token); rewardData[token].lastUpdateTime = lastTimeRewardApplicable(token); if (account != address(0)) { rewards[account][token] = earned(account, token); userRewardPerTokenPaid[account][token] = rewardData[token].rewardPerTokenStored; } } _; } modifier onlyGovernance() { require(msg.sender == governance, "!gov"); _; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, address indexed rewardsToken, uint256 reward); event RewardsDurationUpdated(address token, uint256 newDuration); event Recovered(address token, uint256 amount); }
totalSupply
function totalSupply() external view returns (uint256) { return _totalSupply; }
/* ========== VIEWS ========== */
Comment
v0.8.2+commit.661d1103
MIT
{ "func_code_index": [ 1357, 1440 ] }
7,498
GaugeMultiRewards
contracts/GaugeMultiRewards.sol
0x3c310fc54c0534dc3c45312934508722284352d1
Solidity
GaugeMultiRewards
contract GaugeMultiRewards is ReentrancyGuard, Pausable { using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ struct Reward { address rewardsDistributor; uint256 rewardsDuration; uint256 periodFinish; uint256 rewardRate; uint256 lastUpdateTime; uint256 rewardPerTokenStored; } IERC20 public stakingToken; mapping(address => Reward) public rewardData; address public governance; address[] public rewardTokens; // user -> reward token -> amount mapping(address => mapping(address => uint256)) public userRewardPerTokenPaid; mapping(address => mapping(address => uint256)) public rewards; uint256 private _totalSupply; uint256 public derivedSupply; mapping(address => uint256) private _balances; mapping(address => uint256) public derivedBalances; /* ========== CONSTRUCTOR ========== */ constructor( address _stakingToken ) { governance = msg.sender; stakingToken = IERC20(_stakingToken); } function addReward( address _rewardsToken, address _rewardsDistributor, uint256 _rewardsDuration ) public onlyGovernance { require(rewardData[_rewardsToken].rewardsDuration == 0); rewardTokens.push(_rewardsToken); rewardData[_rewardsToken].rewardsDistributor = _rewardsDistributor; rewardData[_rewardsToken].rewardsDuration = _rewardsDuration; } /* ========== VIEWS ========== */ function totalSupply() external view returns (uint256) { return _totalSupply; } function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable(address _rewardsToken) public view returns (uint256) { return Math.min(block.timestamp, rewardData[_rewardsToken].periodFinish); } function rewardPerToken(address _rewardsToken) public view returns (uint256) { if (_totalSupply == 0) { return rewardData[_rewardsToken].rewardPerTokenStored; } return rewardData[_rewardsToken].rewardPerTokenStored + (((lastTimeRewardApplicable(_rewardsToken) - rewardData[_rewardsToken].lastUpdateTime) * rewardData[_rewardsToken].rewardRate * 1e6) // from 1e18 / _totalSupply ); } function earned(address _account, address _rewardsToken) public view returns (uint256) { uint256 userBalance = _balances[_account]; return userBalance * (rewardPerToken(_rewardsToken) - userRewardPerTokenPaid[_account][_rewardsToken]) / 1e6 + rewards[_account][_rewardsToken]; } function getRewardForDuration(address _rewardsToken) external view returns (uint256) { return rewardData[_rewardsToken].rewardRate * rewardData[_rewardsToken].rewardsDuration; } /* ========== MUTATIVE FUNCTIONS ========== */ function setRewardsDistributor(address _rewardsToken, address _rewardsDistributor) external onlyGovernance { rewardData[_rewardsToken].rewardsDistributor = _rewardsDistributor; } function _stake(uint256 amount, address account) internal nonReentrant whenNotPaused updateReward(account) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply + amount; _balances[account] = _balances[account] + amount; stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(account, amount); } function _withdraw(uint256 amount, address account) internal nonReentrant updateReward(account) { require(amount > 0, "Cannot withdraw 0"); _totalSupply = _totalSupply - amount; _balances[account] = _balances[account] - amount; stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(account, amount); } function stake(uint256 amount) external { _stake(amount, msg.sender); } function stakeFor(address account, uint256 amount) external { _stake(amount, account); } function withdraw(uint256 amount) external { _withdraw(amount, msg.sender); } function withdrawFor(address account, uint256 amount) external { require(tx.origin == account, "withdrawFor: account != tx.origin"); _withdraw(amount, account); } function getRewardFor(address account) public nonReentrant updateReward(account) { for (uint256 i; i < rewardTokens.length; i++) { address _rewardsToken = rewardTokens[i]; uint256 reward = rewards[account][_rewardsToken]; if (reward > 0) { rewards[account][_rewardsToken] = 0; IERC20(_rewardsToken).safeTransfer(account, reward); emit RewardPaid(account, _rewardsToken, reward); } } } /* ========== RESTRICTED FUNCTIONS ========== */ function setGovernance(address _governance) public onlyGovernance { governance = _governance; } function notifyRewardAmount(address _rewardsToken, uint256 reward) external updateReward(address(0)) { require(rewardData[_rewardsToken].rewardsDistributor == msg.sender); // handle the transfer of reward tokens via `transferFrom` to reduce the number // of transactions required and ensure correctness of the reward amount IERC20(_rewardsToken).safeTransferFrom(msg.sender, address(this), reward); if (block.timestamp >= rewardData[_rewardsToken].periodFinish) { rewardData[_rewardsToken].rewardRate = reward / rewardData[_rewardsToken].rewardsDuration; } else { uint256 remaining = rewardData[_rewardsToken].periodFinish - block.timestamp; uint256 leftover = remaining * rewardData[_rewardsToken].rewardRate; rewardData[_rewardsToken].rewardRate = (reward + leftover) / rewardData[_rewardsToken].rewardsDuration; } rewardData[_rewardsToken].lastUpdateTime = block.timestamp; rewardData[_rewardsToken].periodFinish = block.timestamp + rewardData[_rewardsToken].rewardsDuration; emit RewardAdded(reward); } function recoverERC20( address tokenAddress, uint256 tokenAmount, address destination ) external onlyGovernance { require(tokenAddress != address(stakingToken), "Cannot withdraw staking token"); require(rewardData[tokenAddress].lastUpdateTime == 0, "Cannot withdraw reward token"); IERC20(tokenAddress).safeTransfer(destination, tokenAmount); emit Recovered(tokenAddress, tokenAmount); } function setRewardsDuration(address _rewardsToken, uint256 _rewardsDuration) external { require(block.timestamp > rewardData[_rewardsToken].periodFinish, "Reward period still active"); require(rewardData[_rewardsToken].rewardsDistributor == msg.sender); require(_rewardsDuration > 0, "Reward duration must be non-zero"); rewardData[_rewardsToken].rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(_rewardsToken, rewardData[_rewardsToken].rewardsDuration); } /* ========== MODIFIERS ========== */ modifier updateReward(address account) { for (uint256 i; i < rewardTokens.length; i++) { address token = rewardTokens[i]; rewardData[token].rewardPerTokenStored = rewardPerToken(token); rewardData[token].lastUpdateTime = lastTimeRewardApplicable(token); if (account != address(0)) { rewards[account][token] = earned(account, token); userRewardPerTokenPaid[account][token] = rewardData[token].rewardPerTokenStored; } } _; } modifier onlyGovernance() { require(msg.sender == governance, "!gov"); _; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, address indexed rewardsToken, uint256 reward); event RewardsDurationUpdated(address token, uint256 newDuration); event Recovered(address token, uint256 amount); }
setRewardsDistributor
function setRewardsDistributor(address _rewardsToken, address _rewardsDistributor) external onlyGovernance { rewardData[_rewardsToken].rewardsDistributor = _rewardsDistributor; }
/* ========== MUTATIVE FUNCTIONS ========== */
Comment
v0.8.2+commit.661d1103
MIT
{ "func_code_index": [ 2719, 2901 ] }
7,499
GaugeMultiRewards
contracts/GaugeMultiRewards.sol
0x3c310fc54c0534dc3c45312934508722284352d1
Solidity
GaugeMultiRewards
contract GaugeMultiRewards is ReentrancyGuard, Pausable { using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ struct Reward { address rewardsDistributor; uint256 rewardsDuration; uint256 periodFinish; uint256 rewardRate; uint256 lastUpdateTime; uint256 rewardPerTokenStored; } IERC20 public stakingToken; mapping(address => Reward) public rewardData; address public governance; address[] public rewardTokens; // user -> reward token -> amount mapping(address => mapping(address => uint256)) public userRewardPerTokenPaid; mapping(address => mapping(address => uint256)) public rewards; uint256 private _totalSupply; uint256 public derivedSupply; mapping(address => uint256) private _balances; mapping(address => uint256) public derivedBalances; /* ========== CONSTRUCTOR ========== */ constructor( address _stakingToken ) { governance = msg.sender; stakingToken = IERC20(_stakingToken); } function addReward( address _rewardsToken, address _rewardsDistributor, uint256 _rewardsDuration ) public onlyGovernance { require(rewardData[_rewardsToken].rewardsDuration == 0); rewardTokens.push(_rewardsToken); rewardData[_rewardsToken].rewardsDistributor = _rewardsDistributor; rewardData[_rewardsToken].rewardsDuration = _rewardsDuration; } /* ========== VIEWS ========== */ function totalSupply() external view returns (uint256) { return _totalSupply; } function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable(address _rewardsToken) public view returns (uint256) { return Math.min(block.timestamp, rewardData[_rewardsToken].periodFinish); } function rewardPerToken(address _rewardsToken) public view returns (uint256) { if (_totalSupply == 0) { return rewardData[_rewardsToken].rewardPerTokenStored; } return rewardData[_rewardsToken].rewardPerTokenStored + (((lastTimeRewardApplicable(_rewardsToken) - rewardData[_rewardsToken].lastUpdateTime) * rewardData[_rewardsToken].rewardRate * 1e6) // from 1e18 / _totalSupply ); } function earned(address _account, address _rewardsToken) public view returns (uint256) { uint256 userBalance = _balances[_account]; return userBalance * (rewardPerToken(_rewardsToken) - userRewardPerTokenPaid[_account][_rewardsToken]) / 1e6 + rewards[_account][_rewardsToken]; } function getRewardForDuration(address _rewardsToken) external view returns (uint256) { return rewardData[_rewardsToken].rewardRate * rewardData[_rewardsToken].rewardsDuration; } /* ========== MUTATIVE FUNCTIONS ========== */ function setRewardsDistributor(address _rewardsToken, address _rewardsDistributor) external onlyGovernance { rewardData[_rewardsToken].rewardsDistributor = _rewardsDistributor; } function _stake(uint256 amount, address account) internal nonReentrant whenNotPaused updateReward(account) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply + amount; _balances[account] = _balances[account] + amount; stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(account, amount); } function _withdraw(uint256 amount, address account) internal nonReentrant updateReward(account) { require(amount > 0, "Cannot withdraw 0"); _totalSupply = _totalSupply - amount; _balances[account] = _balances[account] - amount; stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(account, amount); } function stake(uint256 amount) external { _stake(amount, msg.sender); } function stakeFor(address account, uint256 amount) external { _stake(amount, account); } function withdraw(uint256 amount) external { _withdraw(amount, msg.sender); } function withdrawFor(address account, uint256 amount) external { require(tx.origin == account, "withdrawFor: account != tx.origin"); _withdraw(amount, account); } function getRewardFor(address account) public nonReentrant updateReward(account) { for (uint256 i; i < rewardTokens.length; i++) { address _rewardsToken = rewardTokens[i]; uint256 reward = rewards[account][_rewardsToken]; if (reward > 0) { rewards[account][_rewardsToken] = 0; IERC20(_rewardsToken).safeTransfer(account, reward); emit RewardPaid(account, _rewardsToken, reward); } } } /* ========== RESTRICTED FUNCTIONS ========== */ function setGovernance(address _governance) public onlyGovernance { governance = _governance; } function notifyRewardAmount(address _rewardsToken, uint256 reward) external updateReward(address(0)) { require(rewardData[_rewardsToken].rewardsDistributor == msg.sender); // handle the transfer of reward tokens via `transferFrom` to reduce the number // of transactions required and ensure correctness of the reward amount IERC20(_rewardsToken).safeTransferFrom(msg.sender, address(this), reward); if (block.timestamp >= rewardData[_rewardsToken].periodFinish) { rewardData[_rewardsToken].rewardRate = reward / rewardData[_rewardsToken].rewardsDuration; } else { uint256 remaining = rewardData[_rewardsToken].periodFinish - block.timestamp; uint256 leftover = remaining * rewardData[_rewardsToken].rewardRate; rewardData[_rewardsToken].rewardRate = (reward + leftover) / rewardData[_rewardsToken].rewardsDuration; } rewardData[_rewardsToken].lastUpdateTime = block.timestamp; rewardData[_rewardsToken].periodFinish = block.timestamp + rewardData[_rewardsToken].rewardsDuration; emit RewardAdded(reward); } function recoverERC20( address tokenAddress, uint256 tokenAmount, address destination ) external onlyGovernance { require(tokenAddress != address(stakingToken), "Cannot withdraw staking token"); require(rewardData[tokenAddress].lastUpdateTime == 0, "Cannot withdraw reward token"); IERC20(tokenAddress).safeTransfer(destination, tokenAmount); emit Recovered(tokenAddress, tokenAmount); } function setRewardsDuration(address _rewardsToken, uint256 _rewardsDuration) external { require(block.timestamp > rewardData[_rewardsToken].periodFinish, "Reward period still active"); require(rewardData[_rewardsToken].rewardsDistributor == msg.sender); require(_rewardsDuration > 0, "Reward duration must be non-zero"); rewardData[_rewardsToken].rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(_rewardsToken, rewardData[_rewardsToken].rewardsDuration); } /* ========== MODIFIERS ========== */ modifier updateReward(address account) { for (uint256 i; i < rewardTokens.length; i++) { address token = rewardTokens[i]; rewardData[token].rewardPerTokenStored = rewardPerToken(token); rewardData[token].lastUpdateTime = lastTimeRewardApplicable(token); if (account != address(0)) { rewards[account][token] = earned(account, token); userRewardPerTokenPaid[account][token] = rewardData[token].rewardPerTokenStored; } } _; } modifier onlyGovernance() { require(msg.sender == governance, "!gov"); _; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, address indexed rewardsToken, uint256 reward); event RewardsDurationUpdated(address token, uint256 newDuration); event Recovered(address token, uint256 amount); }
setGovernance
function setGovernance(address _governance) public onlyGovernance { governance = _governance; }
/* ========== RESTRICTED FUNCTIONS ========== */
Comment
v0.8.2+commit.661d1103
MIT
{ "func_code_index": [ 4464, 4563 ] }
7,500
polkaSecure
polkaSecure.sol
0xed05bf1da9b6faab56511e183ef32088fc6dcd99
Solidity
polkaSecure
contract polkaSecure is ERC20Interface, Owned { using SafeMath for uint256; string public constant symbol = "PLS"; string public constant name = "PolkaSecure"; uint256 public constant decimals = 18; uint256 private _totalSupply = 1000000 * 10 ** (decimals); mapping(address => uint256) private balances; mapping(address => mapping(address => uint256)) private allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(address _rewardsWallet) public { owner = 0x0C3B4D8E2eCF2aBBe45842FF1837C000Fd4Bdc08; balances[_rewardsWallet] = balances[_rewardsWallet].add(450000 * 10 ** (decimals)); emit Transfer(address(0), _rewardsWallet, 450000 * 10 ** (decimals)); balances[owner] = balances[owner].add(550000 * 10 ** (decimals)); emit Transfer(address(0), owner, 550000 * 10 ** (decimals)); } /** ERC20Interface function's implementation **/ function totalSupply() public override view returns (uint256){ return _totalSupply; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public override view returns (uint256 balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint256 tokens) public override returns (bool success) { require(address(to) != address(0)); require(balances[msg.sender] >= tokens); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // ------------------------------------------------------------------------ function approve(address spender, uint256 tokens) public override returns (bool success){ allowed[msg.sender][spender] = tokens; emit Approval(msg.sender,spender,tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...) -d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint256 tokens) public override returns (bool success){ require(tokens <= allowed[from][msg.sender]); //check allowance require(balances[from] >= tokens); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public override view returns (uint256 remaining) { return allowed[tokenOwner][spender]; } }
// ---------------------------------------------------------------------------- // 'PolkaSecure' token contract // Symbol : PLS // Name : PolkaSecure // Total supply: 1,000,000 (1 Million) // Decimals : 18 // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
totalSupply
function totalSupply() public override view returns (uint256){ return _totalSupply; }
/** ERC20Interface function's implementation **/
NatSpecMultiLine
v0.6.12+commit.27d51765
Unlicense
ipfs://4372782a57c6a65e3291b8903fdaff2f350b767f645333dcabe49028241bcfcf
{ "func_code_index": [ 1121, 1224 ] }
7,501
polkaSecure
polkaSecure.sol
0xed05bf1da9b6faab56511e183ef32088fc6dcd99
Solidity
polkaSecure
contract polkaSecure is ERC20Interface, Owned { using SafeMath for uint256; string public constant symbol = "PLS"; string public constant name = "PolkaSecure"; uint256 public constant decimals = 18; uint256 private _totalSupply = 1000000 * 10 ** (decimals); mapping(address => uint256) private balances; mapping(address => mapping(address => uint256)) private allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(address _rewardsWallet) public { owner = 0x0C3B4D8E2eCF2aBBe45842FF1837C000Fd4Bdc08; balances[_rewardsWallet] = balances[_rewardsWallet].add(450000 * 10 ** (decimals)); emit Transfer(address(0), _rewardsWallet, 450000 * 10 ** (decimals)); balances[owner] = balances[owner].add(550000 * 10 ** (decimals)); emit Transfer(address(0), owner, 550000 * 10 ** (decimals)); } /** ERC20Interface function's implementation **/ function totalSupply() public override view returns (uint256){ return _totalSupply; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public override view returns (uint256 balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint256 tokens) public override returns (bool success) { require(address(to) != address(0)); require(balances[msg.sender] >= tokens); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // ------------------------------------------------------------------------ function approve(address spender, uint256 tokens) public override returns (bool success){ allowed[msg.sender][spender] = tokens; emit Approval(msg.sender,spender,tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...) -d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint256 tokens) public override returns (bool success){ require(tokens <= allowed[from][msg.sender]); //check allowance require(balances[from] >= tokens); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public override view returns (uint256 remaining) { return allowed[tokenOwner][spender]; } }
// ---------------------------------------------------------------------------- // 'PolkaSecure' token contract // Symbol : PLS // Name : PolkaSecure // Total supply: 1,000,000 (1 Million) // Decimals : 18 // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
balanceOf
function balanceOf(address tokenOwner) public override view returns (uint256 balance) { return balances[tokenOwner]; }
// ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------
LineComment
v0.6.12+commit.27d51765
Unlicense
ipfs://4372782a57c6a65e3291b8903fdaff2f350b767f645333dcabe49028241bcfcf
{ "func_code_index": [ 1444, 1581 ] }
7,502
polkaSecure
polkaSecure.sol
0xed05bf1da9b6faab56511e183ef32088fc6dcd99
Solidity
polkaSecure
contract polkaSecure is ERC20Interface, Owned { using SafeMath for uint256; string public constant symbol = "PLS"; string public constant name = "PolkaSecure"; uint256 public constant decimals = 18; uint256 private _totalSupply = 1000000 * 10 ** (decimals); mapping(address => uint256) private balances; mapping(address => mapping(address => uint256)) private allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(address _rewardsWallet) public { owner = 0x0C3B4D8E2eCF2aBBe45842FF1837C000Fd4Bdc08; balances[_rewardsWallet] = balances[_rewardsWallet].add(450000 * 10 ** (decimals)); emit Transfer(address(0), _rewardsWallet, 450000 * 10 ** (decimals)); balances[owner] = balances[owner].add(550000 * 10 ** (decimals)); emit Transfer(address(0), owner, 550000 * 10 ** (decimals)); } /** ERC20Interface function's implementation **/ function totalSupply() public override view returns (uint256){ return _totalSupply; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public override view returns (uint256 balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint256 tokens) public override returns (bool success) { require(address(to) != address(0)); require(balances[msg.sender] >= tokens); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // ------------------------------------------------------------------------ function approve(address spender, uint256 tokens) public override returns (bool success){ allowed[msg.sender][spender] = tokens; emit Approval(msg.sender,spender,tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...) -d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint256 tokens) public override returns (bool success){ require(tokens <= allowed[from][msg.sender]); //check allowance require(balances[from] >= tokens); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public override view returns (uint256 remaining) { return allowed[tokenOwner][spender]; } }
// ---------------------------------------------------------------------------- // 'PolkaSecure' token contract // Symbol : PLS // Name : PolkaSecure // Total supply: 1,000,000 (1 Million) // Decimals : 18 // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transfer
function transfer(address to, uint256 tokens) public override returns (bool success) { require(address(to) != address(0)); require(balances[msg.sender] >= tokens); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.6.12+commit.27d51765
Unlicense
ipfs://4372782a57c6a65e3291b8903fdaff2f350b767f645333dcabe49028241bcfcf
{ "func_code_index": [ 1925, 2316 ] }
7,503
polkaSecure
polkaSecure.sol
0xed05bf1da9b6faab56511e183ef32088fc6dcd99
Solidity
polkaSecure
contract polkaSecure is ERC20Interface, Owned { using SafeMath for uint256; string public constant symbol = "PLS"; string public constant name = "PolkaSecure"; uint256 public constant decimals = 18; uint256 private _totalSupply = 1000000 * 10 ** (decimals); mapping(address => uint256) private balances; mapping(address => mapping(address => uint256)) private allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(address _rewardsWallet) public { owner = 0x0C3B4D8E2eCF2aBBe45842FF1837C000Fd4Bdc08; balances[_rewardsWallet] = balances[_rewardsWallet].add(450000 * 10 ** (decimals)); emit Transfer(address(0), _rewardsWallet, 450000 * 10 ** (decimals)); balances[owner] = balances[owner].add(550000 * 10 ** (decimals)); emit Transfer(address(0), owner, 550000 * 10 ** (decimals)); } /** ERC20Interface function's implementation **/ function totalSupply() public override view returns (uint256){ return _totalSupply; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public override view returns (uint256 balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint256 tokens) public override returns (bool success) { require(address(to) != address(0)); require(balances[msg.sender] >= tokens); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // ------------------------------------------------------------------------ function approve(address spender, uint256 tokens) public override returns (bool success){ allowed[msg.sender][spender] = tokens; emit Approval(msg.sender,spender,tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...) -d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint256 tokens) public override returns (bool success){ require(tokens <= allowed[from][msg.sender]); //check allowance require(balances[from] >= tokens); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public override view returns (uint256 remaining) { return allowed[tokenOwner][spender]; } }
// ---------------------------------------------------------------------------- // 'PolkaSecure' token contract // Symbol : PLS // Name : PolkaSecure // Total supply: 1,000,000 (1 Million) // Decimals : 18 // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
approve
function approve(address spender, uint256 tokens) public override returns (bool success){ allowed[msg.sender][spender] = tokens; emit Approval(msg.sender,spender,tokens); return true; }
// ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // ------------------------------------------------------------------------
LineComment
v0.6.12+commit.27d51765
Unlicense
ipfs://4372782a57c6a65e3291b8903fdaff2f350b767f645333dcabe49028241bcfcf
{ "func_code_index": [ 2596, 2838 ] }
7,504
polkaSecure
polkaSecure.sol
0xed05bf1da9b6faab56511e183ef32088fc6dcd99
Solidity
polkaSecure
contract polkaSecure is ERC20Interface, Owned { using SafeMath for uint256; string public constant symbol = "PLS"; string public constant name = "PolkaSecure"; uint256 public constant decimals = 18; uint256 private _totalSupply = 1000000 * 10 ** (decimals); mapping(address => uint256) private balances; mapping(address => mapping(address => uint256)) private allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(address _rewardsWallet) public { owner = 0x0C3B4D8E2eCF2aBBe45842FF1837C000Fd4Bdc08; balances[_rewardsWallet] = balances[_rewardsWallet].add(450000 * 10 ** (decimals)); emit Transfer(address(0), _rewardsWallet, 450000 * 10 ** (decimals)); balances[owner] = balances[owner].add(550000 * 10 ** (decimals)); emit Transfer(address(0), owner, 550000 * 10 ** (decimals)); } /** ERC20Interface function's implementation **/ function totalSupply() public override view returns (uint256){ return _totalSupply; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public override view returns (uint256 balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint256 tokens) public override returns (bool success) { require(address(to) != address(0)); require(balances[msg.sender] >= tokens); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // ------------------------------------------------------------------------ function approve(address spender, uint256 tokens) public override returns (bool success){ allowed[msg.sender][spender] = tokens; emit Approval(msg.sender,spender,tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...) -d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint256 tokens) public override returns (bool success){ require(tokens <= allowed[from][msg.sender]); //check allowance require(balances[from] >= tokens); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public override view returns (uint256 remaining) { return allowed[tokenOwner][spender]; } }
// ---------------------------------------------------------------------------- // 'PolkaSecure' token contract // Symbol : PLS // Name : PolkaSecure // Total supply: 1,000,000 (1 Million) // Decimals : 18 // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transferFrom
function transferFrom(address from, address to, uint256 tokens) public override returns (bool success){ require(tokens <= allowed[from][msg.sender]); //check allowance require(balances[from] >= tokens); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; }
// ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...) -d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------
LineComment
v0.6.12+commit.27d51765
Unlicense
ipfs://4372782a57c6a65e3291b8903fdaff2f350b767f645333dcabe49028241bcfcf
{ "func_code_index": [ 3375, 3872 ] }
7,505
polkaSecure
polkaSecure.sol
0xed05bf1da9b6faab56511e183ef32088fc6dcd99
Solidity
polkaSecure
contract polkaSecure is ERC20Interface, Owned { using SafeMath for uint256; string public constant symbol = "PLS"; string public constant name = "PolkaSecure"; uint256 public constant decimals = 18; uint256 private _totalSupply = 1000000 * 10 ** (decimals); mapping(address => uint256) private balances; mapping(address => mapping(address => uint256)) private allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(address _rewardsWallet) public { owner = 0x0C3B4D8E2eCF2aBBe45842FF1837C000Fd4Bdc08; balances[_rewardsWallet] = balances[_rewardsWallet].add(450000 * 10 ** (decimals)); emit Transfer(address(0), _rewardsWallet, 450000 * 10 ** (decimals)); balances[owner] = balances[owner].add(550000 * 10 ** (decimals)); emit Transfer(address(0), owner, 550000 * 10 ** (decimals)); } /** ERC20Interface function's implementation **/ function totalSupply() public override view returns (uint256){ return _totalSupply; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public override view returns (uint256 balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint256 tokens) public override returns (bool success) { require(address(to) != address(0)); require(balances[msg.sender] >= tokens); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // ------------------------------------------------------------------------ function approve(address spender, uint256 tokens) public override returns (bool success){ allowed[msg.sender][spender] = tokens; emit Approval(msg.sender,spender,tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...) -d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint256 tokens) public override returns (bool success){ require(tokens <= allowed[from][msg.sender]); //check allowance require(balances[from] >= tokens); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public override view returns (uint256 remaining) { return allowed[tokenOwner][spender]; } }
// ---------------------------------------------------------------------------- // 'PolkaSecure' token contract // Symbol : PLS // Name : PolkaSecure // Total supply: 1,000,000 (1 Million) // Decimals : 18 // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
allowance
function allowance(address tokenOwner, address spender) public override view returns (uint256 remaining) { return allowed[tokenOwner][spender]; }
// ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------
LineComment
v0.6.12+commit.27d51765
Unlicense
ipfs://4372782a57c6a65e3291b8903fdaff2f350b767f645333dcabe49028241bcfcf
{ "func_code_index": [ 4157, 4321 ] }
7,506