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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CoalitionCrew | CoalitionCrew.sol | 0x529a4e15b3ce13523417f945ecd0959ff71e0a9e | Solidity | ERC721 | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` 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 tokenId
) internal virtual {}
} | /**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/ | NatSpecMultiLine | _transfer | function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
| /**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://cd75f2b24ba4df97a9f8e86dd1338eb11171136878dcd55a6363260d602d5e44 | {
"func_code_index": [
10155,
10738
]
} | 6,507 |
CoalitionCrew | CoalitionCrew.sol | 0x529a4e15b3ce13523417f945ecd0959ff71e0a9e | Solidity | ERC721 | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` 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 tokenId
) internal virtual {}
} | /**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/ | NatSpecMultiLine | _approve | function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
| /**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://cd75f2b24ba4df97a9f8e86dd1338eb11171136878dcd55a6363260d602d5e44 | {
"func_code_index": [
10851,
11030
]
} | 6,508 |
CoalitionCrew | CoalitionCrew.sol | 0x529a4e15b3ce13523417f945ecd0959ff71e0a9e | Solidity | ERC721 | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` 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 tokenId
) internal virtual {}
} | /**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/ | NatSpecMultiLine | _checkOnERC721Received | function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
| /**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://cd75f2b24ba4df97a9f8e86dd1338eb11171136878dcd55a6363260d602d5e44 | {
"func_code_index": [
11590,
12394
]
} | 6,509 |
CoalitionCrew | CoalitionCrew.sol | 0x529a4e15b3ce13523417f945ecd0959ff71e0a9e | Solidity | ERC721 | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` 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 tokenId
) internal virtual {}
} | /**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/ | NatSpecMultiLine | _beforeTokenTransfer | function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
| /**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://cd75f2b24ba4df97a9f8e86dd1338eb11171136878dcd55a6363260d602d5e44 | {
"func_code_index": [
12961,
13092
]
} | 6,510 |
Workwares | contracts/Workwares.sol | 0x2f69dedd3f47968c504b8e853131a54662a34b98 | Solidity | Workwares | contract Workwares is AbstractERC1155 {
uint256 constant MAX_SUPPLY_WHITE = 323;
uint256 constant MAX_SUPPLY_GOLD = 10;
uint256 constant MAX_RESERVED = 5;
uint256 public presalePrice = 0.1 ether;
uint256 public mintPrice = 0.28 ether;
uint256 public presaleActive = 0;
uint256 public saleActive = 0;
uint256 public numWhiteMints = 0;
uint256 public numGoldMints = 0;
// change to hosted folder
string baseURI = "http://bayc1.mintworkwares.io/metadata/";
mapping(address => uint256) public numMints;
mapping(address => uint256) public whitelist;
mapping(address => uint256) public numReserved;
constructor() ERC1155(baseURI) {
name_ = "Workwares";
symbol_ = "BAYC1";
}
function setPrice(uint256 _price) external onlyOwner {
require(_price > 0, "Price cannot be 0");
mintPrice = _price;
}
function toggleSaleState(uint256 state) external onlyOwner {
saleActive = state;
}
function togglePresaleState(uint256 state) external onlyOwner {
presaleActive = state;
}
function reserveTokens(uint256 amount) external onlyOwner {
require(numReserved[msg.sender] + amount <= MAX_RESERVED, "Would exceed max reserved tokens");
numReserved[msg.sender] += amount;
numWhiteMints += amount;
_mint(msg.sender, 0, amount, "");
}
function withdraw() public payable onlyOwner {
uint256 balance = address(this).balance;
address acct1 = 0x011C2799d043D2D384Ac19aA3cF0567021Cd9Fa4;
address studio = 0x388CcBf8c1A37F444DcFF6eDE0014DfA85BeDC1B;
uint256 acct1_share = balance / 100 * 85;
uint256 studio_share = balance / 100 * 15;
// transfer eth to addresses
payable(studio).transfer(studio_share);
payable(acct1).transfer(acct1_share);
}
function addWhitelist(address[] calldata addresses) external onlyOwner {
for (uint256 i = 0; i < addresses.length; i++) {
whitelist[addresses[i]] = 1;
}
}
// presale mint
function presalePurchase() external payable {
require(presaleActive == 1, "Presale closed");
require(whitelist[msg.sender] == 1, "Address not on whitelist");
require(msg.value == presalePrice, "Incorrect payment");
uint256 nonce = 0;
uint256 mintIndex = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, nonce))) % 30;
whitelist[msg.sender] = 0;
numMints[msg.sender]++;
if (mintIndex == 0 && numGoldMints < MAX_SUPPLY_GOLD) {
numGoldMints++;
_mint(msg.sender, 1, 1, "");
} else {
numWhiteMints++;
_mint(msg.sender, 0, 1, "");
}
}
// public mint
function purchase() external payable {
require(saleActive == 1, "Sale currently closed");
require(numMints[msg.sender] < 10 , "max tx amount exceeded");
require(numWhiteMints < MAX_SUPPLY_WHITE || numGoldMints < MAX_SUPPLY_GOLD, "Transaction would exceed maximum supply");
require(msg.value == mintPrice, "Incorrect payment");
if (balanceOf(msg.sender, 1) >= 1 && numWhiteMints == MAX_SUPPLY_WHITE) {
revert("Not enough tokens remaining to fulfill transaction");
}
uint256 nonce = 0;
uint256 mintIndex = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, nonce))) % 30;
numMints[msg.sender]++;
if (mintIndex == 0 && balanceOf(msg.sender, 1) == 0 && numGoldMints < MAX_SUPPLY_GOLD) {
// mint gold
numGoldMints++;
_mint(msg.sender, 1, 1, "");
} else if (mintIndex != 0 && numWhiteMints == MAX_SUPPLY_WHITE) {
numGoldMints++;
_mint(msg.sender, 1, 1, "");
} else {
// mint white
numWhiteMints++;
_mint(msg.sender, 0, 1, "");
}
}
function redeemToken(uint256 id) external {
require(balanceOf(msg.sender, id) > 0, "RedeemToken: must have a token to redeem");
_burn(msg.sender, id, 1);
_mint(msg.sender, id+2, 1, "");
}
function uri(uint256 _id) public view override returns (string memory) {
require(exists(_id), "URI: nonexistent token");
return string(abi.encodePacked(super.uri(_id), Strings.toString(_id)));
}
// burn function
function burn(
address account,
uint256 id,
uint256 value
) public virtual override {
require(account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_burn(account, id, value);
}
} | presalePurchase | function presalePurchase() external payable {
require(presaleActive == 1, "Presale closed");
require(whitelist[msg.sender] == 1, "Address not on whitelist");
require(msg.value == presalePrice, "Incorrect payment");
uint256 nonce = 0;
uint256 mintIndex = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, nonce))) % 30;
whitelist[msg.sender] = 0;
numMints[msg.sender]++;
if (mintIndex == 0 && numGoldMints < MAX_SUPPLY_GOLD) {
numGoldMints++;
_mint(msg.sender, 1, 1, "");
} else {
numWhiteMints++;
_mint(msg.sender, 0, 1, "");
}
}
| // presale mint | LineComment | v0.8.7+commit.e28d00a7 | MIT | ipfs://f4d2e2633e639767bd36185738906d933d649ba9241fbcde25b4b84fe6c096c3 | {
"func_code_index": [
2151,
2893
]
} | 6,511 |
||
Workwares | contracts/Workwares.sol | 0x2f69dedd3f47968c504b8e853131a54662a34b98 | Solidity | Workwares | contract Workwares is AbstractERC1155 {
uint256 constant MAX_SUPPLY_WHITE = 323;
uint256 constant MAX_SUPPLY_GOLD = 10;
uint256 constant MAX_RESERVED = 5;
uint256 public presalePrice = 0.1 ether;
uint256 public mintPrice = 0.28 ether;
uint256 public presaleActive = 0;
uint256 public saleActive = 0;
uint256 public numWhiteMints = 0;
uint256 public numGoldMints = 0;
// change to hosted folder
string baseURI = "http://bayc1.mintworkwares.io/metadata/";
mapping(address => uint256) public numMints;
mapping(address => uint256) public whitelist;
mapping(address => uint256) public numReserved;
constructor() ERC1155(baseURI) {
name_ = "Workwares";
symbol_ = "BAYC1";
}
function setPrice(uint256 _price) external onlyOwner {
require(_price > 0, "Price cannot be 0");
mintPrice = _price;
}
function toggleSaleState(uint256 state) external onlyOwner {
saleActive = state;
}
function togglePresaleState(uint256 state) external onlyOwner {
presaleActive = state;
}
function reserveTokens(uint256 amount) external onlyOwner {
require(numReserved[msg.sender] + amount <= MAX_RESERVED, "Would exceed max reserved tokens");
numReserved[msg.sender] += amount;
numWhiteMints += amount;
_mint(msg.sender, 0, amount, "");
}
function withdraw() public payable onlyOwner {
uint256 balance = address(this).balance;
address acct1 = 0x011C2799d043D2D384Ac19aA3cF0567021Cd9Fa4;
address studio = 0x388CcBf8c1A37F444DcFF6eDE0014DfA85BeDC1B;
uint256 acct1_share = balance / 100 * 85;
uint256 studio_share = balance / 100 * 15;
// transfer eth to addresses
payable(studio).transfer(studio_share);
payable(acct1).transfer(acct1_share);
}
function addWhitelist(address[] calldata addresses) external onlyOwner {
for (uint256 i = 0; i < addresses.length; i++) {
whitelist[addresses[i]] = 1;
}
}
// presale mint
function presalePurchase() external payable {
require(presaleActive == 1, "Presale closed");
require(whitelist[msg.sender] == 1, "Address not on whitelist");
require(msg.value == presalePrice, "Incorrect payment");
uint256 nonce = 0;
uint256 mintIndex = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, nonce))) % 30;
whitelist[msg.sender] = 0;
numMints[msg.sender]++;
if (mintIndex == 0 && numGoldMints < MAX_SUPPLY_GOLD) {
numGoldMints++;
_mint(msg.sender, 1, 1, "");
} else {
numWhiteMints++;
_mint(msg.sender, 0, 1, "");
}
}
// public mint
function purchase() external payable {
require(saleActive == 1, "Sale currently closed");
require(numMints[msg.sender] < 10 , "max tx amount exceeded");
require(numWhiteMints < MAX_SUPPLY_WHITE || numGoldMints < MAX_SUPPLY_GOLD, "Transaction would exceed maximum supply");
require(msg.value == mintPrice, "Incorrect payment");
if (balanceOf(msg.sender, 1) >= 1 && numWhiteMints == MAX_SUPPLY_WHITE) {
revert("Not enough tokens remaining to fulfill transaction");
}
uint256 nonce = 0;
uint256 mintIndex = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, nonce))) % 30;
numMints[msg.sender]++;
if (mintIndex == 0 && balanceOf(msg.sender, 1) == 0 && numGoldMints < MAX_SUPPLY_GOLD) {
// mint gold
numGoldMints++;
_mint(msg.sender, 1, 1, "");
} else if (mintIndex != 0 && numWhiteMints == MAX_SUPPLY_WHITE) {
numGoldMints++;
_mint(msg.sender, 1, 1, "");
} else {
// mint white
numWhiteMints++;
_mint(msg.sender, 0, 1, "");
}
}
function redeemToken(uint256 id) external {
require(balanceOf(msg.sender, id) > 0, "RedeemToken: must have a token to redeem");
_burn(msg.sender, id, 1);
_mint(msg.sender, id+2, 1, "");
}
function uri(uint256 _id) public view override returns (string memory) {
require(exists(_id), "URI: nonexistent token");
return string(abi.encodePacked(super.uri(_id), Strings.toString(_id)));
}
// burn function
function burn(
address account,
uint256 id,
uint256 value
) public virtual override {
require(account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_burn(account, id, value);
}
} | purchase | function purchase() external payable {
require(saleActive == 1, "Sale currently closed");
require(numMints[msg.sender] < 10 , "max tx amount exceeded");
require(numWhiteMints < MAX_SUPPLY_WHITE || numGoldMints < MAX_SUPPLY_GOLD, "Transaction would exceed maximum supply");
require(msg.value == mintPrice, "Incorrect payment");
if (balanceOf(msg.sender, 1) >= 1 && numWhiteMints == MAX_SUPPLY_WHITE) {
revert("Not enough tokens remaining to fulfill transaction");
}
uint256 nonce = 0;
uint256 mintIndex = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, nonce))) % 30;
numMints[msg.sender]++;
if (mintIndex == 0 && balanceOf(msg.sender, 1) == 0 && numGoldMints < MAX_SUPPLY_GOLD) {
// mint gold
numGoldMints++;
_mint(msg.sender, 1, 1, "");
} else if (mintIndex != 0 && numWhiteMints == MAX_SUPPLY_WHITE) {
numGoldMints++;
_mint(msg.sender, 1, 1, "");
} else {
// mint white
numWhiteMints++;
_mint(msg.sender, 0, 1, "");
}
}
| // public mint | LineComment | v0.8.7+commit.e28d00a7 | MIT | ipfs://f4d2e2633e639767bd36185738906d933d649ba9241fbcde25b4b84fe6c096c3 | {
"func_code_index": [
2916,
4120
]
} | 6,512 |
||
Workwares | contracts/Workwares.sol | 0x2f69dedd3f47968c504b8e853131a54662a34b98 | Solidity | Workwares | contract Workwares is AbstractERC1155 {
uint256 constant MAX_SUPPLY_WHITE = 323;
uint256 constant MAX_SUPPLY_GOLD = 10;
uint256 constant MAX_RESERVED = 5;
uint256 public presalePrice = 0.1 ether;
uint256 public mintPrice = 0.28 ether;
uint256 public presaleActive = 0;
uint256 public saleActive = 0;
uint256 public numWhiteMints = 0;
uint256 public numGoldMints = 0;
// change to hosted folder
string baseURI = "http://bayc1.mintworkwares.io/metadata/";
mapping(address => uint256) public numMints;
mapping(address => uint256) public whitelist;
mapping(address => uint256) public numReserved;
constructor() ERC1155(baseURI) {
name_ = "Workwares";
symbol_ = "BAYC1";
}
function setPrice(uint256 _price) external onlyOwner {
require(_price > 0, "Price cannot be 0");
mintPrice = _price;
}
function toggleSaleState(uint256 state) external onlyOwner {
saleActive = state;
}
function togglePresaleState(uint256 state) external onlyOwner {
presaleActive = state;
}
function reserveTokens(uint256 amount) external onlyOwner {
require(numReserved[msg.sender] + amount <= MAX_RESERVED, "Would exceed max reserved tokens");
numReserved[msg.sender] += amount;
numWhiteMints += amount;
_mint(msg.sender, 0, amount, "");
}
function withdraw() public payable onlyOwner {
uint256 balance = address(this).balance;
address acct1 = 0x011C2799d043D2D384Ac19aA3cF0567021Cd9Fa4;
address studio = 0x388CcBf8c1A37F444DcFF6eDE0014DfA85BeDC1B;
uint256 acct1_share = balance / 100 * 85;
uint256 studio_share = balance / 100 * 15;
// transfer eth to addresses
payable(studio).transfer(studio_share);
payable(acct1).transfer(acct1_share);
}
function addWhitelist(address[] calldata addresses) external onlyOwner {
for (uint256 i = 0; i < addresses.length; i++) {
whitelist[addresses[i]] = 1;
}
}
// presale mint
function presalePurchase() external payable {
require(presaleActive == 1, "Presale closed");
require(whitelist[msg.sender] == 1, "Address not on whitelist");
require(msg.value == presalePrice, "Incorrect payment");
uint256 nonce = 0;
uint256 mintIndex = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, nonce))) % 30;
whitelist[msg.sender] = 0;
numMints[msg.sender]++;
if (mintIndex == 0 && numGoldMints < MAX_SUPPLY_GOLD) {
numGoldMints++;
_mint(msg.sender, 1, 1, "");
} else {
numWhiteMints++;
_mint(msg.sender, 0, 1, "");
}
}
// public mint
function purchase() external payable {
require(saleActive == 1, "Sale currently closed");
require(numMints[msg.sender] < 10 , "max tx amount exceeded");
require(numWhiteMints < MAX_SUPPLY_WHITE || numGoldMints < MAX_SUPPLY_GOLD, "Transaction would exceed maximum supply");
require(msg.value == mintPrice, "Incorrect payment");
if (balanceOf(msg.sender, 1) >= 1 && numWhiteMints == MAX_SUPPLY_WHITE) {
revert("Not enough tokens remaining to fulfill transaction");
}
uint256 nonce = 0;
uint256 mintIndex = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, nonce))) % 30;
numMints[msg.sender]++;
if (mintIndex == 0 && balanceOf(msg.sender, 1) == 0 && numGoldMints < MAX_SUPPLY_GOLD) {
// mint gold
numGoldMints++;
_mint(msg.sender, 1, 1, "");
} else if (mintIndex != 0 && numWhiteMints == MAX_SUPPLY_WHITE) {
numGoldMints++;
_mint(msg.sender, 1, 1, "");
} else {
// mint white
numWhiteMints++;
_mint(msg.sender, 0, 1, "");
}
}
function redeemToken(uint256 id) external {
require(balanceOf(msg.sender, id) > 0, "RedeemToken: must have a token to redeem");
_burn(msg.sender, id, 1);
_mint(msg.sender, id+2, 1, "");
}
function uri(uint256 _id) public view override returns (string memory) {
require(exists(_id), "URI: nonexistent token");
return string(abi.encodePacked(super.uri(_id), Strings.toString(_id)));
}
// burn function
function burn(
address account,
uint256 id,
uint256 value
) public virtual override {
require(account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_burn(account, id, value);
}
} | burn | function burn(
address account,
uint256 id,
uint256 value
) public virtual override {
require(account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_burn(account, id, value);
}
| // burn function | LineComment | v0.8.7+commit.e28d00a7 | MIT | ipfs://f4d2e2633e639767bd36185738906d933d649ba9241fbcde25b4b84fe6c096c3 | {
"func_code_index": [
4611,
4932
]
} | 6,513 |
||
TEST365 | TEST365.sol | 0x4c51ff20f1fd17732344daa97207cc728cb5b28d | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
| /**
* @dev Multiplies two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.5.0+commit.1d4f565a | bzzr://319500f9d32948c6fd279da92253229331d61f406ccdd50d610bdcf45cb4f197 | {
"func_code_index": [
89,
268
]
} | 6,514 |
|||
BlocksizeCapital | BlocksizeCapital.sol | 0xcfd2f2d1f786b2c2f3e14379ae57fb52979196b3 | Solidity | BlocksizeCapital | contract BlocksizeCapital is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "BKC";
name = "Blocksize Capital";
decimals = 15;
_totalSupply = 10000000000000000000000;
balances[0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a] = _totalSupply;
emit Transfer(address(0), 0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
//
// ------------------------------------------------------------------------
function () public payable {
revert();
}
//
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token
// ---------------------------------------------------------------------------- | LineComment | totalSupply | function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
| // ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://f29d8cf52b473c24cb157329a4bbc329897dc3e0f24dd379ddc36d58ec74505b | {
"func_code_index": [
992,
1113
]
} | 6,515 |
BlocksizeCapital | BlocksizeCapital.sol | 0xcfd2f2d1f786b2c2f3e14379ae57fb52979196b3 | Solidity | BlocksizeCapital | contract BlocksizeCapital is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "BKC";
name = "Blocksize Capital";
decimals = 15;
_totalSupply = 10000000000000000000000;
balances[0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a] = _totalSupply;
emit Transfer(address(0), 0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
//
// ------------------------------------------------------------------------
function () public payable {
revert();
}
//
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token
// ---------------------------------------------------------------------------- | LineComment | balanceOf | function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
| // ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://f29d8cf52b473c24cb157329a4bbc329897dc3e0f24dd379ddc36d58ec74505b | {
"func_code_index": [
1289,
1418
]
} | 6,516 |
BlocksizeCapital | BlocksizeCapital.sol | 0xcfd2f2d1f786b2c2f3e14379ae57fb52979196b3 | Solidity | BlocksizeCapital | contract BlocksizeCapital is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "BKC";
name = "Blocksize Capital";
decimals = 15;
_totalSupply = 10000000000000000000000;
balances[0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a] = _totalSupply;
emit Transfer(address(0), 0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
//
// ------------------------------------------------------------------------
function () public payable {
revert();
}
//
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token
// ---------------------------------------------------------------------------- | LineComment | transfer | function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
| // ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://f29d8cf52b473c24cb157329a4bbc329897dc3e0f24dd379ddc36d58ec74505b | {
"func_code_index": [
1512,
1794
]
} | 6,517 |
BlocksizeCapital | BlocksizeCapital.sol | 0xcfd2f2d1f786b2c2f3e14379ae57fb52979196b3 | Solidity | BlocksizeCapital | contract BlocksizeCapital is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "BKC";
name = "Blocksize Capital";
decimals = 15;
_totalSupply = 10000000000000000000000;
balances[0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a] = _totalSupply;
emit Transfer(address(0), 0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
//
// ------------------------------------------------------------------------
function () public payable {
revert();
}
//
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token
// ---------------------------------------------------------------------------- | LineComment | approve | function approve(address spender, uint tokens) public 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.4.24+commit.e67f0147 | None | bzzr://f29d8cf52b473c24cb157329a4bbc329897dc3e0f24dd379ddc36d58ec74505b | {
"func_code_index": [
2080,
2293
]
} | 6,518 |
BlocksizeCapital | BlocksizeCapital.sol | 0xcfd2f2d1f786b2c2f3e14379ae57fb52979196b3 | Solidity | BlocksizeCapital | contract BlocksizeCapital is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "BKC";
name = "Blocksize Capital";
decimals = 15;
_totalSupply = 10000000000000000000000;
balances[0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a] = _totalSupply;
emit Transfer(address(0), 0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
//
// ------------------------------------------------------------------------
function () public payable {
revert();
}
//
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token
// ---------------------------------------------------------------------------- | LineComment | transferFrom | function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
| // ------------------------------------------------------------------------
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://f29d8cf52b473c24cb157329a4bbc329897dc3e0f24dd379ddc36d58ec74505b | {
"func_code_index": [
2466,
2829
]
} | 6,519 |
BlocksizeCapital | BlocksizeCapital.sol | 0xcfd2f2d1f786b2c2f3e14379ae57fb52979196b3 | Solidity | BlocksizeCapital | contract BlocksizeCapital is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "BKC";
name = "Blocksize Capital";
decimals = 15;
_totalSupply = 10000000000000000000000;
balances[0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a] = _totalSupply;
emit Transfer(address(0), 0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
//
// ------------------------------------------------------------------------
function () public payable {
revert();
}
//
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token
// ---------------------------------------------------------------------------- | LineComment | allowance | function allowance(address tokenOwner, address spender) public constant returns (uint 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.4.24+commit.e67f0147 | None | bzzr://f29d8cf52b473c24cb157329a4bbc329897dc3e0f24dd379ddc36d58ec74505b | {
"func_code_index": [
3112,
3268
]
} | 6,520 |
BlocksizeCapital | BlocksizeCapital.sol | 0xcfd2f2d1f786b2c2f3e14379ae57fb52979196b3 | Solidity | BlocksizeCapital | contract BlocksizeCapital is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "BKC";
name = "Blocksize Capital";
decimals = 15;
_totalSupply = 10000000000000000000000;
balances[0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a] = _totalSupply;
emit Transfer(address(0), 0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
//
// ------------------------------------------------------------------------
function () public payable {
revert();
}
//
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token
// ---------------------------------------------------------------------------- | LineComment | approveAndCall | function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
| // ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://f29d8cf52b473c24cb157329a4bbc329897dc3e0f24dd379ddc36d58ec74505b | {
"func_code_index": [
3444,
3766
]
} | 6,521 |
BlocksizeCapital | BlocksizeCapital.sol | 0xcfd2f2d1f786b2c2f3e14379ae57fb52979196b3 | Solidity | BlocksizeCapital | contract BlocksizeCapital is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "BKC";
name = "Blocksize Capital";
decimals = 15;
_totalSupply = 10000000000000000000000;
balances[0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a] = _totalSupply;
emit Transfer(address(0), 0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
//
// ------------------------------------------------------------------------
function () public payable {
revert();
}
//
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token
// ---------------------------------------------------------------------------- | LineComment | function () public payable {
revert();
}
| //
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://f29d8cf52b473c24cb157329a4bbc329897dc3e0f24dd379ddc36d58ec74505b | {
"func_code_index": [
3859,
3918
]
} | 6,522 |
|
BlocksizeCapital | BlocksizeCapital.sol | 0xcfd2f2d1f786b2c2f3e14379ae57fb52979196b3 | Solidity | BlocksizeCapital | contract BlocksizeCapital is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "BKC";
name = "Blocksize Capital";
decimals = 15;
_totalSupply = 10000000000000000000000;
balances[0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a] = _totalSupply;
emit Transfer(address(0), 0xA589dF589a6cADB3ABae60C86dc24562cCcAaa8a, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], 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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
//
// ------------------------------------------------------------------------
function () public payable {
revert();
}
//
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token
// ---------------------------------------------------------------------------- | LineComment | transferAnyERC20Token | function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
| //
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | None | bzzr://f29d8cf52b473c24cb157329a4bbc329897dc3e0f24dd379ddc36d58ec74505b | {
"func_code_index": [
4013,
4202
]
} | 6,523 |
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
| /**
* @dev Multiplies two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
89,
476
]
} | 6,524 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
| /**
* @dev Integer division of two numbers, truncating the quotient.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
560,
840
]
} | 6,525 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| /**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
954,
1070
]
} | 6,526 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | add | function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
| /**
* @dev Adds two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
1134,
1264
]
} | 6,527 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
} | renounceOwnership | function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
| /**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
815,
932
]
} | 6,528 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
} | transferOwnership | function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
1097,
1205
]
} | 6,529 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
} | _transferOwnership | function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
| /**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
1343,
1521
]
} | 6,530 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | Roles | library Roles {
struct Role {
mapping (address => bool) bearer;
}
/**
* @dev give an address access to this role
*/
function add(Role storage role, address addr)
internal
{
role.bearer[addr] = true;
}
/**
* @dev remove an address' access to this role
*/
function remove(Role storage role, address addr)
internal
{
role.bearer[addr] = false;
}
/**
* @dev check if an address has this role
* // reverts
*/
function check(Role storage role, address addr)
view
internal
{
require(has(role, addr));
}
/**
* @dev check if an address has this role
* @return bool
*/
function has(Role storage role, address addr)
view
internal
returns (bool)
{
return role.bearer[addr];
}
} | add | function add(Role storage role, address addr)
internal
{
role.bearer[addr] = true;
}
| /**
* @dev give an address access to this role
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
141,
244
]
} | 6,531 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | Roles | library Roles {
struct Role {
mapping (address => bool) bearer;
}
/**
* @dev give an address access to this role
*/
function add(Role storage role, address addr)
internal
{
role.bearer[addr] = true;
}
/**
* @dev remove an address' access to this role
*/
function remove(Role storage role, address addr)
internal
{
role.bearer[addr] = false;
}
/**
* @dev check if an address has this role
* // reverts
*/
function check(Role storage role, address addr)
view
internal
{
require(has(role, addr));
}
/**
* @dev check if an address has this role
* @return bool
*/
function has(Role storage role, address addr)
view
internal
returns (bool)
{
return role.bearer[addr];
}
} | remove | function remove(Role storage role, address addr)
internal
{
role.bearer[addr] = false;
}
| /**
* @dev remove an address' access to this role
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
311,
418
]
} | 6,532 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | Roles | library Roles {
struct Role {
mapping (address => bool) bearer;
}
/**
* @dev give an address access to this role
*/
function add(Role storage role, address addr)
internal
{
role.bearer[addr] = true;
}
/**
* @dev remove an address' access to this role
*/
function remove(Role storage role, address addr)
internal
{
role.bearer[addr] = false;
}
/**
* @dev check if an address has this role
* // reverts
*/
function check(Role storage role, address addr)
view
internal
{
require(has(role, addr));
}
/**
* @dev check if an address has this role
* @return bool
*/
function has(Role storage role, address addr)
view
internal
returns (bool)
{
return role.bearer[addr];
}
} | check | function check(Role storage role, address addr)
view
internal
{
require(has(role, addr));
}
| /**
* @dev check if an address has this role
* // reverts
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
497,
612
]
} | 6,533 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | Roles | library Roles {
struct Role {
mapping (address => bool) bearer;
}
/**
* @dev give an address access to this role
*/
function add(Role storage role, address addr)
internal
{
role.bearer[addr] = true;
}
/**
* @dev remove an address' access to this role
*/
function remove(Role storage role, address addr)
internal
{
role.bearer[addr] = false;
}
/**
* @dev check if an address has this role
* // reverts
*/
function check(Role storage role, address addr)
view
internal
{
require(has(role, addr));
}
/**
* @dev check if an address has this role
* @return bool
*/
function has(Role storage role, address addr)
view
internal
returns (bool)
{
return role.bearer[addr];
}
} | has | function has(Role storage role, address addr)
view
internal
returns (bool)
{
return role.bearer[addr];
}
| /**
* @dev check if an address has this role
* @return bool
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
693,
826
]
} | 6,534 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @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) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @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) public view returns (uint256) {
return balances[_owner];
}
} | totalSupply | function totalSupply() public view returns (uint256) {
return totalSupply_;
}
| /**
* @dev Total number of tokens in existence
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
199,
287
]
} | 6,535 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @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) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @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) public view returns (uint256) {
return balances[_owner];
}
} | transfer | function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
| /**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
445,
777
]
} | 6,536 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @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) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @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) public view returns (uint256) {
return balances[_owner];
}
} | balanceOf | function balanceOf(address _owner) public view returns (uint256) {
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.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
983,
1087
]
} | 6,537 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | MultiSigTransfer | contract MultiSigTransfer is Ownable {
string public name = "MultiSigTransfer";
string public symbol = "MST";
bool public complete = false;
bool public denied = false;
uint32 public quantity;
address public targetAddress;
address public requesterAddress;
/**
* @dev The multisig transfer contract ensures that no single administrator can
* KVTs without approval of another administrator
* @param _quantity The number of KVT to transfer
* @param _targetAddress The receiver of the KVTs
* @param _requesterAddress The administrator requesting the transfer
*/
constructor(
uint32 _quantity,
address _targetAddress,
address _requesterAddress
) public {
quantity = _quantity;
targetAddress = _targetAddress;
requesterAddress = _requesterAddress;
}
/**
* @dev Mark the transfer as approved / complete
*/
function approveTransfer() public onlyOwner {
require(denied == false, "cannot approve a denied transfer");
require(complete == false, "cannot approve a complete transfer");
complete = true;
}
/**
* @dev Mark the transfer as denied
*/
function denyTransfer() public onlyOwner {
require(denied == false, "cannot deny a transfer that is already denied");
denied = true;
}
/**
* @dev Determine if the transfer is pending
*/
function isPending() public view returns (bool) {
return !complete;
}
} | approveTransfer | function approveTransfer() public onlyOwner {
require(denied == false, "cannot approve a denied transfer");
require(complete == false, "cannot approve a complete transfer");
complete = true;
}
| /**
* @dev Mark the transfer as approved / complete
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
893,
1106
]
} | 6,538 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | MultiSigTransfer | contract MultiSigTransfer is Ownable {
string public name = "MultiSigTransfer";
string public symbol = "MST";
bool public complete = false;
bool public denied = false;
uint32 public quantity;
address public targetAddress;
address public requesterAddress;
/**
* @dev The multisig transfer contract ensures that no single administrator can
* KVTs without approval of another administrator
* @param _quantity The number of KVT to transfer
* @param _targetAddress The receiver of the KVTs
* @param _requesterAddress The administrator requesting the transfer
*/
constructor(
uint32 _quantity,
address _targetAddress,
address _requesterAddress
) public {
quantity = _quantity;
targetAddress = _targetAddress;
requesterAddress = _requesterAddress;
}
/**
* @dev Mark the transfer as approved / complete
*/
function approveTransfer() public onlyOwner {
require(denied == false, "cannot approve a denied transfer");
require(complete == false, "cannot approve a complete transfer");
complete = true;
}
/**
* @dev Mark the transfer as denied
*/
function denyTransfer() public onlyOwner {
require(denied == false, "cannot deny a transfer that is already denied");
denied = true;
}
/**
* @dev Determine if the transfer is pending
*/
function isPending() public view returns (bool) {
return !complete;
}
} | denyTransfer | function denyTransfer() public onlyOwner {
require(denied == false, "cannot deny a transfer that is already denied");
denied = true;
}
| /**
* @dev Mark the transfer as denied
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
1160,
1310
]
} | 6,539 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | MultiSigTransfer | contract MultiSigTransfer is Ownable {
string public name = "MultiSigTransfer";
string public symbol = "MST";
bool public complete = false;
bool public denied = false;
uint32 public quantity;
address public targetAddress;
address public requesterAddress;
/**
* @dev The multisig transfer contract ensures that no single administrator can
* KVTs without approval of another administrator
* @param _quantity The number of KVT to transfer
* @param _targetAddress The receiver of the KVTs
* @param _requesterAddress The administrator requesting the transfer
*/
constructor(
uint32 _quantity,
address _targetAddress,
address _requesterAddress
) public {
quantity = _quantity;
targetAddress = _targetAddress;
requesterAddress = _requesterAddress;
}
/**
* @dev Mark the transfer as approved / complete
*/
function approveTransfer() public onlyOwner {
require(denied == false, "cannot approve a denied transfer");
require(complete == false, "cannot approve a complete transfer");
complete = true;
}
/**
* @dev Mark the transfer as denied
*/
function denyTransfer() public onlyOwner {
require(denied == false, "cannot deny a transfer that is already denied");
denied = true;
}
/**
* @dev Determine if the transfer is pending
*/
function isPending() public view returns (bool) {
return !complete;
}
} | isPending | function isPending() public view returns (bool) {
return !complete;
}
| /**
* @dev Determine if the transfer is pending
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
1373,
1453
]
} | 6,540 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | RBAC | contract RBAC {
using Roles for Roles.Role;
mapping (string => Roles.Role) private roles;
event RoleAdded(address indexed operator, string role);
event RoleRemoved(address indexed operator, string role);
/**
* @dev reverts if addr does not have role
* @param _operator address
* @param _role the name of the role
* // reverts
*/
function checkRole(address _operator, string _role)
view
public
{
roles[_role].check(_operator);
}
/**
* @dev determine if addr has role
* @param _operator address
* @param _role the name of the role
* @return bool
*/
function hasRole(address _operator, string _role)
view
public
returns (bool)
{
return roles[_role].has(_operator);
}
/**
* @dev add a role to an address
* @param _operator address
* @param _role the name of the role
*/
function addRole(address _operator, string _role)
internal
{
roles[_role].add(_operator);
emit RoleAdded(_operator, _role);
}
/**
* @dev remove a role from an address
* @param _operator address
* @param _role the name of the role
*/
function removeRole(address _operator, string _role)
internal
{
roles[_role].remove(_operator);
emit RoleRemoved(_operator, _role);
}
/**
* @dev modifier to scope access to a single role (uses msg.sender as addr)
* @param _role the name of the role
* // reverts
*/
modifier onlyRole(string _role)
{
checkRole(msg.sender, _role);
_;
}
/**
* @dev modifier to scope access to a set of roles (uses msg.sender as addr)
* @param _roles the names of the roles to scope access to
* // reverts
*
* @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this
* see: https://github.com/ethereum/solidity/issues/2467
*/
// modifier onlyRoles(string[] _roles) {
// bool hasAnyRole = false;
// for (uint8 i = 0; i < _roles.length; i++) {
// if (hasRole(msg.sender, _roles[i])) {
// hasAnyRole = true;
// break;
// }
// }
// require(hasAnyRole);
// _;
// }
} | checkRole | function checkRole(address _operator, string _role)
view
public
{
roles[_role].check(_operator);
}
| /**
* @dev reverts if addr does not have role
* @param _operator address
* @param _role the name of the role
* // reverts
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
371,
493
]
} | 6,541 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | RBAC | contract RBAC {
using Roles for Roles.Role;
mapping (string => Roles.Role) private roles;
event RoleAdded(address indexed operator, string role);
event RoleRemoved(address indexed operator, string role);
/**
* @dev reverts if addr does not have role
* @param _operator address
* @param _role the name of the role
* // reverts
*/
function checkRole(address _operator, string _role)
view
public
{
roles[_role].check(_operator);
}
/**
* @dev determine if addr has role
* @param _operator address
* @param _role the name of the role
* @return bool
*/
function hasRole(address _operator, string _role)
view
public
returns (bool)
{
return roles[_role].has(_operator);
}
/**
* @dev add a role to an address
* @param _operator address
* @param _role the name of the role
*/
function addRole(address _operator, string _role)
internal
{
roles[_role].add(_operator);
emit RoleAdded(_operator, _role);
}
/**
* @dev remove a role from an address
* @param _operator address
* @param _role the name of the role
*/
function removeRole(address _operator, string _role)
internal
{
roles[_role].remove(_operator);
emit RoleRemoved(_operator, _role);
}
/**
* @dev modifier to scope access to a single role (uses msg.sender as addr)
* @param _role the name of the role
* // reverts
*/
modifier onlyRole(string _role)
{
checkRole(msg.sender, _role);
_;
}
/**
* @dev modifier to scope access to a set of roles (uses msg.sender as addr)
* @param _roles the names of the roles to scope access to
* // reverts
*
* @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this
* see: https://github.com/ethereum/solidity/issues/2467
*/
// modifier onlyRoles(string[] _roles) {
// bool hasAnyRole = false;
// for (uint8 i = 0; i < _roles.length; i++) {
// if (hasRole(msg.sender, _roles[i])) {
// hasAnyRole = true;
// break;
// }
// }
// require(hasAnyRole);
// _;
// }
} | hasRole | function hasRole(address _operator, string _role)
view
public
returns (bool)
{
return roles[_role].has(_operator);
}
| /**
* @dev determine if addr has role
* @param _operator address
* @param _role the name of the role
* @return bool
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
638,
783
]
} | 6,542 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | RBAC | contract RBAC {
using Roles for Roles.Role;
mapping (string => Roles.Role) private roles;
event RoleAdded(address indexed operator, string role);
event RoleRemoved(address indexed operator, string role);
/**
* @dev reverts if addr does not have role
* @param _operator address
* @param _role the name of the role
* // reverts
*/
function checkRole(address _operator, string _role)
view
public
{
roles[_role].check(_operator);
}
/**
* @dev determine if addr has role
* @param _operator address
* @param _role the name of the role
* @return bool
*/
function hasRole(address _operator, string _role)
view
public
returns (bool)
{
return roles[_role].has(_operator);
}
/**
* @dev add a role to an address
* @param _operator address
* @param _role the name of the role
*/
function addRole(address _operator, string _role)
internal
{
roles[_role].add(_operator);
emit RoleAdded(_operator, _role);
}
/**
* @dev remove a role from an address
* @param _operator address
* @param _role the name of the role
*/
function removeRole(address _operator, string _role)
internal
{
roles[_role].remove(_operator);
emit RoleRemoved(_operator, _role);
}
/**
* @dev modifier to scope access to a single role (uses msg.sender as addr)
* @param _role the name of the role
* // reverts
*/
modifier onlyRole(string _role)
{
checkRole(msg.sender, _role);
_;
}
/**
* @dev modifier to scope access to a set of roles (uses msg.sender as addr)
* @param _roles the names of the roles to scope access to
* // reverts
*
* @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this
* see: https://github.com/ethereum/solidity/issues/2467
*/
// modifier onlyRoles(string[] _roles) {
// bool hasAnyRole = false;
// for (uint8 i = 0; i < _roles.length; i++) {
// if (hasRole(msg.sender, _roles[i])) {
// hasAnyRole = true;
// break;
// }
// }
// require(hasAnyRole);
// _;
// }
} | addRole | function addRole(address _operator, string _role)
internal
{
roles[_role].add(_operator);
emit RoleAdded(_operator, _role);
}
| /**
* @dev add a role to an address
* @param _operator address
* @param _role the name of the role
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
907,
1056
]
} | 6,543 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | RBAC | contract RBAC {
using Roles for Roles.Role;
mapping (string => Roles.Role) private roles;
event RoleAdded(address indexed operator, string role);
event RoleRemoved(address indexed operator, string role);
/**
* @dev reverts if addr does not have role
* @param _operator address
* @param _role the name of the role
* // reverts
*/
function checkRole(address _operator, string _role)
view
public
{
roles[_role].check(_operator);
}
/**
* @dev determine if addr has role
* @param _operator address
* @param _role the name of the role
* @return bool
*/
function hasRole(address _operator, string _role)
view
public
returns (bool)
{
return roles[_role].has(_operator);
}
/**
* @dev add a role to an address
* @param _operator address
* @param _role the name of the role
*/
function addRole(address _operator, string _role)
internal
{
roles[_role].add(_operator);
emit RoleAdded(_operator, _role);
}
/**
* @dev remove a role from an address
* @param _operator address
* @param _role the name of the role
*/
function removeRole(address _operator, string _role)
internal
{
roles[_role].remove(_operator);
emit RoleRemoved(_operator, _role);
}
/**
* @dev modifier to scope access to a single role (uses msg.sender as addr)
* @param _role the name of the role
* // reverts
*/
modifier onlyRole(string _role)
{
checkRole(msg.sender, _role);
_;
}
/**
* @dev modifier to scope access to a set of roles (uses msg.sender as addr)
* @param _roles the names of the roles to scope access to
* // reverts
*
* @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this
* see: https://github.com/ethereum/solidity/issues/2467
*/
// modifier onlyRoles(string[] _roles) {
// bool hasAnyRole = false;
// for (uint8 i = 0; i < _roles.length; i++) {
// if (hasRole(msg.sender, _roles[i])) {
// hasAnyRole = true;
// break;
// }
// }
// require(hasAnyRole);
// _;
// }
} | removeRole | function removeRole(address _operator, string _role)
internal
{
roles[_role].remove(_operator);
emit RoleRemoved(_operator, _role);
}
| /**
* @dev remove a role from an address
* @param _operator address
* @param _role the name of the role
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
1185,
1342
]
} | 6,544 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is BasicToken, Ownable, RBAC {
string public name = "KinesisVelocityToken";
string public symbol = "KVT";
uint8 public decimals = 0;
string public constant ADMIN_ROLE = "ADMIN";
address[] public transfers;
uint public constant INITIAL_SUPPLY = 300000;
uint public totalSupply = 0;
bool public isTransferable = false;
bool public toggleTransferablePending = false;
address public transferToggleRequester = address(0);
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
addRole(msg.sender, ADMIN_ROLE);
}
/**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/
function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
/**
* @dev Returns the list of MultiSig transfers
*/
function getTransfers() public view returns (address[]) {
return transfers;
}
/**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/
function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
/**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/
function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
/**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/
function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
/**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/
function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
/**
* @dev As an administrator who did not make the request, approve the transferable state change
*/
function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
/**
* @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, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
/**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/
function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
/**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
/**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
address public crowdsale = address(0);
/**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/
function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
} | isOwner | function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
| /**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
772,
874
]
} | 6,545 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is BasicToken, Ownable, RBAC {
string public name = "KinesisVelocityToken";
string public symbol = "KVT";
uint8 public decimals = 0;
string public constant ADMIN_ROLE = "ADMIN";
address[] public transfers;
uint public constant INITIAL_SUPPLY = 300000;
uint public totalSupply = 0;
bool public isTransferable = false;
bool public toggleTransferablePending = false;
address public transferToggleRequester = address(0);
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
addRole(msg.sender, ADMIN_ROLE);
}
/**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/
function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
/**
* @dev Returns the list of MultiSig transfers
*/
function getTransfers() public view returns (address[]) {
return transfers;
}
/**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/
function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
/**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/
function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
/**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/
function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
/**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/
function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
/**
* @dev As an administrator who did not make the request, approve the transferable state change
*/
function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
/**
* @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, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
/**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/
function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
/**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
/**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
address public crowdsale = address(0);
/**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/
function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
} | getTransfers | function getTransfers() public view returns (address[]) {
return transfers;
}
| /**
* @dev Returns the list of MultiSig transfers
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
939,
1027
]
} | 6,546 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is BasicToken, Ownable, RBAC {
string public name = "KinesisVelocityToken";
string public symbol = "KVT";
uint8 public decimals = 0;
string public constant ADMIN_ROLE = "ADMIN";
address[] public transfers;
uint public constant INITIAL_SUPPLY = 300000;
uint public totalSupply = 0;
bool public isTransferable = false;
bool public toggleTransferablePending = false;
address public transferToggleRequester = address(0);
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
addRole(msg.sender, ADMIN_ROLE);
}
/**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/
function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
/**
* @dev Returns the list of MultiSig transfers
*/
function getTransfers() public view returns (address[]) {
return transfers;
}
/**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/
function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
/**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/
function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
/**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/
function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
/**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/
function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
/**
* @dev As an administrator who did not make the request, approve the transferable state change
*/
function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
/**
* @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, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
/**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/
function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
/**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
/**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
address public crowdsale = address(0);
/**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/
function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
} | isAdmin | function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
| /**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
1159,
1273
]
} | 6,547 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is BasicToken, Ownable, RBAC {
string public name = "KinesisVelocityToken";
string public symbol = "KVT";
uint8 public decimals = 0;
string public constant ADMIN_ROLE = "ADMIN";
address[] public transfers;
uint public constant INITIAL_SUPPLY = 300000;
uint public totalSupply = 0;
bool public isTransferable = false;
bool public toggleTransferablePending = false;
address public transferToggleRequester = address(0);
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
addRole(msg.sender, ADMIN_ROLE);
}
/**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/
function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
/**
* @dev Returns the list of MultiSig transfers
*/
function getTransfers() public view returns (address[]) {
return transfers;
}
/**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/
function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
/**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/
function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
/**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/
function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
/**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/
function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
/**
* @dev As an administrator who did not make the request, approve the transferable state change
*/
function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
/**
* @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, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
/**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/
function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
/**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
/**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
address public crowdsale = address(0);
/**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/
function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
} | setAdmin | function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
| /**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
1373,
1480
]
} | 6,548 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is BasicToken, Ownable, RBAC {
string public name = "KinesisVelocityToken";
string public symbol = "KVT";
uint8 public decimals = 0;
string public constant ADMIN_ROLE = "ADMIN";
address[] public transfers;
uint public constant INITIAL_SUPPLY = 300000;
uint public totalSupply = 0;
bool public isTransferable = false;
bool public toggleTransferablePending = false;
address public transferToggleRequester = address(0);
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
addRole(msg.sender, ADMIN_ROLE);
}
/**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/
function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
/**
* @dev Returns the list of MultiSig transfers
*/
function getTransfers() public view returns (address[]) {
return transfers;
}
/**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/
function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
/**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/
function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
/**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/
function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
/**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/
function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
/**
* @dev As an administrator who did not make the request, approve the transferable state change
*/
function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
/**
* @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, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
/**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/
function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
/**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
/**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
address public crowdsale = address(0);
/**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/
function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
} | removeAdmin | function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
| /**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
1583,
1696
]
} | 6,549 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is BasicToken, Ownable, RBAC {
string public name = "KinesisVelocityToken";
string public symbol = "KVT";
uint8 public decimals = 0;
string public constant ADMIN_ROLE = "ADMIN";
address[] public transfers;
uint public constant INITIAL_SUPPLY = 300000;
uint public totalSupply = 0;
bool public isTransferable = false;
bool public toggleTransferablePending = false;
address public transferToggleRequester = address(0);
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
addRole(msg.sender, ADMIN_ROLE);
}
/**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/
function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
/**
* @dev Returns the list of MultiSig transfers
*/
function getTransfers() public view returns (address[]) {
return transfers;
}
/**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/
function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
/**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/
function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
/**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/
function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
/**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/
function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
/**
* @dev As an administrator who did not make the request, approve the transferable state change
*/
function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
/**
* @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, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
/**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/
function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
/**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
/**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
address public crowdsale = address(0);
/**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/
function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
} | setTransferable | function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
| /**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
1838,
2093
]
} | 6,550 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is BasicToken, Ownable, RBAC {
string public name = "KinesisVelocityToken";
string public symbol = "KVT";
uint8 public decimals = 0;
string public constant ADMIN_ROLE = "ADMIN";
address[] public transfers;
uint public constant INITIAL_SUPPLY = 300000;
uint public totalSupply = 0;
bool public isTransferable = false;
bool public toggleTransferablePending = false;
address public transferToggleRequester = address(0);
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
addRole(msg.sender, ADMIN_ROLE);
}
/**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/
function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
/**
* @dev Returns the list of MultiSig transfers
*/
function getTransfers() public view returns (address[]) {
return transfers;
}
/**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/
function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
/**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/
function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
/**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/
function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
/**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/
function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
/**
* @dev As an administrator who did not make the request, approve the transferable state change
*/
function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
/**
* @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, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
/**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/
function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
/**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
/**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
address public crowdsale = address(0);
/**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/
function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
} | approveTransferableToggle | function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
| /**
* @dev As an administrator who did not make the request, approve the transferable state change
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
2207,
2597
]
} | 6,551 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is BasicToken, Ownable, RBAC {
string public name = "KinesisVelocityToken";
string public symbol = "KVT";
uint8 public decimals = 0;
string public constant ADMIN_ROLE = "ADMIN";
address[] public transfers;
uint public constant INITIAL_SUPPLY = 300000;
uint public totalSupply = 0;
bool public isTransferable = false;
bool public toggleTransferablePending = false;
address public transferToggleRequester = address(0);
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
addRole(msg.sender, ADMIN_ROLE);
}
/**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/
function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
/**
* @dev Returns the list of MultiSig transfers
*/
function getTransfers() public view returns (address[]) {
return transfers;
}
/**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/
function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
/**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/
function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
/**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/
function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
/**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/
function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
/**
* @dev As an administrator who did not make the request, approve the transferable state change
*/
function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
/**
* @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, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
/**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/
function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
/**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
/**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
address public crowdsale = address(0);
/**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/
function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
} | _transfer | function _transfer(address _to, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
| /**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
2755,
3179
]
} | 6,552 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is BasicToken, Ownable, RBAC {
string public name = "KinesisVelocityToken";
string public symbol = "KVT";
uint8 public decimals = 0;
string public constant ADMIN_ROLE = "ADMIN";
address[] public transfers;
uint public constant INITIAL_SUPPLY = 300000;
uint public totalSupply = 0;
bool public isTransferable = false;
bool public toggleTransferablePending = false;
address public transferToggleRequester = address(0);
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
addRole(msg.sender, ADMIN_ROLE);
}
/**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/
function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
/**
* @dev Returns the list of MultiSig transfers
*/
function getTransfers() public view returns (address[]) {
return transfers;
}
/**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/
function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
/**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/
function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
/**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/
function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
/**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/
function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
/**
* @dev As an administrator who did not make the request, approve the transferable state change
*/
function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
/**
* @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, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
/**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/
function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
/**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
/**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
address public crowdsale = address(0);
/**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/
function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
} | transfer | function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
| /**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
3377,
3962
]
} | 6,553 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is BasicToken, Ownable, RBAC {
string public name = "KinesisVelocityToken";
string public symbol = "KVT";
uint8 public decimals = 0;
string public constant ADMIN_ROLE = "ADMIN";
address[] public transfers;
uint public constant INITIAL_SUPPLY = 300000;
uint public totalSupply = 0;
bool public isTransferable = false;
bool public toggleTransferablePending = false;
address public transferToggleRequester = address(0);
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
addRole(msg.sender, ADMIN_ROLE);
}
/**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/
function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
/**
* @dev Returns the list of MultiSig transfers
*/
function getTransfers() public view returns (address[]) {
return transfers;
}
/**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/
function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
/**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/
function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
/**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/
function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
/**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/
function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
/**
* @dev As an administrator who did not make the request, approve the transferable state change
*/
function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
/**
* @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, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
/**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/
function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
/**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
/**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
address public crowdsale = address(0);
/**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/
function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
} | adminTransfer | function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
| /**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
4146,
4348
]
} | 6,554 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is BasicToken, Ownable, RBAC {
string public name = "KinesisVelocityToken";
string public symbol = "KVT";
uint8 public decimals = 0;
string public constant ADMIN_ROLE = "ADMIN";
address[] public transfers;
uint public constant INITIAL_SUPPLY = 300000;
uint public totalSupply = 0;
bool public isTransferable = false;
bool public toggleTransferablePending = false;
address public transferToggleRequester = address(0);
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
addRole(msg.sender, ADMIN_ROLE);
}
/**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/
function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
/**
* @dev Returns the list of MultiSig transfers
*/
function getTransfers() public view returns (address[]) {
return transfers;
}
/**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/
function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
/**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/
function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
/**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/
function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
/**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/
function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
/**
* @dev As an administrator who did not make the request, approve the transferable state change
*/
function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
/**
* @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, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
/**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/
function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
/**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
/**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
address public crowdsale = address(0);
/**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/
function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
} | approveTransfer | function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
| /**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
4605,
5192
]
} | 6,555 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is BasicToken, Ownable, RBAC {
string public name = "KinesisVelocityToken";
string public symbol = "KVT";
uint8 public decimals = 0;
string public constant ADMIN_ROLE = "ADMIN";
address[] public transfers;
uint public constant INITIAL_SUPPLY = 300000;
uint public totalSupply = 0;
bool public isTransferable = false;
bool public toggleTransferablePending = false;
address public transferToggleRequester = address(0);
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
addRole(msg.sender, ADMIN_ROLE);
}
/**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/
function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
/**
* @dev Returns the list of MultiSig transfers
*/
function getTransfers() public view returns (address[]) {
return transfers;
}
/**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/
function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
/**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/
function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
/**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/
function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
/**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/
function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
/**
* @dev As an administrator who did not make the request, approve the transferable state change
*/
function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
/**
* @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, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
/**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/
function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
/**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
/**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
address public crowdsale = address(0);
/**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/
function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
} | denyTransfer | function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
| /**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
5370,
5589
]
} | 6,556 |
|||
KinesisVelocityToken | KinesisVelocityToken.sol | 0x3a859b9ea4998d344547283c7ce8ebc4abb77656 | Solidity | KinesisVelocityToken | contract KinesisVelocityToken is BasicToken, Ownable, RBAC {
string public name = "KinesisVelocityToken";
string public symbol = "KVT";
uint8 public decimals = 0;
string public constant ADMIN_ROLE = "ADMIN";
address[] public transfers;
uint public constant INITIAL_SUPPLY = 300000;
uint public totalSupply = 0;
bool public isTransferable = false;
bool public toggleTransferablePending = false;
address public transferToggleRequester = address(0);
constructor() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
addRole(msg.sender, ADMIN_ROLE);
}
/**
* @dev Determine if the address is the owner of the contract
* @param _address The address to determine of ownership
*/
function isOwner(address _address) public view returns (bool) {
return owner == _address;
}
/**
* @dev Returns the list of MultiSig transfers
*/
function getTransfers() public view returns (address[]) {
return transfers;
}
/**
* @dev The KVT ERC20 token uses adminstrators to handle transfering to the crowdsale, vesting and pre-purchasers
*/
function isAdmin(address _address) public view returns (bool) {
return hasRole(_address, ADMIN_ROLE);
}
/**
* @dev Set an administrator as the owner, using Open Zepplin RBAC implementation
*/
function setAdmin(address _newAdmin) public onlyOwner {
return addRole(_newAdmin, ADMIN_ROLE);
}
/**
* @dev Remove an administrator as the owner, using Open Zepplin RBAC implementation
*/
function removeAdmin(address _oldAdmin) public onlyOwner {
return removeRole(_oldAdmin, ADMIN_ROLE);
}
/**
* @dev As an administrator, request the token is made transferable
* @param _toState The transfer state being requested
*/
function setTransferable(bool _toState) public onlyRole(ADMIN_ROLE) {
require(isTransferable != _toState, "to init a transfer toggle, the toState must change");
toggleTransferablePending = true;
transferToggleRequester = msg.sender;
}
/**
* @dev As an administrator who did not make the request, approve the transferable state change
*/
function approveTransferableToggle() public onlyRole(ADMIN_ROLE) {
require(toggleTransferablePending == true, "transfer toggle not in pending state");
require(transferToggleRequester != msg.sender, "the requester cannot approve the transfer toggle");
isTransferable = !isTransferable;
toggleTransferablePending = false;
transferToggleRequester = address(0);
}
/**
* @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, address _from, uint256 _value) private returns (bool) {
require(_value <= balances[_from], "the balance in the from address is smaller than the tx value");
// SafeMath.sub will throw if there is not enough balance.
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Public transfer token function. This wrapper ensures the token is transferable
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "cannot transfer to the zero address");
/* We allow holders to return their Tokens to the contract owner at any point */
if (_to != owner && msg.sender != crowdsale) {
require(isTransferable == true, "kvt is not yet transferable");
}
/* Transfers from the owner address must use the administrative transfer */
require(msg.sender != owner, "the owner of the kvt contract cannot transfer");
return _transfer(_to, msg.sender, _value);
}
/**
* @dev Request an administrative transfer. This does not move tokens
* @param _to The address to transfer to.
* @param _quantity The amount to be transferred.
*/
function adminTransfer(address _to, uint32 _quantity) public onlyRole(ADMIN_ROLE) {
address newTransfer = new MultiSigTransfer(_quantity, _to, msg.sender);
transfers.push(newTransfer);
}
/**
* @dev Approve an administrative transfer. This moves the tokens if the requester
* is an admin, but not the same admin as the one who made the request
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function approveTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
uint32 transferQuantity = transferToApprove.quantity();
address deliveryAddress = transferToApprove.targetAddress();
address requesterAddress = transferToApprove.requesterAddress();
require(msg.sender != requesterAddress, "a requester cannot approve an admin transfer");
transferToApprove.approveTransfer();
return _transfer(deliveryAddress, owner, transferQuantity);
}
/**
* @dev Deny an administrative transfer. This ensures it cannot be approved.
* @param _approvedTransfer The contract address of the multisignature transfer.
*/
function denyTransfer(address _approvedTransfer) public onlyRole(ADMIN_ROLE) returns (bool) {
MultiSigTransfer transferToApprove = MultiSigTransfer(_approvedTransfer);
transferToApprove.denyTransfer();
}
address public crowdsale = address(0);
/**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/
function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
} | setCrowdsaleAddress | function setCrowdsaleAddress(address _crowdsaleAddress) public onlyRole(ADMIN_ROLE) {
crowdsale = _crowdsaleAddress;
}
| /**
* @dev Any admin can set the current crowdsale address, to allows transfers
* from the crowdsale to the purchaser
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://e627866e043cf4da56f8c79cec5a79ae3e0ab147c534df8d16f19fe0b4d13b9c | {
"func_code_index": [
5769,
5898
]
} | 6,557 |
|||
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | FixedPoint | library FixedPoint {
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
struct uq112x112 {
uint224 _x;
}
// range: [0, 2**144 - 1]
// resolution: 1 / 2**112
struct uq144x112 {
uint _x;
}
uint8 private constant RESOLUTION = 112;
uint private constant Q112 = uint(1) << RESOLUTION;
uint private constant Q224 = Q112 << RESOLUTION;
// encode a uint112 as a UQ112x112
function encode(uint112 x) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(x) << RESOLUTION);
}
// encodes a uint144 as a UQ144x112
function encode144(uint144 x) internal pure returns (uq144x112 memory) {
return uq144x112(uint256(x) << RESOLUTION);
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
require(x != 0, 'FixedPoint: DIV_BY_ZERO');
return uq112x112(self._x / uint224(x));
}
// multiply a UQ112x112 by a uint, returning a UQ144x112
// reverts on overflow
function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) {
uint z;
require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
return uq144x112(z);
}
// returns a UQ112x112 which represents the ratio of the numerator to the denominator
// equivalent to encode(numerator).div(denominator)
function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
}
// decode a UQ112x112 into a uint112 by truncating after the radix point
function decode(uq112x112 memory self) internal pure returns (uint112) {
return uint112(self._x >> RESOLUTION);
}
// decode a UQ144x112 into a uint144 by truncating after the radix point
function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
// take the reciprocal of a UQ112x112
function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
return uq112x112(uint224(Q224 / self._x));
}
// square root of a UQ112x112
function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
}
} | // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) | LineComment | encode | function encode(uint112 x) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(x) << RESOLUTION);
}
| // encode a uint112 as a UQ112x112 | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
450,
584
]
} | 6,558 |
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | FixedPoint | library FixedPoint {
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
struct uq112x112 {
uint224 _x;
}
// range: [0, 2**144 - 1]
// resolution: 1 / 2**112
struct uq144x112 {
uint _x;
}
uint8 private constant RESOLUTION = 112;
uint private constant Q112 = uint(1) << RESOLUTION;
uint private constant Q224 = Q112 << RESOLUTION;
// encode a uint112 as a UQ112x112
function encode(uint112 x) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(x) << RESOLUTION);
}
// encodes a uint144 as a UQ144x112
function encode144(uint144 x) internal pure returns (uq144x112 memory) {
return uq144x112(uint256(x) << RESOLUTION);
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
require(x != 0, 'FixedPoint: DIV_BY_ZERO');
return uq112x112(self._x / uint224(x));
}
// multiply a UQ112x112 by a uint, returning a UQ144x112
// reverts on overflow
function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) {
uint z;
require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
return uq144x112(z);
}
// returns a UQ112x112 which represents the ratio of the numerator to the denominator
// equivalent to encode(numerator).div(denominator)
function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
}
// decode a UQ112x112 into a uint112 by truncating after the radix point
function decode(uq112x112 memory self) internal pure returns (uint112) {
return uint112(self._x >> RESOLUTION);
}
// decode a UQ144x112 into a uint144 by truncating after the radix point
function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
// take the reciprocal of a UQ112x112
function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
return uq112x112(uint224(Q224 / self._x));
}
// square root of a UQ112x112
function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
}
} | // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) | LineComment | encode144 | function encode144(uint144 x) internal pure returns (uq144x112 memory) {
return uq144x112(uint256(x) << RESOLUTION);
}
| // encodes a uint144 as a UQ144x112 | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
628,
765
]
} | 6,559 |
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | FixedPoint | library FixedPoint {
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
struct uq112x112 {
uint224 _x;
}
// range: [0, 2**144 - 1]
// resolution: 1 / 2**112
struct uq144x112 {
uint _x;
}
uint8 private constant RESOLUTION = 112;
uint private constant Q112 = uint(1) << RESOLUTION;
uint private constant Q224 = Q112 << RESOLUTION;
// encode a uint112 as a UQ112x112
function encode(uint112 x) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(x) << RESOLUTION);
}
// encodes a uint144 as a UQ144x112
function encode144(uint144 x) internal pure returns (uq144x112 memory) {
return uq144x112(uint256(x) << RESOLUTION);
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
require(x != 0, 'FixedPoint: DIV_BY_ZERO');
return uq112x112(self._x / uint224(x));
}
// multiply a UQ112x112 by a uint, returning a UQ144x112
// reverts on overflow
function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) {
uint z;
require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
return uq144x112(z);
}
// returns a UQ112x112 which represents the ratio of the numerator to the denominator
// equivalent to encode(numerator).div(denominator)
function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
}
// decode a UQ112x112 into a uint112 by truncating after the radix point
function decode(uq112x112 memory self) internal pure returns (uint112) {
return uint112(self._x >> RESOLUTION);
}
// decode a UQ144x112 into a uint144 by truncating after the radix point
function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
// take the reciprocal of a UQ112x112
function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
return uq112x112(uint224(Q224 / self._x));
}
// square root of a UQ112x112
function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
}
} | // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) | LineComment | div | function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
require(x != 0, 'FixedPoint: DIV_BY_ZERO');
return uq112x112(self._x / uint224(x));
}
| // divide a UQ112x112 by a uint112, returning a UQ112x112 | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
831,
1034
]
} | 6,560 |
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | FixedPoint | library FixedPoint {
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
struct uq112x112 {
uint224 _x;
}
// range: [0, 2**144 - 1]
// resolution: 1 / 2**112
struct uq144x112 {
uint _x;
}
uint8 private constant RESOLUTION = 112;
uint private constant Q112 = uint(1) << RESOLUTION;
uint private constant Q224 = Q112 << RESOLUTION;
// encode a uint112 as a UQ112x112
function encode(uint112 x) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(x) << RESOLUTION);
}
// encodes a uint144 as a UQ144x112
function encode144(uint144 x) internal pure returns (uq144x112 memory) {
return uq144x112(uint256(x) << RESOLUTION);
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
require(x != 0, 'FixedPoint: DIV_BY_ZERO');
return uq112x112(self._x / uint224(x));
}
// multiply a UQ112x112 by a uint, returning a UQ144x112
// reverts on overflow
function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) {
uint z;
require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
return uq144x112(z);
}
// returns a UQ112x112 which represents the ratio of the numerator to the denominator
// equivalent to encode(numerator).div(denominator)
function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
}
// decode a UQ112x112 into a uint112 by truncating after the radix point
function decode(uq112x112 memory self) internal pure returns (uint112) {
return uint112(self._x >> RESOLUTION);
}
// decode a UQ144x112 into a uint144 by truncating after the radix point
function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
// take the reciprocal of a UQ112x112
function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
return uq112x112(uint224(Q224 / self._x));
}
// square root of a UQ112x112
function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
}
} | // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) | LineComment | mul | function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) {
uint z;
require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
return uq144x112(z);
}
| // multiply a UQ112x112 by a uint, returning a UQ144x112
// reverts on overflow | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
1127,
1385
]
} | 6,561 |
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | FixedPoint | library FixedPoint {
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
struct uq112x112 {
uint224 _x;
}
// range: [0, 2**144 - 1]
// resolution: 1 / 2**112
struct uq144x112 {
uint _x;
}
uint8 private constant RESOLUTION = 112;
uint private constant Q112 = uint(1) << RESOLUTION;
uint private constant Q224 = Q112 << RESOLUTION;
// encode a uint112 as a UQ112x112
function encode(uint112 x) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(x) << RESOLUTION);
}
// encodes a uint144 as a UQ144x112
function encode144(uint144 x) internal pure returns (uq144x112 memory) {
return uq144x112(uint256(x) << RESOLUTION);
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
require(x != 0, 'FixedPoint: DIV_BY_ZERO');
return uq112x112(self._x / uint224(x));
}
// multiply a UQ112x112 by a uint, returning a UQ144x112
// reverts on overflow
function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) {
uint z;
require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
return uq144x112(z);
}
// returns a UQ112x112 which represents the ratio of the numerator to the denominator
// equivalent to encode(numerator).div(denominator)
function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
}
// decode a UQ112x112 into a uint112 by truncating after the radix point
function decode(uq112x112 memory self) internal pure returns (uint112) {
return uint112(self._x >> RESOLUTION);
}
// decode a UQ144x112 into a uint144 by truncating after the radix point
function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
// take the reciprocal of a UQ112x112
function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
return uq112x112(uint224(Q224 / self._x));
}
// square root of a UQ112x112
function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
}
} | // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) | LineComment | fraction | function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
}
| // returns a UQ112x112 which represents the ratio of the numerator to the denominator
// equivalent to encode(numerator).div(denominator) | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
1536,
1787
]
} | 6,562 |
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | FixedPoint | library FixedPoint {
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
struct uq112x112 {
uint224 _x;
}
// range: [0, 2**144 - 1]
// resolution: 1 / 2**112
struct uq144x112 {
uint _x;
}
uint8 private constant RESOLUTION = 112;
uint private constant Q112 = uint(1) << RESOLUTION;
uint private constant Q224 = Q112 << RESOLUTION;
// encode a uint112 as a UQ112x112
function encode(uint112 x) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(x) << RESOLUTION);
}
// encodes a uint144 as a UQ144x112
function encode144(uint144 x) internal pure returns (uq144x112 memory) {
return uq144x112(uint256(x) << RESOLUTION);
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
require(x != 0, 'FixedPoint: DIV_BY_ZERO');
return uq112x112(self._x / uint224(x));
}
// multiply a UQ112x112 by a uint, returning a UQ144x112
// reverts on overflow
function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) {
uint z;
require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
return uq144x112(z);
}
// returns a UQ112x112 which represents the ratio of the numerator to the denominator
// equivalent to encode(numerator).div(denominator)
function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
}
// decode a UQ112x112 into a uint112 by truncating after the radix point
function decode(uq112x112 memory self) internal pure returns (uint112) {
return uint112(self._x >> RESOLUTION);
}
// decode a UQ144x112 into a uint144 by truncating after the radix point
function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
// take the reciprocal of a UQ112x112
function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
return uq112x112(uint224(Q224 / self._x));
}
// square root of a UQ112x112
function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
}
} | // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) | LineComment | decode | function decode(uq112x112 memory self) internal pure returns (uint112) {
return uint112(self._x >> RESOLUTION);
}
| // decode a UQ112x112 into a uint112 by truncating after the radix point | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
1868,
2000
]
} | 6,563 |
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | FixedPoint | library FixedPoint {
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
struct uq112x112 {
uint224 _x;
}
// range: [0, 2**144 - 1]
// resolution: 1 / 2**112
struct uq144x112 {
uint _x;
}
uint8 private constant RESOLUTION = 112;
uint private constant Q112 = uint(1) << RESOLUTION;
uint private constant Q224 = Q112 << RESOLUTION;
// encode a uint112 as a UQ112x112
function encode(uint112 x) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(x) << RESOLUTION);
}
// encodes a uint144 as a UQ144x112
function encode144(uint144 x) internal pure returns (uq144x112 memory) {
return uq144x112(uint256(x) << RESOLUTION);
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
require(x != 0, 'FixedPoint: DIV_BY_ZERO');
return uq112x112(self._x / uint224(x));
}
// multiply a UQ112x112 by a uint, returning a UQ144x112
// reverts on overflow
function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) {
uint z;
require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
return uq144x112(z);
}
// returns a UQ112x112 which represents the ratio of the numerator to the denominator
// equivalent to encode(numerator).div(denominator)
function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
}
// decode a UQ112x112 into a uint112 by truncating after the radix point
function decode(uq112x112 memory self) internal pure returns (uint112) {
return uint112(self._x >> RESOLUTION);
}
// decode a UQ144x112 into a uint144 by truncating after the radix point
function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
// take the reciprocal of a UQ112x112
function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
return uq112x112(uint224(Q224 / self._x));
}
// square root of a UQ112x112
function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
}
} | // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) | LineComment | decode144 | function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
| // decode a UQ144x112 into a uint144 by truncating after the radix point | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
2081,
2216
]
} | 6,564 |
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | FixedPoint | library FixedPoint {
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
struct uq112x112 {
uint224 _x;
}
// range: [0, 2**144 - 1]
// resolution: 1 / 2**112
struct uq144x112 {
uint _x;
}
uint8 private constant RESOLUTION = 112;
uint private constant Q112 = uint(1) << RESOLUTION;
uint private constant Q224 = Q112 << RESOLUTION;
// encode a uint112 as a UQ112x112
function encode(uint112 x) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(x) << RESOLUTION);
}
// encodes a uint144 as a UQ144x112
function encode144(uint144 x) internal pure returns (uq144x112 memory) {
return uq144x112(uint256(x) << RESOLUTION);
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
require(x != 0, 'FixedPoint: DIV_BY_ZERO');
return uq112x112(self._x / uint224(x));
}
// multiply a UQ112x112 by a uint, returning a UQ144x112
// reverts on overflow
function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) {
uint z;
require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
return uq144x112(z);
}
// returns a UQ112x112 which represents the ratio of the numerator to the denominator
// equivalent to encode(numerator).div(denominator)
function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
}
// decode a UQ112x112 into a uint112 by truncating after the radix point
function decode(uq112x112 memory self) internal pure returns (uint112) {
return uint112(self._x >> RESOLUTION);
}
// decode a UQ144x112 into a uint144 by truncating after the radix point
function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
// take the reciprocal of a UQ112x112
function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
return uq112x112(uint224(Q224 / self._x));
}
// square root of a UQ112x112
function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
}
} | // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) | LineComment | reciprocal | function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
return uq112x112(uint224(Q224 / self._x));
}
| // take the reciprocal of a UQ112x112 | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
2262,
2474
]
} | 6,565 |
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | FixedPoint | library FixedPoint {
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
struct uq112x112 {
uint224 _x;
}
// range: [0, 2**144 - 1]
// resolution: 1 / 2**112
struct uq144x112 {
uint _x;
}
uint8 private constant RESOLUTION = 112;
uint private constant Q112 = uint(1) << RESOLUTION;
uint private constant Q224 = Q112 << RESOLUTION;
// encode a uint112 as a UQ112x112
function encode(uint112 x) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(x) << RESOLUTION);
}
// encodes a uint144 as a UQ144x112
function encode144(uint144 x) internal pure returns (uq144x112 memory) {
return uq144x112(uint256(x) << RESOLUTION);
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
require(x != 0, 'FixedPoint: DIV_BY_ZERO');
return uq112x112(self._x / uint224(x));
}
// multiply a UQ112x112 by a uint, returning a UQ144x112
// reverts on overflow
function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) {
uint z;
require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
return uq144x112(z);
}
// returns a UQ112x112 which represents the ratio of the numerator to the denominator
// equivalent to encode(numerator).div(denominator)
function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
}
// decode a UQ112x112 into a uint112 by truncating after the radix point
function decode(uq112x112 memory self) internal pure returns (uint112) {
return uint112(self._x >> RESOLUTION);
}
// decode a UQ144x112 into a uint144 by truncating after the radix point
function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
// take the reciprocal of a UQ112x112
function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
return uq112x112(uint224(Q224 / self._x));
}
// square root of a UQ112x112
function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
}
} | // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) | LineComment | sqrt | function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
}
| // square root of a UQ112x112 | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
2512,
2680
]
} | 6,566 |
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | sortTokens | function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
| // returns sorted token addresses, used to handle return values from pairs sorted in this order | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
161,
515
]
} | 6,567 |
||
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | pairFor | function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
| // calculates the CREATE2 address for a pair without making any external calls | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
602,
1085
]
} | 6,568 |
||
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | getReserves | function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
| // fetches and sorts the reserves for a pair | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
1138,
1534
]
} | 6,569 |
||
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | quote | function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
| // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
1642,
1968
]
} | 6,570 |
||
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | getAmountOut | function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
| // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
2085,
2607
]
} | 6,571 |
||
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | getAmountIn | function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
| // given an output amount of an asset and pair reserves, returns a required input amount of the other asset | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
2723,
3200
]
} | 6,572 |
||
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | getAmountsOut | function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
| // performs chained getAmountOut calculations on any number of pairs | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
3277,
3793
]
} | 6,573 |
||
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | getAmountsIn | function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
| // performs chained getAmountIn calculations on any number of pairs | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
3869,
4406
]
} | 6,574 |
||
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | UniswapV2OracleLibrary | library UniswapV2OracleLibrary {
using FixedPoint for *;
// helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]
function currentBlockTimestamp() internal view returns (uint32) {
return uint32(block.timestamp % 2 ** 32);
}
// produces the cumulative price using counterfactuals to save gas and avoid a call to sync.
function currentCumulativePrices(
address pair
) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) {
blockTimestamp = currentBlockTimestamp();
price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast();
price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast();
// if time has elapsed since the last update on the pair, mock the accumulated price values
(uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves();
if (blockTimestampLast != blockTimestamp) {
// subtraction overflow is desired
uint32 timeElapsed = blockTimestamp - blockTimestampLast;
// addition overflow is desired
// counterfactual
price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;
// counterfactual
price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;
}
}
} | // library with helper methods for oracles that are concerned with computing average prices | LineComment | currentBlockTimestamp | function currentBlockTimestamp() internal view returns (uint32) {
return uint32(block.timestamp % 2 ** 32);
}
| // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
178,
306
]
} | 6,575 |
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | UniswapV2OracleLibrary | library UniswapV2OracleLibrary {
using FixedPoint for *;
// helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]
function currentBlockTimestamp() internal view returns (uint32) {
return uint32(block.timestamp % 2 ** 32);
}
// produces the cumulative price using counterfactuals to save gas and avoid a call to sync.
function currentCumulativePrices(
address pair
) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) {
blockTimestamp = currentBlockTimestamp();
price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast();
price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast();
// if time has elapsed since the last update on the pair, mock the accumulated price values
(uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves();
if (blockTimestampLast != blockTimestamp) {
// subtraction overflow is desired
uint32 timeElapsed = blockTimestamp - blockTimestampLast;
// addition overflow is desired
// counterfactual
price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;
// counterfactual
price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;
}
}
} | // library with helper methods for oracles that are concerned with computing average prices | LineComment | currentCumulativePrices | function currentCumulativePrices(
address pair
) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) {
blockTimestamp = currentBlockTimestamp();
price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast();
price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast();
// if time has elapsed since the last update on the pair, mock the accumulated price values
(uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves();
if (blockTimestampLast != blockTimestamp) {
// subtraction overflow is desired
uint32 timeElapsed = blockTimestamp - blockTimestampLast;
// addition overflow is desired
// counterfactual
price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;
// counterfactual
price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;
}
}
| // produces the cumulative price using counterfactuals to save gas and avoid a call to sync. | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
407,
1470
]
} | 6,576 |
ExampleOracleSimple | ExampleOracleSimple.sol | 0x77c5d6f22b8a6765e33da91e349b9844b79854f3 | Solidity | ExampleOracleSimple | contract ExampleOracleSimple {
using FixedPoint for *;
uint public constant PERIOD = 10 minutes;
IUniswapV2Pair immutable pair;
address public immutable token0;
address public immutable token1;
uint public price0CumulativeLast;
uint public price1CumulativeLast;
uint32 public blockTimestampLast;
FixedPoint.uq112x112 public price0Average;
FixedPoint.uq112x112 public price1Average;
constructor(address factory, address tokenA, address tokenB) public {
IUniswapV2Pair _pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, tokenA, tokenB));
pair = _pair;
token0 = _pair.token0();
token1 = _pair.token1();
price0CumulativeLast = _pair.price0CumulativeLast(); // fetch the current accumulated price value (1 / 0)
price1CumulativeLast = _pair.price1CumulativeLast(); // fetch the current accumulated price value (0 / 1)
uint112 reserve0;
uint112 reserve1;
(reserve0, reserve1, blockTimestampLast) = _pair.getReserves();
require(reserve0 != 0 && reserve1 != 0, 'ExampleOracleSimple: NO_RESERVES'); // ensure that there's liquidity in the pair
}
function update() external {
(uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) =
UniswapV2OracleLibrary.currentCumulativePrices(address(pair));
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
// ensure that at least one full period has passed since the last update
require(timeElapsed >= PERIOD, 'ExampleOracleSimple: PERIOD_NOT_ELAPSED');
// overflow is desired, casting never truncates
// cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed
price0Average = FixedPoint.uq112x112(uint224((price0Cumulative - price0CumulativeLast) / timeElapsed));
price1Average = FixedPoint.uq112x112(uint224((price1Cumulative - price1CumulativeLast) / timeElapsed));
price0CumulativeLast = price0Cumulative;
price1CumulativeLast = price1Cumulative;
blockTimestampLast = blockTimestamp;
}
// note this will always return 0 before update has been called successfully for the first time.
function consult(address token, uint amountIn) external view returns (uint amountOut) {
if (token == token0) {
amountOut = price0Average.mul(amountIn).decode144();
} else {
require(token == token1, 'ExampleOracleSimple: INVALID_TOKEN');
amountOut = price1Average.mul(amountIn).decode144();
}
}
} | // fixed window oracle that recomputes the average price for the entire period once every period
// note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period | LineComment | consult | function consult(address token, uint amountIn) external view returns (uint amountOut) {
if (token == token0) {
amountOut = price0Average.mul(amountIn).decode144();
} else {
require(token == token1, 'ExampleOracleSimple: INVALID_TOKEN');
amountOut = price1Average.mul(amountIn).decode144();
}
}
| // note this will always return 0 before update has been called successfully for the first time. | LineComment | v0.6.6+commit.6c089d02 | GNU GPLv3 | ipfs://fef9da001588a96274ede1aa60922ee3ff5fe22773b20f60c61f7df9ffeb9265 | {
"func_code_index": [
2324,
2693
]
} | 6,577 |
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | LimitedTransferToken | contract LimitedTransferToken is ERC20 {
/**
* @dev Checks whether it can transfer or otherwise throws.
*/
modifier canTransfer(address _sender, uint _value) {
if (_value > transferableTokens(_sender, uint64(now))) throw;
_;
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to The address that will recieve the tokens.
* @param _value The amount of tokens to be transferred.
*/
function transfer(address _to, uint _value) canTransfer(msg.sender, _value) {
return super.transfer(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from The address that will send the tokens.
* @param _to The address that will recieve the tokens.
* @param _value The amount of tokens to be transferred.
*/
function transferFrom(address _from, address _to, uint _value) canTransfer(_from, _value) {
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Default transferable tokens function returns all tokens for a holder (no limit).
* @dev Overwriting transferableTokens(address holder, uint64 time) is the way to provide the
* specific logic for limiting token transferability for a holder over time.
*/
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
return balanceOf(holder);
}
} | /**
* @title LimitedTransferToken
* @dev LimitedTransferToken defines the generic interface and the implementation to limit token
* transferability for different events. It is intended to be used as a base class for other token
* contracts.
* LimitedTransferToken has been designed to allow for different limiting factors,
* this can be achieved by recursively calling super.transferableTokens() until the base class is
* hit. For example:
* function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
* return min256(unlockedTokens, super.transferableTokens(holder, time));
* }
* A working example is VestedToken.sol:
* https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/VestedToken.sol
*/ | NatSpecMultiLine | transfer | function transfer(address _to, uint _value) canTransfer(msg.sender, _value) {
return super.transfer(_to, _value);
}
| /**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to The address that will recieve the tokens.
* @param _value The amount of tokens to be transferred.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
463,
588
]
} | 6,578 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | LimitedTransferToken | contract LimitedTransferToken is ERC20 {
/**
* @dev Checks whether it can transfer or otherwise throws.
*/
modifier canTransfer(address _sender, uint _value) {
if (_value > transferableTokens(_sender, uint64(now))) throw;
_;
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to The address that will recieve the tokens.
* @param _value The amount of tokens to be transferred.
*/
function transfer(address _to, uint _value) canTransfer(msg.sender, _value) {
return super.transfer(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from The address that will send the tokens.
* @param _to The address that will recieve the tokens.
* @param _value The amount of tokens to be transferred.
*/
function transferFrom(address _from, address _to, uint _value) canTransfer(_from, _value) {
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Default transferable tokens function returns all tokens for a holder (no limit).
* @dev Overwriting transferableTokens(address holder, uint64 time) is the way to provide the
* specific logic for limiting token transferability for a holder over time.
*/
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
return balanceOf(holder);
}
} | /**
* @title LimitedTransferToken
* @dev LimitedTransferToken defines the generic interface and the implementation to limit token
* transferability for different events. It is intended to be used as a base class for other token
* contracts.
* LimitedTransferToken has been designed to allow for different limiting factors,
* this can be achieved by recursively calling super.transferableTokens() until the base class is
* hit. For example:
* function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
* return min256(unlockedTokens, super.transferableTokens(holder, time));
* }
* A working example is VestedToken.sol:
* https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/VestedToken.sol
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address _from, address _to, uint _value) canTransfer(_from, _value) {
return super.transferFrom(_from, _to, _value);
}
| /**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from The address that will send the tokens.
* @param _to The address that will recieve the tokens.
* @param _value The amount of tokens to be transferred.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
850,
1000
]
} | 6,579 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | LimitedTransferToken | contract LimitedTransferToken is ERC20 {
/**
* @dev Checks whether it can transfer or otherwise throws.
*/
modifier canTransfer(address _sender, uint _value) {
if (_value > transferableTokens(_sender, uint64(now))) throw;
_;
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to The address that will recieve the tokens.
* @param _value The amount of tokens to be transferred.
*/
function transfer(address _to, uint _value) canTransfer(msg.sender, _value) {
return super.transfer(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from The address that will send the tokens.
* @param _to The address that will recieve the tokens.
* @param _value The amount of tokens to be transferred.
*/
function transferFrom(address _from, address _to, uint _value) canTransfer(_from, _value) {
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Default transferable tokens function returns all tokens for a holder (no limit).
* @dev Overwriting transferableTokens(address holder, uint64 time) is the way to provide the
* specific logic for limiting token transferability for a holder over time.
*/
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
return balanceOf(holder);
}
} | /**
* @title LimitedTransferToken
* @dev LimitedTransferToken defines the generic interface and the implementation to limit token
* transferability for different events. It is intended to be used as a base class for other token
* contracts.
* LimitedTransferToken has been designed to allow for different limiting factors,
* this can be achieved by recursively calling super.transferableTokens() until the base class is
* hit. For example:
* function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
* return min256(unlockedTokens, super.transferableTokens(holder, time));
* }
* A working example is VestedToken.sol:
* https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/VestedToken.sol
*/ | NatSpecMultiLine | transferableTokens | function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
return balanceOf(holder);
}
| /**
* @dev Default transferable tokens function returns all tokens for a holder (no limit).
* @dev Overwriting transferableTokens(address holder, uint64 time) is the way to provide the
* specific logic for limiting token transferability for a holder over time.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
1287,
1418
]
} | 6,580 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint;
mapping(address => uint) balances;
/**
* @dev Fix for the ERC20 short address attack.
*/
modifier onlyPayloadSize(uint size) {
if(msg.data.length < size + 4) {
throw;
}
_;
}
/**
* @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, uint _value) onlyPayloadSize(2 * 32) {
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 uint representing the amount owned by the passed address.
*/
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | transfer | function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) {
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.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
446,
673
]
} | 6,581 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint;
mapping(address => uint) balances;
/**
* @dev Fix for the ERC20 short address attack.
*/
modifier onlyPayloadSize(uint size) {
if(msg.data.length < size + 4) {
throw;
}
_;
}
/**
* @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, uint _value) onlyPayloadSize(2 * 32) {
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 uint representing the amount owned by the passed address.
*/
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
| /**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
877,
983
]
} | 6,582 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | StandardToken | contract StandardToken is BasicToken, ERC20 {
mapping (address => mapping (address => uint)) 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 uint the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) {
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 beahlf 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, uint _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 than 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 uint specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) constant returns (uint remaining) {
return allowed[_owner][_spender];
}
} | /**
* @title Standard ERC20 token
*
* @dev Implemantation of the basic standart 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, uint _value) onlyPayloadSize(3 * 32) {
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 uint the amout of tokens to be transfered
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
384,
875
]
} | 6,583 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | StandardToken | contract StandardToken is BasicToken, ERC20 {
mapping (address => mapping (address => uint)) 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 uint the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) {
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 beahlf 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, uint _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 than 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 uint specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) constant returns (uint remaining) {
return allowed[_owner][_spender];
}
} | /**
* @title Standard ERC20 token
*
* @dev Implemantation of the basic standart 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, uint _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 beahlf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
1110,
1624
]
} | 6,584 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | StandardToken | contract StandardToken is BasicToken, ERC20 {
mapping (address => mapping (address => uint)) 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 uint the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) {
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 beahlf 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, uint _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 than 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 uint specifing the amount of tokens still avaible for the spender.
*/
function allowance(address _owner, address _spender) constant returns (uint remaining) {
return allowed[_owner][_spender];
}
} | /**
* @title Standard ERC20 token
*
* @dev Implemantation of the basic standart 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 (uint remaining) {
return allowed[_owner][_spender];
}
| /**
* @dev Function to check the amount of tokens than 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 uint specifing the amount of tokens still avaible for the spender.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
1942,
2077
]
} | 6,585 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | VestedToken | contract VestedToken is StandardToken, LimitedTransferToken {
uint256 MAX_GRANTS_PER_ADDRESS = 20;
struct TokenGrant {
address granter; // 20 bytes
uint256 value; // 32 bytes
uint64 cliff;
uint64 vesting;
uint64 start; // 3 * 8 = 24 bytes
bool revokable;
bool burnsOnRevoke; // 2 * 1 = 2 bits? or 2 bytes?
} // total 78 bytes = 3 sstore per operation (32 per sstore)
mapping (address => TokenGrant[]) public grants;
event NewTokenGrant(address indexed from, address indexed to, uint256 value, uint256 grantId);
/**
* @dev Grant tokens to a specified address
* @param _to address The address which the tokens will be granted to.
* @param _value uint256 The amount of tokens to be granted.
* @param _start uint64 Time of the beginning of the grant.
* @param _cliff uint64 Time of the cliff period.
* @param _vesting uint64 The vesting period.
*/
function grantVestedTokens(
address _to,
uint256 _value,
uint64 _start,
uint64 _cliff,
uint64 _vesting,
bool _revokable,
bool _burnsOnRevoke
) public {
// Check for date inconsistencies that may cause unexpected behavior
if (_cliff < _start || _vesting < _cliff) {
throw;
}
if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) throw; // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting).
uint count = grants[_to].push(
TokenGrant(
_revokable ? msg.sender : 0, // avoid storing an extra 20 bytes when it is non-revokable
_value,
_cliff,
_vesting,
_start,
_revokable,
_burnsOnRevoke
)
);
transfer(_to, _value);
NewTokenGrant(msg.sender, _to, _value, count - 1);
}
/**
* @dev Revoke the grant of tokens of a specifed address.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
*/
function revokeTokenGrant(address _holder, uint _grantId) public {
TokenGrant grant = grants[_holder][_grantId];
if (!grant.revokable) { // Check if grant was revokable
throw;
}
if (grant.granter != msg.sender) { // Only granter can revoke it
throw;
}
address receiver = grant.burnsOnRevoke ? 0xdead : msg.sender;
uint256 nonVested = nonVestedTokens(grant, uint64(now));
// remove grant from array
delete grants[_holder][_grantId];
grants[_holder][_grantId] = grants[_holder][grants[_holder].length.sub(1)];
grants[_holder].length -= 1;
balances[receiver] = balances[receiver].add(nonVested);
balances[_holder] = balances[_holder].sub(nonVested);
Transfer(_holder, receiver, nonVested);
}
/**
* @dev Calculate the total amount of transferable tokens of a holder at a given time
* @param holder address The address of the holder
* @param time uint64 The specific time.
* @return An uint representing a holder's total amount of transferable tokens.
*/
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
uint256 grantIndex = tokenGrantsCount(holder);
if (grantIndex == 0) return balanceOf(holder); // shortcut for holder without grants
// Iterate through all the grants the holder has, and add all non-vested tokens
uint256 nonVested = 0;
for (uint256 i = 0; i < grantIndex; i++) {
nonVested = SafeMath.add(nonVested, nonVestedTokens(grants[holder][i], time));
}
// Balance - totalNonVested is the amount of tokens a holder can transfer at any given time
uint256 vestedTransferable = SafeMath.sub(balanceOf(holder), nonVested);
// Return the minimum of how many vested can transfer and other value
// in case there are other limiting transferability factors (default is balanceOf)
return SafeMath.min256(vestedTransferable, super.transferableTokens(holder, time));
}
/**
* @dev Check the amount of grants that an address has.
* @param _holder The holder of the grants.
* @return A uint representing the total amount of grants.
*/
function tokenGrantsCount(address _holder) constant returns (uint index) {
return grants[_holder].length;
}
/**
* @dev Calculate amount of vested tokens at a specifc time.
* @param tokens uint256 The amount of tokens grantted.
* @param time uint64 The time to be checked
* @param start uint64 A time representing the begining of the grant
* @param cliff uint64 The cliff period.
* @param vesting uint64 The vesting period.
* @return An uint representing the amount of vested tokensof a specif grant.
* transferableTokens
* | _/-------- vestedTokens rect
* | _/
* | _/
* | _/
* | _/
* | /
* | .|
* | . |
* | . |
* | . |
* | . |
* | . |
* +===+===========+---------+----------> time
* Start Clift Vesting
*/
function calculateVestedTokens(
uint256 tokens,
uint256 time,
uint256 start,
uint256 cliff,
uint256 vesting) constant returns (uint256)
{
// Shortcuts for before cliff and after vesting cases.
if (time < cliff) return 0;
if (time >= vesting) return tokens;
// Interpolate all vested tokens.
// As before cliff the shortcut returns 0, we can use just calculate a value
// in the vesting rect (as shown in above's figure)
// vestedTokens = tokens * (time - start) / (vesting - start)
uint256 vestedTokens = SafeMath.div(
SafeMath.mul(
tokens,
SafeMath.sub(time, start)
),
SafeMath.sub(vesting, start)
);
return vestedTokens;
}
/**
* @dev Get all information about a specifc grant.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
* @return Returns all the values that represent a TokenGrant(address, value, start, cliff,
* revokability, burnsOnRevoke, and vesting) plus the vested value at the current time.
*/
function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
TokenGrant grant = grants[_holder][_grantId];
granter = grant.granter;
value = grant.value;
start = grant.start;
cliff = grant.cliff;
vesting = grant.vesting;
revokable = grant.revokable;
burnsOnRevoke = grant.burnsOnRevoke;
vested = vestedTokens(grant, uint64(now));
}
/**
* @dev Get the amount of vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time The time to be checked
* @return An uint representing the amount of vested tokens of a specific grant at a specific time.
*/
function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return calculateVestedTokens(
grant.value,
uint256(time),
uint256(grant.start),
uint256(grant.cliff),
uint256(grant.vesting)
);
}
/**
* @dev Calculate the amount of non vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time uint64 The time to be checked
* @return An uint representing the amount of non vested tokens of a specifc grant on the
* passed time frame.
*/
function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return grant.value.sub(vestedTokens(grant, time));
}
/**
* @dev Calculate the date when the holder can trasfer all its tokens
* @param holder address The address of the holder
* @return An uint representing the date of the last transferable tokens.
*/
function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
date = uint64(now);
uint256 grantIndex = grants[holder].length;
for (uint256 i = 0; i < grantIndex; i++) {
date = SafeMath.max64(grants[holder][i].vesting, date);
}
}
} | /**
* @title Vested token
* @dev Tokens that can be vested for a group of addresses.
*/ | NatSpecMultiLine | grantVestedTokens | function grantVestedTokens(
address _to,
uint256 _value,
uint64 _start,
uint64 _cliff,
uint64 _vesting,
bool _revokable,
bool _burnsOnRevoke
) public {
// Check for date inconsistencies that may cause unexpected behavior
if (_cliff < _start || _vesting < _cliff) {
throw;
}
if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) throw; // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting).
uint count = grants[_to].push(
TokenGrant(
_revokable ? msg.sender : 0, // avoid storing an extra 20 bytes when it is non-revokable
_value,
_cliff,
_vesting,
_start,
_revokable,
_burnsOnRevoke
)
);
transfer(_to, _value);
NewTokenGrant(msg.sender, _to, _value, count - 1);
}
| /**
* @dev Grant tokens to a specified address
* @param _to address The address which the tokens will be granted to.
* @param _value uint256 The amount of tokens to be granted.
* @param _start uint64 Time of the beginning of the grant.
* @param _cliff uint64 Time of the cliff period.
* @param _vesting uint64 The vesting period.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
954,
1949
]
} | 6,586 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | VestedToken | contract VestedToken is StandardToken, LimitedTransferToken {
uint256 MAX_GRANTS_PER_ADDRESS = 20;
struct TokenGrant {
address granter; // 20 bytes
uint256 value; // 32 bytes
uint64 cliff;
uint64 vesting;
uint64 start; // 3 * 8 = 24 bytes
bool revokable;
bool burnsOnRevoke; // 2 * 1 = 2 bits? or 2 bytes?
} // total 78 bytes = 3 sstore per operation (32 per sstore)
mapping (address => TokenGrant[]) public grants;
event NewTokenGrant(address indexed from, address indexed to, uint256 value, uint256 grantId);
/**
* @dev Grant tokens to a specified address
* @param _to address The address which the tokens will be granted to.
* @param _value uint256 The amount of tokens to be granted.
* @param _start uint64 Time of the beginning of the grant.
* @param _cliff uint64 Time of the cliff period.
* @param _vesting uint64 The vesting period.
*/
function grantVestedTokens(
address _to,
uint256 _value,
uint64 _start,
uint64 _cliff,
uint64 _vesting,
bool _revokable,
bool _burnsOnRevoke
) public {
// Check for date inconsistencies that may cause unexpected behavior
if (_cliff < _start || _vesting < _cliff) {
throw;
}
if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) throw; // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting).
uint count = grants[_to].push(
TokenGrant(
_revokable ? msg.sender : 0, // avoid storing an extra 20 bytes when it is non-revokable
_value,
_cliff,
_vesting,
_start,
_revokable,
_burnsOnRevoke
)
);
transfer(_to, _value);
NewTokenGrant(msg.sender, _to, _value, count - 1);
}
/**
* @dev Revoke the grant of tokens of a specifed address.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
*/
function revokeTokenGrant(address _holder, uint _grantId) public {
TokenGrant grant = grants[_holder][_grantId];
if (!grant.revokable) { // Check if grant was revokable
throw;
}
if (grant.granter != msg.sender) { // Only granter can revoke it
throw;
}
address receiver = grant.burnsOnRevoke ? 0xdead : msg.sender;
uint256 nonVested = nonVestedTokens(grant, uint64(now));
// remove grant from array
delete grants[_holder][_grantId];
grants[_holder][_grantId] = grants[_holder][grants[_holder].length.sub(1)];
grants[_holder].length -= 1;
balances[receiver] = balances[receiver].add(nonVested);
balances[_holder] = balances[_holder].sub(nonVested);
Transfer(_holder, receiver, nonVested);
}
/**
* @dev Calculate the total amount of transferable tokens of a holder at a given time
* @param holder address The address of the holder
* @param time uint64 The specific time.
* @return An uint representing a holder's total amount of transferable tokens.
*/
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
uint256 grantIndex = tokenGrantsCount(holder);
if (grantIndex == 0) return balanceOf(holder); // shortcut for holder without grants
// Iterate through all the grants the holder has, and add all non-vested tokens
uint256 nonVested = 0;
for (uint256 i = 0; i < grantIndex; i++) {
nonVested = SafeMath.add(nonVested, nonVestedTokens(grants[holder][i], time));
}
// Balance - totalNonVested is the amount of tokens a holder can transfer at any given time
uint256 vestedTransferable = SafeMath.sub(balanceOf(holder), nonVested);
// Return the minimum of how many vested can transfer and other value
// in case there are other limiting transferability factors (default is balanceOf)
return SafeMath.min256(vestedTransferable, super.transferableTokens(holder, time));
}
/**
* @dev Check the amount of grants that an address has.
* @param _holder The holder of the grants.
* @return A uint representing the total amount of grants.
*/
function tokenGrantsCount(address _holder) constant returns (uint index) {
return grants[_holder].length;
}
/**
* @dev Calculate amount of vested tokens at a specifc time.
* @param tokens uint256 The amount of tokens grantted.
* @param time uint64 The time to be checked
* @param start uint64 A time representing the begining of the grant
* @param cliff uint64 The cliff period.
* @param vesting uint64 The vesting period.
* @return An uint representing the amount of vested tokensof a specif grant.
* transferableTokens
* | _/-------- vestedTokens rect
* | _/
* | _/
* | _/
* | _/
* | /
* | .|
* | . |
* | . |
* | . |
* | . |
* | . |
* +===+===========+---------+----------> time
* Start Clift Vesting
*/
function calculateVestedTokens(
uint256 tokens,
uint256 time,
uint256 start,
uint256 cliff,
uint256 vesting) constant returns (uint256)
{
// Shortcuts for before cliff and after vesting cases.
if (time < cliff) return 0;
if (time >= vesting) return tokens;
// Interpolate all vested tokens.
// As before cliff the shortcut returns 0, we can use just calculate a value
// in the vesting rect (as shown in above's figure)
// vestedTokens = tokens * (time - start) / (vesting - start)
uint256 vestedTokens = SafeMath.div(
SafeMath.mul(
tokens,
SafeMath.sub(time, start)
),
SafeMath.sub(vesting, start)
);
return vestedTokens;
}
/**
* @dev Get all information about a specifc grant.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
* @return Returns all the values that represent a TokenGrant(address, value, start, cliff,
* revokability, burnsOnRevoke, and vesting) plus the vested value at the current time.
*/
function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
TokenGrant grant = grants[_holder][_grantId];
granter = grant.granter;
value = grant.value;
start = grant.start;
cliff = grant.cliff;
vesting = grant.vesting;
revokable = grant.revokable;
burnsOnRevoke = grant.burnsOnRevoke;
vested = vestedTokens(grant, uint64(now));
}
/**
* @dev Get the amount of vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time The time to be checked
* @return An uint representing the amount of vested tokens of a specific grant at a specific time.
*/
function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return calculateVestedTokens(
grant.value,
uint256(time),
uint256(grant.start),
uint256(grant.cliff),
uint256(grant.vesting)
);
}
/**
* @dev Calculate the amount of non vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time uint64 The time to be checked
* @return An uint representing the amount of non vested tokens of a specifc grant on the
* passed time frame.
*/
function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return grant.value.sub(vestedTokens(grant, time));
}
/**
* @dev Calculate the date when the holder can trasfer all its tokens
* @param holder address The address of the holder
* @return An uint representing the date of the last transferable tokens.
*/
function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
date = uint64(now);
uint256 grantIndex = grants[holder].length;
for (uint256 i = 0; i < grantIndex; i++) {
date = SafeMath.max64(grants[holder][i].vesting, date);
}
}
} | /**
* @title Vested token
* @dev Tokens that can be vested for a group of addresses.
*/ | NatSpecMultiLine | revokeTokenGrant | function revokeTokenGrant(address _holder, uint _grantId) public {
TokenGrant grant = grants[_holder][_grantId];
if (!grant.revokable) { // Check if grant was revokable
throw;
}
if (grant.granter != msg.sender) { // Only granter can revoke it
throw;
}
address receiver = grant.burnsOnRevoke ? 0xdead : msg.sender;
uint256 nonVested = nonVestedTokens(grant, uint64(now));
// remove grant from array
delete grants[_holder][_grantId];
grants[_holder][_grantId] = grants[_holder][grants[_holder].length.sub(1)];
grants[_holder].length -= 1;
balances[receiver] = balances[receiver].add(nonVested);
balances[_holder] = balances[_holder].sub(nonVested);
Transfer(_holder, receiver, nonVested);
}
| /**
* @dev Revoke the grant of tokens of a specifed address.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
2145,
2937
]
} | 6,587 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | VestedToken | contract VestedToken is StandardToken, LimitedTransferToken {
uint256 MAX_GRANTS_PER_ADDRESS = 20;
struct TokenGrant {
address granter; // 20 bytes
uint256 value; // 32 bytes
uint64 cliff;
uint64 vesting;
uint64 start; // 3 * 8 = 24 bytes
bool revokable;
bool burnsOnRevoke; // 2 * 1 = 2 bits? or 2 bytes?
} // total 78 bytes = 3 sstore per operation (32 per sstore)
mapping (address => TokenGrant[]) public grants;
event NewTokenGrant(address indexed from, address indexed to, uint256 value, uint256 grantId);
/**
* @dev Grant tokens to a specified address
* @param _to address The address which the tokens will be granted to.
* @param _value uint256 The amount of tokens to be granted.
* @param _start uint64 Time of the beginning of the grant.
* @param _cliff uint64 Time of the cliff period.
* @param _vesting uint64 The vesting period.
*/
function grantVestedTokens(
address _to,
uint256 _value,
uint64 _start,
uint64 _cliff,
uint64 _vesting,
bool _revokable,
bool _burnsOnRevoke
) public {
// Check for date inconsistencies that may cause unexpected behavior
if (_cliff < _start || _vesting < _cliff) {
throw;
}
if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) throw; // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting).
uint count = grants[_to].push(
TokenGrant(
_revokable ? msg.sender : 0, // avoid storing an extra 20 bytes when it is non-revokable
_value,
_cliff,
_vesting,
_start,
_revokable,
_burnsOnRevoke
)
);
transfer(_to, _value);
NewTokenGrant(msg.sender, _to, _value, count - 1);
}
/**
* @dev Revoke the grant of tokens of a specifed address.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
*/
function revokeTokenGrant(address _holder, uint _grantId) public {
TokenGrant grant = grants[_holder][_grantId];
if (!grant.revokable) { // Check if grant was revokable
throw;
}
if (grant.granter != msg.sender) { // Only granter can revoke it
throw;
}
address receiver = grant.burnsOnRevoke ? 0xdead : msg.sender;
uint256 nonVested = nonVestedTokens(grant, uint64(now));
// remove grant from array
delete grants[_holder][_grantId];
grants[_holder][_grantId] = grants[_holder][grants[_holder].length.sub(1)];
grants[_holder].length -= 1;
balances[receiver] = balances[receiver].add(nonVested);
balances[_holder] = balances[_holder].sub(nonVested);
Transfer(_holder, receiver, nonVested);
}
/**
* @dev Calculate the total amount of transferable tokens of a holder at a given time
* @param holder address The address of the holder
* @param time uint64 The specific time.
* @return An uint representing a holder's total amount of transferable tokens.
*/
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
uint256 grantIndex = tokenGrantsCount(holder);
if (grantIndex == 0) return balanceOf(holder); // shortcut for holder without grants
// Iterate through all the grants the holder has, and add all non-vested tokens
uint256 nonVested = 0;
for (uint256 i = 0; i < grantIndex; i++) {
nonVested = SafeMath.add(nonVested, nonVestedTokens(grants[holder][i], time));
}
// Balance - totalNonVested is the amount of tokens a holder can transfer at any given time
uint256 vestedTransferable = SafeMath.sub(balanceOf(holder), nonVested);
// Return the minimum of how many vested can transfer and other value
// in case there are other limiting transferability factors (default is balanceOf)
return SafeMath.min256(vestedTransferable, super.transferableTokens(holder, time));
}
/**
* @dev Check the amount of grants that an address has.
* @param _holder The holder of the grants.
* @return A uint representing the total amount of grants.
*/
function tokenGrantsCount(address _holder) constant returns (uint index) {
return grants[_holder].length;
}
/**
* @dev Calculate amount of vested tokens at a specifc time.
* @param tokens uint256 The amount of tokens grantted.
* @param time uint64 The time to be checked
* @param start uint64 A time representing the begining of the grant
* @param cliff uint64 The cliff period.
* @param vesting uint64 The vesting period.
* @return An uint representing the amount of vested tokensof a specif grant.
* transferableTokens
* | _/-------- vestedTokens rect
* | _/
* | _/
* | _/
* | _/
* | /
* | .|
* | . |
* | . |
* | . |
* | . |
* | . |
* +===+===========+---------+----------> time
* Start Clift Vesting
*/
function calculateVestedTokens(
uint256 tokens,
uint256 time,
uint256 start,
uint256 cliff,
uint256 vesting) constant returns (uint256)
{
// Shortcuts for before cliff and after vesting cases.
if (time < cliff) return 0;
if (time >= vesting) return tokens;
// Interpolate all vested tokens.
// As before cliff the shortcut returns 0, we can use just calculate a value
// in the vesting rect (as shown in above's figure)
// vestedTokens = tokens * (time - start) / (vesting - start)
uint256 vestedTokens = SafeMath.div(
SafeMath.mul(
tokens,
SafeMath.sub(time, start)
),
SafeMath.sub(vesting, start)
);
return vestedTokens;
}
/**
* @dev Get all information about a specifc grant.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
* @return Returns all the values that represent a TokenGrant(address, value, start, cliff,
* revokability, burnsOnRevoke, and vesting) plus the vested value at the current time.
*/
function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
TokenGrant grant = grants[_holder][_grantId];
granter = grant.granter;
value = grant.value;
start = grant.start;
cliff = grant.cliff;
vesting = grant.vesting;
revokable = grant.revokable;
burnsOnRevoke = grant.burnsOnRevoke;
vested = vestedTokens(grant, uint64(now));
}
/**
* @dev Get the amount of vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time The time to be checked
* @return An uint representing the amount of vested tokens of a specific grant at a specific time.
*/
function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return calculateVestedTokens(
grant.value,
uint256(time),
uint256(grant.start),
uint256(grant.cliff),
uint256(grant.vesting)
);
}
/**
* @dev Calculate the amount of non vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time uint64 The time to be checked
* @return An uint representing the amount of non vested tokens of a specifc grant on the
* passed time frame.
*/
function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return grant.value.sub(vestedTokens(grant, time));
}
/**
* @dev Calculate the date when the holder can trasfer all its tokens
* @param holder address The address of the holder
* @return An uint representing the date of the last transferable tokens.
*/
function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
date = uint64(now);
uint256 grantIndex = grants[holder].length;
for (uint256 i = 0; i < grantIndex; i++) {
date = SafeMath.max64(grants[holder][i].vesting, date);
}
}
} | /**
* @title Vested token
* @dev Tokens that can be vested for a group of addresses.
*/ | NatSpecMultiLine | transferableTokens | function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
uint256 grantIndex = tokenGrantsCount(holder);
if (grantIndex == 0) return balanceOf(holder); // shortcut for holder without grants
// Iterate through all the grants the holder has, and add all non-vested tokens
uint256 nonVested = 0;
for (uint256 i = 0; i < grantIndex; i++) {
nonVested = SafeMath.add(nonVested, nonVestedTokens(grants[holder][i], time));
}
// Balance - totalNonVested is the amount of tokens a holder can transfer at any given time
uint256 vestedTransferable = SafeMath.sub(balanceOf(holder), nonVested);
// Return the minimum of how many vested can transfer and other value
// in case there are other limiting transferability factors (default is balanceOf)
return SafeMath.min256(vestedTransferable, super.transferableTokens(holder, time));
}
| /**
* @dev Calculate the total amount of transferable tokens of a holder at a given time
* @param holder address The address of the holder
* @param time uint64 The specific time.
* @return An uint representing a holder's total amount of transferable tokens.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
3226,
4157
]
} | 6,588 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | VestedToken | contract VestedToken is StandardToken, LimitedTransferToken {
uint256 MAX_GRANTS_PER_ADDRESS = 20;
struct TokenGrant {
address granter; // 20 bytes
uint256 value; // 32 bytes
uint64 cliff;
uint64 vesting;
uint64 start; // 3 * 8 = 24 bytes
bool revokable;
bool burnsOnRevoke; // 2 * 1 = 2 bits? or 2 bytes?
} // total 78 bytes = 3 sstore per operation (32 per sstore)
mapping (address => TokenGrant[]) public grants;
event NewTokenGrant(address indexed from, address indexed to, uint256 value, uint256 grantId);
/**
* @dev Grant tokens to a specified address
* @param _to address The address which the tokens will be granted to.
* @param _value uint256 The amount of tokens to be granted.
* @param _start uint64 Time of the beginning of the grant.
* @param _cliff uint64 Time of the cliff period.
* @param _vesting uint64 The vesting period.
*/
function grantVestedTokens(
address _to,
uint256 _value,
uint64 _start,
uint64 _cliff,
uint64 _vesting,
bool _revokable,
bool _burnsOnRevoke
) public {
// Check for date inconsistencies that may cause unexpected behavior
if (_cliff < _start || _vesting < _cliff) {
throw;
}
if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) throw; // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting).
uint count = grants[_to].push(
TokenGrant(
_revokable ? msg.sender : 0, // avoid storing an extra 20 bytes when it is non-revokable
_value,
_cliff,
_vesting,
_start,
_revokable,
_burnsOnRevoke
)
);
transfer(_to, _value);
NewTokenGrant(msg.sender, _to, _value, count - 1);
}
/**
* @dev Revoke the grant of tokens of a specifed address.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
*/
function revokeTokenGrant(address _holder, uint _grantId) public {
TokenGrant grant = grants[_holder][_grantId];
if (!grant.revokable) { // Check if grant was revokable
throw;
}
if (grant.granter != msg.sender) { // Only granter can revoke it
throw;
}
address receiver = grant.burnsOnRevoke ? 0xdead : msg.sender;
uint256 nonVested = nonVestedTokens(grant, uint64(now));
// remove grant from array
delete grants[_holder][_grantId];
grants[_holder][_grantId] = grants[_holder][grants[_holder].length.sub(1)];
grants[_holder].length -= 1;
balances[receiver] = balances[receiver].add(nonVested);
balances[_holder] = balances[_holder].sub(nonVested);
Transfer(_holder, receiver, nonVested);
}
/**
* @dev Calculate the total amount of transferable tokens of a holder at a given time
* @param holder address The address of the holder
* @param time uint64 The specific time.
* @return An uint representing a holder's total amount of transferable tokens.
*/
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
uint256 grantIndex = tokenGrantsCount(holder);
if (grantIndex == 0) return balanceOf(holder); // shortcut for holder without grants
// Iterate through all the grants the holder has, and add all non-vested tokens
uint256 nonVested = 0;
for (uint256 i = 0; i < grantIndex; i++) {
nonVested = SafeMath.add(nonVested, nonVestedTokens(grants[holder][i], time));
}
// Balance - totalNonVested is the amount of tokens a holder can transfer at any given time
uint256 vestedTransferable = SafeMath.sub(balanceOf(holder), nonVested);
// Return the minimum of how many vested can transfer and other value
// in case there are other limiting transferability factors (default is balanceOf)
return SafeMath.min256(vestedTransferable, super.transferableTokens(holder, time));
}
/**
* @dev Check the amount of grants that an address has.
* @param _holder The holder of the grants.
* @return A uint representing the total amount of grants.
*/
function tokenGrantsCount(address _holder) constant returns (uint index) {
return grants[_holder].length;
}
/**
* @dev Calculate amount of vested tokens at a specifc time.
* @param tokens uint256 The amount of tokens grantted.
* @param time uint64 The time to be checked
* @param start uint64 A time representing the begining of the grant
* @param cliff uint64 The cliff period.
* @param vesting uint64 The vesting period.
* @return An uint representing the amount of vested tokensof a specif grant.
* transferableTokens
* | _/-------- vestedTokens rect
* | _/
* | _/
* | _/
* | _/
* | /
* | .|
* | . |
* | . |
* | . |
* | . |
* | . |
* +===+===========+---------+----------> time
* Start Clift Vesting
*/
function calculateVestedTokens(
uint256 tokens,
uint256 time,
uint256 start,
uint256 cliff,
uint256 vesting) constant returns (uint256)
{
// Shortcuts for before cliff and after vesting cases.
if (time < cliff) return 0;
if (time >= vesting) return tokens;
// Interpolate all vested tokens.
// As before cliff the shortcut returns 0, we can use just calculate a value
// in the vesting rect (as shown in above's figure)
// vestedTokens = tokens * (time - start) / (vesting - start)
uint256 vestedTokens = SafeMath.div(
SafeMath.mul(
tokens,
SafeMath.sub(time, start)
),
SafeMath.sub(vesting, start)
);
return vestedTokens;
}
/**
* @dev Get all information about a specifc grant.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
* @return Returns all the values that represent a TokenGrant(address, value, start, cliff,
* revokability, burnsOnRevoke, and vesting) plus the vested value at the current time.
*/
function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
TokenGrant grant = grants[_holder][_grantId];
granter = grant.granter;
value = grant.value;
start = grant.start;
cliff = grant.cliff;
vesting = grant.vesting;
revokable = grant.revokable;
burnsOnRevoke = grant.burnsOnRevoke;
vested = vestedTokens(grant, uint64(now));
}
/**
* @dev Get the amount of vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time The time to be checked
* @return An uint representing the amount of vested tokens of a specific grant at a specific time.
*/
function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return calculateVestedTokens(
grant.value,
uint256(time),
uint256(grant.start),
uint256(grant.cliff),
uint256(grant.vesting)
);
}
/**
* @dev Calculate the amount of non vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time uint64 The time to be checked
* @return An uint representing the amount of non vested tokens of a specifc grant on the
* passed time frame.
*/
function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return grant.value.sub(vestedTokens(grant, time));
}
/**
* @dev Calculate the date when the holder can trasfer all its tokens
* @param holder address The address of the holder
* @return An uint representing the date of the last transferable tokens.
*/
function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
date = uint64(now);
uint256 grantIndex = grants[holder].length;
for (uint256 i = 0; i < grantIndex; i++) {
date = SafeMath.max64(grants[holder][i].vesting, date);
}
}
} | /**
* @title Vested token
* @dev Tokens that can be vested for a group of addresses.
*/ | NatSpecMultiLine | tokenGrantsCount | function tokenGrantsCount(address _holder) constant returns (uint index) {
return grants[_holder].length;
}
| /**
* @dev Check the amount of grants that an address has.
* @param _holder The holder of the grants.
* @return A uint representing the total amount of grants.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
4342,
4460
]
} | 6,589 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | VestedToken | contract VestedToken is StandardToken, LimitedTransferToken {
uint256 MAX_GRANTS_PER_ADDRESS = 20;
struct TokenGrant {
address granter; // 20 bytes
uint256 value; // 32 bytes
uint64 cliff;
uint64 vesting;
uint64 start; // 3 * 8 = 24 bytes
bool revokable;
bool burnsOnRevoke; // 2 * 1 = 2 bits? or 2 bytes?
} // total 78 bytes = 3 sstore per operation (32 per sstore)
mapping (address => TokenGrant[]) public grants;
event NewTokenGrant(address indexed from, address indexed to, uint256 value, uint256 grantId);
/**
* @dev Grant tokens to a specified address
* @param _to address The address which the tokens will be granted to.
* @param _value uint256 The amount of tokens to be granted.
* @param _start uint64 Time of the beginning of the grant.
* @param _cliff uint64 Time of the cliff period.
* @param _vesting uint64 The vesting period.
*/
function grantVestedTokens(
address _to,
uint256 _value,
uint64 _start,
uint64 _cliff,
uint64 _vesting,
bool _revokable,
bool _burnsOnRevoke
) public {
// Check for date inconsistencies that may cause unexpected behavior
if (_cliff < _start || _vesting < _cliff) {
throw;
}
if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) throw; // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting).
uint count = grants[_to].push(
TokenGrant(
_revokable ? msg.sender : 0, // avoid storing an extra 20 bytes when it is non-revokable
_value,
_cliff,
_vesting,
_start,
_revokable,
_burnsOnRevoke
)
);
transfer(_to, _value);
NewTokenGrant(msg.sender, _to, _value, count - 1);
}
/**
* @dev Revoke the grant of tokens of a specifed address.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
*/
function revokeTokenGrant(address _holder, uint _grantId) public {
TokenGrant grant = grants[_holder][_grantId];
if (!grant.revokable) { // Check if grant was revokable
throw;
}
if (grant.granter != msg.sender) { // Only granter can revoke it
throw;
}
address receiver = grant.burnsOnRevoke ? 0xdead : msg.sender;
uint256 nonVested = nonVestedTokens(grant, uint64(now));
// remove grant from array
delete grants[_holder][_grantId];
grants[_holder][_grantId] = grants[_holder][grants[_holder].length.sub(1)];
grants[_holder].length -= 1;
balances[receiver] = balances[receiver].add(nonVested);
balances[_holder] = balances[_holder].sub(nonVested);
Transfer(_holder, receiver, nonVested);
}
/**
* @dev Calculate the total amount of transferable tokens of a holder at a given time
* @param holder address The address of the holder
* @param time uint64 The specific time.
* @return An uint representing a holder's total amount of transferable tokens.
*/
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
uint256 grantIndex = tokenGrantsCount(holder);
if (grantIndex == 0) return balanceOf(holder); // shortcut for holder without grants
// Iterate through all the grants the holder has, and add all non-vested tokens
uint256 nonVested = 0;
for (uint256 i = 0; i < grantIndex; i++) {
nonVested = SafeMath.add(nonVested, nonVestedTokens(grants[holder][i], time));
}
// Balance - totalNonVested is the amount of tokens a holder can transfer at any given time
uint256 vestedTransferable = SafeMath.sub(balanceOf(holder), nonVested);
// Return the minimum of how many vested can transfer and other value
// in case there are other limiting transferability factors (default is balanceOf)
return SafeMath.min256(vestedTransferable, super.transferableTokens(holder, time));
}
/**
* @dev Check the amount of grants that an address has.
* @param _holder The holder of the grants.
* @return A uint representing the total amount of grants.
*/
function tokenGrantsCount(address _holder) constant returns (uint index) {
return grants[_holder].length;
}
/**
* @dev Calculate amount of vested tokens at a specifc time.
* @param tokens uint256 The amount of tokens grantted.
* @param time uint64 The time to be checked
* @param start uint64 A time representing the begining of the grant
* @param cliff uint64 The cliff period.
* @param vesting uint64 The vesting period.
* @return An uint representing the amount of vested tokensof a specif grant.
* transferableTokens
* | _/-------- vestedTokens rect
* | _/
* | _/
* | _/
* | _/
* | /
* | .|
* | . |
* | . |
* | . |
* | . |
* | . |
* +===+===========+---------+----------> time
* Start Clift Vesting
*/
function calculateVestedTokens(
uint256 tokens,
uint256 time,
uint256 start,
uint256 cliff,
uint256 vesting) constant returns (uint256)
{
// Shortcuts for before cliff and after vesting cases.
if (time < cliff) return 0;
if (time >= vesting) return tokens;
// Interpolate all vested tokens.
// As before cliff the shortcut returns 0, we can use just calculate a value
// in the vesting rect (as shown in above's figure)
// vestedTokens = tokens * (time - start) / (vesting - start)
uint256 vestedTokens = SafeMath.div(
SafeMath.mul(
tokens,
SafeMath.sub(time, start)
),
SafeMath.sub(vesting, start)
);
return vestedTokens;
}
/**
* @dev Get all information about a specifc grant.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
* @return Returns all the values that represent a TokenGrant(address, value, start, cliff,
* revokability, burnsOnRevoke, and vesting) plus the vested value at the current time.
*/
function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
TokenGrant grant = grants[_holder][_grantId];
granter = grant.granter;
value = grant.value;
start = grant.start;
cliff = grant.cliff;
vesting = grant.vesting;
revokable = grant.revokable;
burnsOnRevoke = grant.burnsOnRevoke;
vested = vestedTokens(grant, uint64(now));
}
/**
* @dev Get the amount of vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time The time to be checked
* @return An uint representing the amount of vested tokens of a specific grant at a specific time.
*/
function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return calculateVestedTokens(
grant.value,
uint256(time),
uint256(grant.start),
uint256(grant.cliff),
uint256(grant.vesting)
);
}
/**
* @dev Calculate the amount of non vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time uint64 The time to be checked
* @return An uint representing the amount of non vested tokens of a specifc grant on the
* passed time frame.
*/
function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return grant.value.sub(vestedTokens(grant, time));
}
/**
* @dev Calculate the date when the holder can trasfer all its tokens
* @param holder address The address of the holder
* @return An uint representing the date of the last transferable tokens.
*/
function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
date = uint64(now);
uint256 grantIndex = grants[holder].length;
for (uint256 i = 0; i < grantIndex; i++) {
date = SafeMath.max64(grants[holder][i].vesting, date);
}
}
} | /**
* @title Vested token
* @dev Tokens that can be vested for a group of addresses.
*/ | NatSpecMultiLine | calculateVestedTokens | function calculateVestedTokens(
uint256 tokens,
uint256 time,
uint256 start,
uint256 cliff,
uint256 vesting) constant returns (uint256)
{
// Shortcuts for before cliff and after vesting cases.
if (time < cliff) return 0;
if (time >= vesting) return tokens;
// Interpolate all vested tokens.
// As before cliff the shortcut returns 0, we can use just calculate a value
// in the vesting rect (as shown in above's figure)
// vestedTokens = tokens * (time - start) / (vesting - start)
uint256 vestedTokens = SafeMath.div(
SafeMath.mul(
tokens,
SafeMath.sub(time, start)
),
SafeMath.sub(vesting, start)
);
return vestedTokens;
}
| /**
* @dev Calculate amount of vested tokens at a specifc time.
* @param tokens uint256 The amount of tokens grantted.
* @param time uint64 The time to be checked
* @param start uint64 A time representing the begining of the grant
* @param cliff uint64 The cliff period.
* @param vesting uint64 The vesting period.
* @return An uint representing the amount of vested tokensof a specif grant.
* transferableTokens
* | _/-------- vestedTokens rect
* | _/
* | _/
* | _/
* | _/
* | /
* | .|
* | . |
* | . |
* | . |
* | . |
* | . |
* +===+===========+---------+----------> time
* Start Clift Vesting
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
5387,
6344
]
} | 6,590 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | VestedToken | contract VestedToken is StandardToken, LimitedTransferToken {
uint256 MAX_GRANTS_PER_ADDRESS = 20;
struct TokenGrant {
address granter; // 20 bytes
uint256 value; // 32 bytes
uint64 cliff;
uint64 vesting;
uint64 start; // 3 * 8 = 24 bytes
bool revokable;
bool burnsOnRevoke; // 2 * 1 = 2 bits? or 2 bytes?
} // total 78 bytes = 3 sstore per operation (32 per sstore)
mapping (address => TokenGrant[]) public grants;
event NewTokenGrant(address indexed from, address indexed to, uint256 value, uint256 grantId);
/**
* @dev Grant tokens to a specified address
* @param _to address The address which the tokens will be granted to.
* @param _value uint256 The amount of tokens to be granted.
* @param _start uint64 Time of the beginning of the grant.
* @param _cliff uint64 Time of the cliff period.
* @param _vesting uint64 The vesting period.
*/
function grantVestedTokens(
address _to,
uint256 _value,
uint64 _start,
uint64 _cliff,
uint64 _vesting,
bool _revokable,
bool _burnsOnRevoke
) public {
// Check for date inconsistencies that may cause unexpected behavior
if (_cliff < _start || _vesting < _cliff) {
throw;
}
if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) throw; // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting).
uint count = grants[_to].push(
TokenGrant(
_revokable ? msg.sender : 0, // avoid storing an extra 20 bytes when it is non-revokable
_value,
_cliff,
_vesting,
_start,
_revokable,
_burnsOnRevoke
)
);
transfer(_to, _value);
NewTokenGrant(msg.sender, _to, _value, count - 1);
}
/**
* @dev Revoke the grant of tokens of a specifed address.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
*/
function revokeTokenGrant(address _holder, uint _grantId) public {
TokenGrant grant = grants[_holder][_grantId];
if (!grant.revokable) { // Check if grant was revokable
throw;
}
if (grant.granter != msg.sender) { // Only granter can revoke it
throw;
}
address receiver = grant.burnsOnRevoke ? 0xdead : msg.sender;
uint256 nonVested = nonVestedTokens(grant, uint64(now));
// remove grant from array
delete grants[_holder][_grantId];
grants[_holder][_grantId] = grants[_holder][grants[_holder].length.sub(1)];
grants[_holder].length -= 1;
balances[receiver] = balances[receiver].add(nonVested);
balances[_holder] = balances[_holder].sub(nonVested);
Transfer(_holder, receiver, nonVested);
}
/**
* @dev Calculate the total amount of transferable tokens of a holder at a given time
* @param holder address The address of the holder
* @param time uint64 The specific time.
* @return An uint representing a holder's total amount of transferable tokens.
*/
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
uint256 grantIndex = tokenGrantsCount(holder);
if (grantIndex == 0) return balanceOf(holder); // shortcut for holder without grants
// Iterate through all the grants the holder has, and add all non-vested tokens
uint256 nonVested = 0;
for (uint256 i = 0; i < grantIndex; i++) {
nonVested = SafeMath.add(nonVested, nonVestedTokens(grants[holder][i], time));
}
// Balance - totalNonVested is the amount of tokens a holder can transfer at any given time
uint256 vestedTransferable = SafeMath.sub(balanceOf(holder), nonVested);
// Return the minimum of how many vested can transfer and other value
// in case there are other limiting transferability factors (default is balanceOf)
return SafeMath.min256(vestedTransferable, super.transferableTokens(holder, time));
}
/**
* @dev Check the amount of grants that an address has.
* @param _holder The holder of the grants.
* @return A uint representing the total amount of grants.
*/
function tokenGrantsCount(address _holder) constant returns (uint index) {
return grants[_holder].length;
}
/**
* @dev Calculate amount of vested tokens at a specifc time.
* @param tokens uint256 The amount of tokens grantted.
* @param time uint64 The time to be checked
* @param start uint64 A time representing the begining of the grant
* @param cliff uint64 The cliff period.
* @param vesting uint64 The vesting period.
* @return An uint representing the amount of vested tokensof a specif grant.
* transferableTokens
* | _/-------- vestedTokens rect
* | _/
* | _/
* | _/
* | _/
* | /
* | .|
* | . |
* | . |
* | . |
* | . |
* | . |
* +===+===========+---------+----------> time
* Start Clift Vesting
*/
function calculateVestedTokens(
uint256 tokens,
uint256 time,
uint256 start,
uint256 cliff,
uint256 vesting) constant returns (uint256)
{
// Shortcuts for before cliff and after vesting cases.
if (time < cliff) return 0;
if (time >= vesting) return tokens;
// Interpolate all vested tokens.
// As before cliff the shortcut returns 0, we can use just calculate a value
// in the vesting rect (as shown in above's figure)
// vestedTokens = tokens * (time - start) / (vesting - start)
uint256 vestedTokens = SafeMath.div(
SafeMath.mul(
tokens,
SafeMath.sub(time, start)
),
SafeMath.sub(vesting, start)
);
return vestedTokens;
}
/**
* @dev Get all information about a specifc grant.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
* @return Returns all the values that represent a TokenGrant(address, value, start, cliff,
* revokability, burnsOnRevoke, and vesting) plus the vested value at the current time.
*/
function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
TokenGrant grant = grants[_holder][_grantId];
granter = grant.granter;
value = grant.value;
start = grant.start;
cliff = grant.cliff;
vesting = grant.vesting;
revokable = grant.revokable;
burnsOnRevoke = grant.burnsOnRevoke;
vested = vestedTokens(grant, uint64(now));
}
/**
* @dev Get the amount of vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time The time to be checked
* @return An uint representing the amount of vested tokens of a specific grant at a specific time.
*/
function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return calculateVestedTokens(
grant.value,
uint256(time),
uint256(grant.start),
uint256(grant.cliff),
uint256(grant.vesting)
);
}
/**
* @dev Calculate the amount of non vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time uint64 The time to be checked
* @return An uint representing the amount of non vested tokens of a specifc grant on the
* passed time frame.
*/
function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return grant.value.sub(vestedTokens(grant, time));
}
/**
* @dev Calculate the date when the holder can trasfer all its tokens
* @param holder address The address of the holder
* @return An uint representing the date of the last transferable tokens.
*/
function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
date = uint64(now);
uint256 grantIndex = grants[holder].length;
for (uint256 i = 0; i < grantIndex; i++) {
date = SafeMath.max64(grants[holder][i].vesting, date);
}
}
} | /**
* @title Vested token
* @dev Tokens that can be vested for a group of addresses.
*/ | NatSpecMultiLine | tokenGrant | function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
TokenGrant grant = grants[_holder][_grantId];
granter = grant.granter;
value = grant.value;
start = grant.start;
cliff = grant.cliff;
vesting = grant.vesting;
revokable = grant.revokable;
burnsOnRevoke = grant.burnsOnRevoke;
vested = vestedTokens(grant, uint64(now));
}
| /**
* @dev Get all information about a specifc grant.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
* @return Returns all the values that represent a TokenGrant(address, value, start, cliff,
* revokability, burnsOnRevoke, and vesting) plus the vested value at the current time.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
6719,
7243
]
} | 6,591 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | VestedToken | contract VestedToken is StandardToken, LimitedTransferToken {
uint256 MAX_GRANTS_PER_ADDRESS = 20;
struct TokenGrant {
address granter; // 20 bytes
uint256 value; // 32 bytes
uint64 cliff;
uint64 vesting;
uint64 start; // 3 * 8 = 24 bytes
bool revokable;
bool burnsOnRevoke; // 2 * 1 = 2 bits? or 2 bytes?
} // total 78 bytes = 3 sstore per operation (32 per sstore)
mapping (address => TokenGrant[]) public grants;
event NewTokenGrant(address indexed from, address indexed to, uint256 value, uint256 grantId);
/**
* @dev Grant tokens to a specified address
* @param _to address The address which the tokens will be granted to.
* @param _value uint256 The amount of tokens to be granted.
* @param _start uint64 Time of the beginning of the grant.
* @param _cliff uint64 Time of the cliff period.
* @param _vesting uint64 The vesting period.
*/
function grantVestedTokens(
address _to,
uint256 _value,
uint64 _start,
uint64 _cliff,
uint64 _vesting,
bool _revokable,
bool _burnsOnRevoke
) public {
// Check for date inconsistencies that may cause unexpected behavior
if (_cliff < _start || _vesting < _cliff) {
throw;
}
if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) throw; // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting).
uint count = grants[_to].push(
TokenGrant(
_revokable ? msg.sender : 0, // avoid storing an extra 20 bytes when it is non-revokable
_value,
_cliff,
_vesting,
_start,
_revokable,
_burnsOnRevoke
)
);
transfer(_to, _value);
NewTokenGrant(msg.sender, _to, _value, count - 1);
}
/**
* @dev Revoke the grant of tokens of a specifed address.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
*/
function revokeTokenGrant(address _holder, uint _grantId) public {
TokenGrant grant = grants[_holder][_grantId];
if (!grant.revokable) { // Check if grant was revokable
throw;
}
if (grant.granter != msg.sender) { // Only granter can revoke it
throw;
}
address receiver = grant.burnsOnRevoke ? 0xdead : msg.sender;
uint256 nonVested = nonVestedTokens(grant, uint64(now));
// remove grant from array
delete grants[_holder][_grantId];
grants[_holder][_grantId] = grants[_holder][grants[_holder].length.sub(1)];
grants[_holder].length -= 1;
balances[receiver] = balances[receiver].add(nonVested);
balances[_holder] = balances[_holder].sub(nonVested);
Transfer(_holder, receiver, nonVested);
}
/**
* @dev Calculate the total amount of transferable tokens of a holder at a given time
* @param holder address The address of the holder
* @param time uint64 The specific time.
* @return An uint representing a holder's total amount of transferable tokens.
*/
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
uint256 grantIndex = tokenGrantsCount(holder);
if (grantIndex == 0) return balanceOf(holder); // shortcut for holder without grants
// Iterate through all the grants the holder has, and add all non-vested tokens
uint256 nonVested = 0;
for (uint256 i = 0; i < grantIndex; i++) {
nonVested = SafeMath.add(nonVested, nonVestedTokens(grants[holder][i], time));
}
// Balance - totalNonVested is the amount of tokens a holder can transfer at any given time
uint256 vestedTransferable = SafeMath.sub(balanceOf(holder), nonVested);
// Return the minimum of how many vested can transfer and other value
// in case there are other limiting transferability factors (default is balanceOf)
return SafeMath.min256(vestedTransferable, super.transferableTokens(holder, time));
}
/**
* @dev Check the amount of grants that an address has.
* @param _holder The holder of the grants.
* @return A uint representing the total amount of grants.
*/
function tokenGrantsCount(address _holder) constant returns (uint index) {
return grants[_holder].length;
}
/**
* @dev Calculate amount of vested tokens at a specifc time.
* @param tokens uint256 The amount of tokens grantted.
* @param time uint64 The time to be checked
* @param start uint64 A time representing the begining of the grant
* @param cliff uint64 The cliff period.
* @param vesting uint64 The vesting period.
* @return An uint representing the amount of vested tokensof a specif grant.
* transferableTokens
* | _/-------- vestedTokens rect
* | _/
* | _/
* | _/
* | _/
* | /
* | .|
* | . |
* | . |
* | . |
* | . |
* | . |
* +===+===========+---------+----------> time
* Start Clift Vesting
*/
function calculateVestedTokens(
uint256 tokens,
uint256 time,
uint256 start,
uint256 cliff,
uint256 vesting) constant returns (uint256)
{
// Shortcuts for before cliff and after vesting cases.
if (time < cliff) return 0;
if (time >= vesting) return tokens;
// Interpolate all vested tokens.
// As before cliff the shortcut returns 0, we can use just calculate a value
// in the vesting rect (as shown in above's figure)
// vestedTokens = tokens * (time - start) / (vesting - start)
uint256 vestedTokens = SafeMath.div(
SafeMath.mul(
tokens,
SafeMath.sub(time, start)
),
SafeMath.sub(vesting, start)
);
return vestedTokens;
}
/**
* @dev Get all information about a specifc grant.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
* @return Returns all the values that represent a TokenGrant(address, value, start, cliff,
* revokability, burnsOnRevoke, and vesting) plus the vested value at the current time.
*/
function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
TokenGrant grant = grants[_holder][_grantId];
granter = grant.granter;
value = grant.value;
start = grant.start;
cliff = grant.cliff;
vesting = grant.vesting;
revokable = grant.revokable;
burnsOnRevoke = grant.burnsOnRevoke;
vested = vestedTokens(grant, uint64(now));
}
/**
* @dev Get the amount of vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time The time to be checked
* @return An uint representing the amount of vested tokens of a specific grant at a specific time.
*/
function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return calculateVestedTokens(
grant.value,
uint256(time),
uint256(grant.start),
uint256(grant.cliff),
uint256(grant.vesting)
);
}
/**
* @dev Calculate the amount of non vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time uint64 The time to be checked
* @return An uint representing the amount of non vested tokens of a specifc grant on the
* passed time frame.
*/
function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return grant.value.sub(vestedTokens(grant, time));
}
/**
* @dev Calculate the date when the holder can trasfer all its tokens
* @param holder address The address of the holder
* @return An uint representing the date of the last transferable tokens.
*/
function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
date = uint64(now);
uint256 grantIndex = grants[holder].length;
for (uint256 i = 0; i < grantIndex; i++) {
date = SafeMath.max64(grants[holder][i].vesting, date);
}
}
} | /**
* @title Vested token
* @dev Tokens that can be vested for a group of addresses.
*/ | NatSpecMultiLine | vestedTokens | function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return calculateVestedTokens(
grant.value,
uint256(time),
uint256(grant.start),
uint256(grant.cliff),
uint256(grant.vesting)
);
}
| /**
* @dev Get the amount of vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time The time to be checked
* @return An uint representing the amount of vested tokens of a specific grant at a specific time.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
7522,
7792
]
} | 6,592 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | VestedToken | contract VestedToken is StandardToken, LimitedTransferToken {
uint256 MAX_GRANTS_PER_ADDRESS = 20;
struct TokenGrant {
address granter; // 20 bytes
uint256 value; // 32 bytes
uint64 cliff;
uint64 vesting;
uint64 start; // 3 * 8 = 24 bytes
bool revokable;
bool burnsOnRevoke; // 2 * 1 = 2 bits? or 2 bytes?
} // total 78 bytes = 3 sstore per operation (32 per sstore)
mapping (address => TokenGrant[]) public grants;
event NewTokenGrant(address indexed from, address indexed to, uint256 value, uint256 grantId);
/**
* @dev Grant tokens to a specified address
* @param _to address The address which the tokens will be granted to.
* @param _value uint256 The amount of tokens to be granted.
* @param _start uint64 Time of the beginning of the grant.
* @param _cliff uint64 Time of the cliff period.
* @param _vesting uint64 The vesting period.
*/
function grantVestedTokens(
address _to,
uint256 _value,
uint64 _start,
uint64 _cliff,
uint64 _vesting,
bool _revokable,
bool _burnsOnRevoke
) public {
// Check for date inconsistencies that may cause unexpected behavior
if (_cliff < _start || _vesting < _cliff) {
throw;
}
if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) throw; // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting).
uint count = grants[_to].push(
TokenGrant(
_revokable ? msg.sender : 0, // avoid storing an extra 20 bytes when it is non-revokable
_value,
_cliff,
_vesting,
_start,
_revokable,
_burnsOnRevoke
)
);
transfer(_to, _value);
NewTokenGrant(msg.sender, _to, _value, count - 1);
}
/**
* @dev Revoke the grant of tokens of a specifed address.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
*/
function revokeTokenGrant(address _holder, uint _grantId) public {
TokenGrant grant = grants[_holder][_grantId];
if (!grant.revokable) { // Check if grant was revokable
throw;
}
if (grant.granter != msg.sender) { // Only granter can revoke it
throw;
}
address receiver = grant.burnsOnRevoke ? 0xdead : msg.sender;
uint256 nonVested = nonVestedTokens(grant, uint64(now));
// remove grant from array
delete grants[_holder][_grantId];
grants[_holder][_grantId] = grants[_holder][grants[_holder].length.sub(1)];
grants[_holder].length -= 1;
balances[receiver] = balances[receiver].add(nonVested);
balances[_holder] = balances[_holder].sub(nonVested);
Transfer(_holder, receiver, nonVested);
}
/**
* @dev Calculate the total amount of transferable tokens of a holder at a given time
* @param holder address The address of the holder
* @param time uint64 The specific time.
* @return An uint representing a holder's total amount of transferable tokens.
*/
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
uint256 grantIndex = tokenGrantsCount(holder);
if (grantIndex == 0) return balanceOf(holder); // shortcut for holder without grants
// Iterate through all the grants the holder has, and add all non-vested tokens
uint256 nonVested = 0;
for (uint256 i = 0; i < grantIndex; i++) {
nonVested = SafeMath.add(nonVested, nonVestedTokens(grants[holder][i], time));
}
// Balance - totalNonVested is the amount of tokens a holder can transfer at any given time
uint256 vestedTransferable = SafeMath.sub(balanceOf(holder), nonVested);
// Return the minimum of how many vested can transfer and other value
// in case there are other limiting transferability factors (default is balanceOf)
return SafeMath.min256(vestedTransferable, super.transferableTokens(holder, time));
}
/**
* @dev Check the amount of grants that an address has.
* @param _holder The holder of the grants.
* @return A uint representing the total amount of grants.
*/
function tokenGrantsCount(address _holder) constant returns (uint index) {
return grants[_holder].length;
}
/**
* @dev Calculate amount of vested tokens at a specifc time.
* @param tokens uint256 The amount of tokens grantted.
* @param time uint64 The time to be checked
* @param start uint64 A time representing the begining of the grant
* @param cliff uint64 The cliff period.
* @param vesting uint64 The vesting period.
* @return An uint representing the amount of vested tokensof a specif grant.
* transferableTokens
* | _/-------- vestedTokens rect
* | _/
* | _/
* | _/
* | _/
* | /
* | .|
* | . |
* | . |
* | . |
* | . |
* | . |
* +===+===========+---------+----------> time
* Start Clift Vesting
*/
function calculateVestedTokens(
uint256 tokens,
uint256 time,
uint256 start,
uint256 cliff,
uint256 vesting) constant returns (uint256)
{
// Shortcuts for before cliff and after vesting cases.
if (time < cliff) return 0;
if (time >= vesting) return tokens;
// Interpolate all vested tokens.
// As before cliff the shortcut returns 0, we can use just calculate a value
// in the vesting rect (as shown in above's figure)
// vestedTokens = tokens * (time - start) / (vesting - start)
uint256 vestedTokens = SafeMath.div(
SafeMath.mul(
tokens,
SafeMath.sub(time, start)
),
SafeMath.sub(vesting, start)
);
return vestedTokens;
}
/**
* @dev Get all information about a specifc grant.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
* @return Returns all the values that represent a TokenGrant(address, value, start, cliff,
* revokability, burnsOnRevoke, and vesting) plus the vested value at the current time.
*/
function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
TokenGrant grant = grants[_holder][_grantId];
granter = grant.granter;
value = grant.value;
start = grant.start;
cliff = grant.cliff;
vesting = grant.vesting;
revokable = grant.revokable;
burnsOnRevoke = grant.burnsOnRevoke;
vested = vestedTokens(grant, uint64(now));
}
/**
* @dev Get the amount of vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time The time to be checked
* @return An uint representing the amount of vested tokens of a specific grant at a specific time.
*/
function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return calculateVestedTokens(
grant.value,
uint256(time),
uint256(grant.start),
uint256(grant.cliff),
uint256(grant.vesting)
);
}
/**
* @dev Calculate the amount of non vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time uint64 The time to be checked
* @return An uint representing the amount of non vested tokens of a specifc grant on the
* passed time frame.
*/
function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return grant.value.sub(vestedTokens(grant, time));
}
/**
* @dev Calculate the date when the holder can trasfer all its tokens
* @param holder address The address of the holder
* @return An uint representing the date of the last transferable tokens.
*/
function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
date = uint64(now);
uint256 grantIndex = grants[holder].length;
for (uint256 i = 0; i < grantIndex; i++) {
date = SafeMath.max64(grants[holder][i].vesting, date);
}
}
} | /**
* @title Vested token
* @dev Tokens that can be vested for a group of addresses.
*/ | NatSpecMultiLine | nonVestedTokens | function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return grant.value.sub(vestedTokens(grant, time));
}
| /**
* @dev Calculate the amount of non vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time uint64 The time to be checked
* @return An uint representing the amount of non vested tokens of a specifc grant on the
* passed time frame.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
8104,
8260
]
} | 6,593 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | VestedToken | contract VestedToken is StandardToken, LimitedTransferToken {
uint256 MAX_GRANTS_PER_ADDRESS = 20;
struct TokenGrant {
address granter; // 20 bytes
uint256 value; // 32 bytes
uint64 cliff;
uint64 vesting;
uint64 start; // 3 * 8 = 24 bytes
bool revokable;
bool burnsOnRevoke; // 2 * 1 = 2 bits? or 2 bytes?
} // total 78 bytes = 3 sstore per operation (32 per sstore)
mapping (address => TokenGrant[]) public grants;
event NewTokenGrant(address indexed from, address indexed to, uint256 value, uint256 grantId);
/**
* @dev Grant tokens to a specified address
* @param _to address The address which the tokens will be granted to.
* @param _value uint256 The amount of tokens to be granted.
* @param _start uint64 Time of the beginning of the grant.
* @param _cliff uint64 Time of the cliff period.
* @param _vesting uint64 The vesting period.
*/
function grantVestedTokens(
address _to,
uint256 _value,
uint64 _start,
uint64 _cliff,
uint64 _vesting,
bool _revokable,
bool _burnsOnRevoke
) public {
// Check for date inconsistencies that may cause unexpected behavior
if (_cliff < _start || _vesting < _cliff) {
throw;
}
if (tokenGrantsCount(_to) > MAX_GRANTS_PER_ADDRESS) throw; // To prevent a user being spammed and have his balance locked (out of gas attack when calculating vesting).
uint count = grants[_to].push(
TokenGrant(
_revokable ? msg.sender : 0, // avoid storing an extra 20 bytes when it is non-revokable
_value,
_cliff,
_vesting,
_start,
_revokable,
_burnsOnRevoke
)
);
transfer(_to, _value);
NewTokenGrant(msg.sender, _to, _value, count - 1);
}
/**
* @dev Revoke the grant of tokens of a specifed address.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
*/
function revokeTokenGrant(address _holder, uint _grantId) public {
TokenGrant grant = grants[_holder][_grantId];
if (!grant.revokable) { // Check if grant was revokable
throw;
}
if (grant.granter != msg.sender) { // Only granter can revoke it
throw;
}
address receiver = grant.burnsOnRevoke ? 0xdead : msg.sender;
uint256 nonVested = nonVestedTokens(grant, uint64(now));
// remove grant from array
delete grants[_holder][_grantId];
grants[_holder][_grantId] = grants[_holder][grants[_holder].length.sub(1)];
grants[_holder].length -= 1;
balances[receiver] = balances[receiver].add(nonVested);
balances[_holder] = balances[_holder].sub(nonVested);
Transfer(_holder, receiver, nonVested);
}
/**
* @dev Calculate the total amount of transferable tokens of a holder at a given time
* @param holder address The address of the holder
* @param time uint64 The specific time.
* @return An uint representing a holder's total amount of transferable tokens.
*/
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
uint256 grantIndex = tokenGrantsCount(holder);
if (grantIndex == 0) return balanceOf(holder); // shortcut for holder without grants
// Iterate through all the grants the holder has, and add all non-vested tokens
uint256 nonVested = 0;
for (uint256 i = 0; i < grantIndex; i++) {
nonVested = SafeMath.add(nonVested, nonVestedTokens(grants[holder][i], time));
}
// Balance - totalNonVested is the amount of tokens a holder can transfer at any given time
uint256 vestedTransferable = SafeMath.sub(balanceOf(holder), nonVested);
// Return the minimum of how many vested can transfer and other value
// in case there are other limiting transferability factors (default is balanceOf)
return SafeMath.min256(vestedTransferable, super.transferableTokens(holder, time));
}
/**
* @dev Check the amount of grants that an address has.
* @param _holder The holder of the grants.
* @return A uint representing the total amount of grants.
*/
function tokenGrantsCount(address _holder) constant returns (uint index) {
return grants[_holder].length;
}
/**
* @dev Calculate amount of vested tokens at a specifc time.
* @param tokens uint256 The amount of tokens grantted.
* @param time uint64 The time to be checked
* @param start uint64 A time representing the begining of the grant
* @param cliff uint64 The cliff period.
* @param vesting uint64 The vesting period.
* @return An uint representing the amount of vested tokensof a specif grant.
* transferableTokens
* | _/-------- vestedTokens rect
* | _/
* | _/
* | _/
* | _/
* | /
* | .|
* | . |
* | . |
* | . |
* | . |
* | . |
* +===+===========+---------+----------> time
* Start Clift Vesting
*/
function calculateVestedTokens(
uint256 tokens,
uint256 time,
uint256 start,
uint256 cliff,
uint256 vesting) constant returns (uint256)
{
// Shortcuts for before cliff and after vesting cases.
if (time < cliff) return 0;
if (time >= vesting) return tokens;
// Interpolate all vested tokens.
// As before cliff the shortcut returns 0, we can use just calculate a value
// in the vesting rect (as shown in above's figure)
// vestedTokens = tokens * (time - start) / (vesting - start)
uint256 vestedTokens = SafeMath.div(
SafeMath.mul(
tokens,
SafeMath.sub(time, start)
),
SafeMath.sub(vesting, start)
);
return vestedTokens;
}
/**
* @dev Get all information about a specifc grant.
* @param _holder The address which will have its tokens revoked.
* @param _grantId The id of the token grant.
* @return Returns all the values that represent a TokenGrant(address, value, start, cliff,
* revokability, burnsOnRevoke, and vesting) plus the vested value at the current time.
*/
function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
TokenGrant grant = grants[_holder][_grantId];
granter = grant.granter;
value = grant.value;
start = grant.start;
cliff = grant.cliff;
vesting = grant.vesting;
revokable = grant.revokable;
burnsOnRevoke = grant.burnsOnRevoke;
vested = vestedTokens(grant, uint64(now));
}
/**
* @dev Get the amount of vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time The time to be checked
* @return An uint representing the amount of vested tokens of a specific grant at a specific time.
*/
function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return calculateVestedTokens(
grant.value,
uint256(time),
uint256(grant.start),
uint256(grant.cliff),
uint256(grant.vesting)
);
}
/**
* @dev Calculate the amount of non vested tokens at a specific time.
* @param grant TokenGrant The grant to be checked.
* @param time uint64 The time to be checked
* @return An uint representing the amount of non vested tokens of a specifc grant on the
* passed time frame.
*/
function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
return grant.value.sub(vestedTokens(grant, time));
}
/**
* @dev Calculate the date when the holder can trasfer all its tokens
* @param holder address The address of the holder
* @return An uint representing the date of the last transferable tokens.
*/
function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
date = uint64(now);
uint256 grantIndex = grants[holder].length;
for (uint256 i = 0; i < grantIndex; i++) {
date = SafeMath.max64(grants[holder][i].vesting, date);
}
}
} | /**
* @title Vested token
* @dev Tokens that can be vested for a group of addresses.
*/ | NatSpecMultiLine | lastTokenIsTransferableDate | function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
date = uint64(now);
uint256 grantIndex = grants[holder].length;
for (uint256 i = 0; i < grantIndex; i++) {
date = SafeMath.max64(grants[holder][i].vesting, date);
}
}
| /**
* @dev Calculate the date when the holder can trasfer all its tokens
* @param holder address The address of the holder
* @return An uint representing the date of the last transferable tokens.
*/ | NatSpecMultiLine | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
8481,
8773
]
} | 6,594 |
|
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | CDTToken | contract CDTToken is VestedToken {
using SafeMath for uint;
//FIELDS
//CONSTANTS
uint public constant decimals = 18; // 18 decimal places, the same as ETH.
string public constant name = "CoinDash Token";
string public constant symbol = "CDT";
//ASSIGNED IN INITIALIZATION
address public creator; //address of the account which may mint new tokens
//May only be called by the owner address
modifier only_owner() {
if (msg.sender != creator) throw;
_;
}
// Initialization contract assigns address of crowdfund contract and end time.
function CDTToken(uint supply) {
totalSupply = supply;
creator = msg.sender;
balances[msg.sender] = supply;
MAX_GRANTS_PER_ADDRESS = 2;
}
// Fallback function throws when called.
function() {
throw;
}
function vestedBalanceOf(address _owner) constant returns (uint balance) {
return transferableTokens(_owner, uint64(now));
}
//failsafe drain
function drain()
only_owner
{
if (!creator.send(this.balance)) throw;
}
} | CDTToken | function CDTToken(uint supply) {
totalSupply = supply;
creator = msg.sender;
balances[msg.sender] = supply;
MAX_GRANTS_PER_ADDRESS = 2;
}
| // Initialization contract assigns address of crowdfund contract and end time. | LineComment | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
575,
734
]
} | 6,595 |
|||
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | CDTToken | contract CDTToken is VestedToken {
using SafeMath for uint;
//FIELDS
//CONSTANTS
uint public constant decimals = 18; // 18 decimal places, the same as ETH.
string public constant name = "CoinDash Token";
string public constant symbol = "CDT";
//ASSIGNED IN INITIALIZATION
address public creator; //address of the account which may mint new tokens
//May only be called by the owner address
modifier only_owner() {
if (msg.sender != creator) throw;
_;
}
// Initialization contract assigns address of crowdfund contract and end time.
function CDTToken(uint supply) {
totalSupply = supply;
creator = msg.sender;
balances[msg.sender] = supply;
MAX_GRANTS_PER_ADDRESS = 2;
}
// Fallback function throws when called.
function() {
throw;
}
function vestedBalanceOf(address _owner) constant returns (uint balance) {
return transferableTokens(_owner, uint64(now));
}
//failsafe drain
function drain()
only_owner
{
if (!creator.send(this.balance)) throw;
}
} | function() {
throw;
}
| // Fallback function throws when called. | LineComment | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
780,
808
]
} | 6,596 |
||||
CDTToken | CDTToken.sol | 0x8fd36e8ec5b55ac2412e593175b41fd1566e81b3 | Solidity | CDTToken | contract CDTToken is VestedToken {
using SafeMath for uint;
//FIELDS
//CONSTANTS
uint public constant decimals = 18; // 18 decimal places, the same as ETH.
string public constant name = "CoinDash Token";
string public constant symbol = "CDT";
//ASSIGNED IN INITIALIZATION
address public creator; //address of the account which may mint new tokens
//May only be called by the owner address
modifier only_owner() {
if (msg.sender != creator) throw;
_;
}
// Initialization contract assigns address of crowdfund contract and end time.
function CDTToken(uint supply) {
totalSupply = supply;
creator = msg.sender;
balances[msg.sender] = supply;
MAX_GRANTS_PER_ADDRESS = 2;
}
// Fallback function throws when called.
function() {
throw;
}
function vestedBalanceOf(address _owner) constant returns (uint balance) {
return transferableTokens(_owner, uint64(now));
}
//failsafe drain
function drain()
only_owner
{
if (!creator.send(this.balance)) throw;
}
} | drain | function drain()
only_owner
{
if (!creator.send(this.balance)) throw;
}
| //failsafe drain | LineComment | v0.4.8+commit.60cc1668 | bzzr://cda948482ca91b403feb47c3d04aa6b66f868fe80ea247b0dbf908d9ad4e61f3 | {
"func_code_index": [
977,
1060
]
} | 6,597 |
|||
BelottoCoin | BelottoCoin.sol | 0x4c1ed91da2edd5f86c0f4adb8562466f202f0a0a | Solidity | BelottoCoin | contract BelottoCoin is ERC20Interface, Owned{
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function BelottoCoin(address _owner) public{
symbol = "BEL";
name = "Belotto";
decimals = 18;
owner = _owner;
_totalSupply = totalSupply();
balances[owner] = _totalSupply;
emit Transfer(address(0),owner,_totalSupply);
}
function sender() public view returns (address sender){
return msg.sender;
}
function totalSupply() public constant returns (uint){
return 1200000000 * 10**uint(decimals);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint 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, uint tokens) public returns (bool success) {
// prevent transfer to 0x0, use burn instead
require(to != 0x0);
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender,to,tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public 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, uint tokens) public returns (bool success){
require(tokens <= allowed[from][msg.sender]); //check allowance
require(balances[from] >= tokens);
balances[from] = balances[from].sub(tokens);
balances[to] = balances[to].add(tokens);
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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
event Burn(address indexed burner, uint256 value);
function burn(uint256 _value) public {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
Burn(burner, _value);
}
} | BelottoCoin | function BelottoCoin(address _owner) public{
symbol = "BEL";
name = "Belotto";
decimals = 18;
owner = _owner;
_totalSupply = totalSupply();
balances[owner] = _totalSupply;
emit Transfer(address(0),owner,_totalSupply);
}
| // ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------ | LineComment | v0.4.23+commit.124ca40d | bzzr://ab867b62e3b6617cca98eada6291654947614b1abf7b62bcbb0ac94842af649b | {
"func_code_index": [
478,
770
]
} | 6,598 |
|||
BelottoCoin | BelottoCoin.sol | 0x4c1ed91da2edd5f86c0f4adb8562466f202f0a0a | Solidity | BelottoCoin | contract BelottoCoin is ERC20Interface, Owned{
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function BelottoCoin(address _owner) public{
symbol = "BEL";
name = "Belotto";
decimals = 18;
owner = _owner;
_totalSupply = totalSupply();
balances[owner] = _totalSupply;
emit Transfer(address(0),owner,_totalSupply);
}
function sender() public view returns (address sender){
return msg.sender;
}
function totalSupply() public constant returns (uint){
return 1200000000 * 10**uint(decimals);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint 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, uint tokens) public returns (bool success) {
// prevent transfer to 0x0, use burn instead
require(to != 0x0);
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender,to,tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public 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, uint tokens) public returns (bool success){
require(tokens <= allowed[from][msg.sender]); //check allowance
require(balances[from] >= tokens);
balances[from] = balances[from].sub(tokens);
balances[to] = balances[to].add(tokens);
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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
event Burn(address indexed burner, uint256 value);
function burn(uint256 _value) public {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
Burn(burner, _value);
}
} | balanceOf | function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
| // ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------ | LineComment | v0.4.23+commit.124ca40d | bzzr://ab867b62e3b6617cca98eada6291654947614b1abf7b62bcbb0ac94842af649b | {
"func_code_index": [
1209,
1338
]
} | 6,599 |
|||
BelottoCoin | BelottoCoin.sol | 0x4c1ed91da2edd5f86c0f4adb8562466f202f0a0a | Solidity | BelottoCoin | contract BelottoCoin is ERC20Interface, Owned{
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function BelottoCoin(address _owner) public{
symbol = "BEL";
name = "Belotto";
decimals = 18;
owner = _owner;
_totalSupply = totalSupply();
balances[owner] = _totalSupply;
emit Transfer(address(0),owner,_totalSupply);
}
function sender() public view returns (address sender){
return msg.sender;
}
function totalSupply() public constant returns (uint){
return 1200000000 * 10**uint(decimals);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint 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, uint tokens) public returns (bool success) {
// prevent transfer to 0x0, use burn instead
require(to != 0x0);
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender,to,tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public 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, uint tokens) public returns (bool success){
require(tokens <= allowed[from][msg.sender]); //check allowance
require(balances[from] >= tokens);
balances[from] = balances[from].sub(tokens);
balances[to] = balances[to].add(tokens);
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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
event Burn(address indexed burner, uint256 value);
function burn(uint256 _value) public {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
Burn(burner, _value);
}
} | transfer | function transfer(address to, uint tokens) public returns (bool success) {
// prevent transfer to 0x0, use burn instead
require(to != 0x0);
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender,to,tokens);
return true;
}
| // ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------ | LineComment | v0.4.23+commit.124ca40d | bzzr://ab867b62e3b6617cca98eada6291654947614b1abf7b62bcbb0ac94842af649b | {
"func_code_index": [
1682,
2143
]
} | 6,600 |
|||
BelottoCoin | BelottoCoin.sol | 0x4c1ed91da2edd5f86c0f4adb8562466f202f0a0a | Solidity | BelottoCoin | contract BelottoCoin is ERC20Interface, Owned{
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function BelottoCoin(address _owner) public{
symbol = "BEL";
name = "Belotto";
decimals = 18;
owner = _owner;
_totalSupply = totalSupply();
balances[owner] = _totalSupply;
emit Transfer(address(0),owner,_totalSupply);
}
function sender() public view returns (address sender){
return msg.sender;
}
function totalSupply() public constant returns (uint){
return 1200000000 * 10**uint(decimals);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint 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, uint tokens) public returns (bool success) {
// prevent transfer to 0x0, use burn instead
require(to != 0x0);
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender,to,tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public 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, uint tokens) public returns (bool success){
require(tokens <= allowed[from][msg.sender]); //check allowance
require(balances[from] >= tokens);
balances[from] = balances[from].sub(tokens);
balances[to] = balances[to].add(tokens);
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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
event Burn(address indexed burner, uint256 value);
function burn(uint256 _value) public {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
Burn(burner, _value);
}
} | approve | function approve(address spender, uint tokens) public 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.4.23+commit.124ca40d | bzzr://ab867b62e3b6617cca98eada6291654947614b1abf7b62bcbb0ac94842af649b | {
"func_code_index": [
2427,
2637
]
} | 6,601 |
|||
BelottoCoin | BelottoCoin.sol | 0x4c1ed91da2edd5f86c0f4adb8562466f202f0a0a | Solidity | BelottoCoin | contract BelottoCoin is ERC20Interface, Owned{
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function BelottoCoin(address _owner) public{
symbol = "BEL";
name = "Belotto";
decimals = 18;
owner = _owner;
_totalSupply = totalSupply();
balances[owner] = _totalSupply;
emit Transfer(address(0),owner,_totalSupply);
}
function sender() public view returns (address sender){
return msg.sender;
}
function totalSupply() public constant returns (uint){
return 1200000000 * 10**uint(decimals);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint 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, uint tokens) public returns (bool success) {
// prevent transfer to 0x0, use burn instead
require(to != 0x0);
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender,to,tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public 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, uint tokens) public returns (bool success){
require(tokens <= allowed[from][msg.sender]); //check allowance
require(balances[from] >= tokens);
balances[from] = balances[from].sub(tokens);
balances[to] = balances[to].add(tokens);
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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
event Burn(address indexed burner, uint256 value);
function burn(uint256 _value) public {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
Burn(burner, _value);
}
} | transferFrom | function transferFrom(address from, address to, uint tokens) public returns (bool success){
require(tokens <= allowed[from][msg.sender]); //check allowance
require(balances[from] >= tokens);
balances[from] = balances[from].sub(tokens);
balances[to] = balances[to].add(tokens);
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.4.23+commit.124ca40d | bzzr://ab867b62e3b6617cca98eada6291654947614b1abf7b62bcbb0ac94842af649b | {
"func_code_index": [
3174,
3636
]
} | 6,602 |
|||
BelottoCoin | BelottoCoin.sol | 0x4c1ed91da2edd5f86c0f4adb8562466f202f0a0a | Solidity | BelottoCoin | contract BelottoCoin is ERC20Interface, Owned{
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function BelottoCoin(address _owner) public{
symbol = "BEL";
name = "Belotto";
decimals = 18;
owner = _owner;
_totalSupply = totalSupply();
balances[owner] = _totalSupply;
emit Transfer(address(0),owner,_totalSupply);
}
function sender() public view returns (address sender){
return msg.sender;
}
function totalSupply() public constant returns (uint){
return 1200000000 * 10**uint(decimals);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint 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, uint tokens) public returns (bool success) {
// prevent transfer to 0x0, use burn instead
require(to != 0x0);
require(balances[msg.sender] >= tokens );
require(balances[to] + tokens >= balances[to]);
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender,to,tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public 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, uint tokens) public returns (bool success){
require(tokens <= allowed[from][msg.sender]); //check allowance
require(balances[from] >= tokens);
balances[from] = balances[from].sub(tokens);
balances[to] = balances[to].add(tokens);
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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
event Burn(address indexed burner, uint256 value);
function burn(uint256 _value) public {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
Burn(burner, _value);
}
} | allowance | function allowance(address tokenOwner, address spender) public constant returns (uint 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.4.23+commit.124ca40d | bzzr://ab867b62e3b6617cca98eada6291654947614b1abf7b62bcbb0ac94842af649b | {
"func_code_index": [
3915,
4071
]
} | 6,603 |
|||
DiemlibreFaucet | DiemlibreFaucet.sol | 0x46c8f3059145e1b69acf2f926a5bcc1d1ad82129 | Solidity | DiemlibreFaucet | contract DiemlibreFaucet {
struct State {
bool isInit;
address self;
address owner;
address holder;
uint256 faucetAmount; // In smallest unit WEI
uint256 maxPageBuffer;
}
IERC20 DLB;
address[] savedAddresses;
mapping(address => bool) sentAddresses;
State currentState;
constructor(address _tokenAddress, address _holderAddress) {
require(_tokenAddress != address(0), "Error! Invalid Token Address.");
require(_holderAddress != address(0), "Error! Invalid Holder Address.");
require(_tokenAddress != _holderAddress, "Token Address and Spender Address cann't be the same.");
currentState = State({
isInit: false,
self: address(0),
owner: msg.sender,
holder: _holderAddress,
faucetAmount: 2000000000000000000000,
maxPageBuffer: 1000
});
DLB = IERC20(_tokenAddress);
}
function _withdrawETHToOwner(uint256 _amount) private returns(bool) {
payable(currentState.owner).transfer(_amount);
return true;
}
function getCurrentState() external view returns(State memory) {
return currentState;
}
/**
* Method: faucet
* Des: To send a speicific amout of $DLB to addresses and you pay for gas.
**/
function diemlibreFaucet(address _faucetAddress) external returns(bool) {
require(sentAddresses[_faucetAddress] == false, "Error 501: Address has already been fauced with DLB.");
require(currentState.isInit, "Error 500: Contract Not Initialized or Contract Turned Off.");
uint256 tokenAllowance = DLB.allowance(currentState.holder, currentState.self);
require(currentState.faucetAmount > 0 && currentState.faucetAmount <= tokenAllowance, "Error 502: Insufficient Liquidity");
require(DLB.transferFrom(currentState.holder, _faucetAddress, currentState.faucetAmount), "Error 503: Oops... Could not complete Transaction. Please try again later.");
sentAddresses[_faucetAddress] = true;
savedAddresses.push(_faucetAddress);
return true;
}
// Owner Functions
function init(address _selfAddress) external returns(bool) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
currentState.self = _selfAddress;
currentState.isInit = true;
return true;
}
function power(bool _state) external returns(State memory) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
currentState.isInit = _state;
return currentState;
}
function getSavedAddressesLength() external view returns(uint256) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
return savedAddresses.length;
}
function getSavedAddresses(uint256 _page) external view returns(address[] memory) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
require(_page >= 1, "Error 400: Invalid Page Number.");
uint256 i;
uint256 j = 0;
address[] memory res;
uint256 lowerLimit;
uint256 upperLimit;
uint256 tempUpperLimit = _page * currentState.maxPageBuffer;
if(savedAddresses.length < tempUpperLimit) {
if(savedAddresses.length < currentState.maxPageBuffer) lowerLimit = 0;
else lowerLimit = (_page - 1) * currentState.maxPageBuffer;
upperLimit = savedAddresses.length;
// If an unvailable page is requested lowerLimit will be greater than upperLimit
if(lowerLimit > upperLimit) return res;
// If lowerLimit == 0, then you should requesting for only page 1
if(lowerLimit == 0 && _page > 1) return res;
} else {
lowerLimit = (_page - 1) * currentState.maxPageBuffer;
upperLimit = tempUpperLimit;
}
uint256 resLength = upperLimit - lowerLimit;
res = new address[](resLength);
for(i = lowerLimit; i < upperLimit; i++) {
res[j] = savedAddresses[i];
j++;
}
return res;
}
function setHolderAddress(address _newHolder) external returns(State memory) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
currentState.holder = _newHolder;
return currentState;
}
function setFaucetAmount(uint256 _faucetAmount) external returns(State memory) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
currentState.faucetAmount = _faucetAmount;
return currentState;
}
function setMaxPageBuffer(uint256 _maxPageBuffer) external returns(State memory) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
currentState.maxPageBuffer = _maxPageBuffer;
return currentState;
}
function withdrawETHToOwner(uint256 _amount) external returns(bool) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
require(_amount > 0, "Error 400: Invalid Amount! Amount must be greater than 0.");
return _withdrawETHToOwner(_amount);
}
} | diemlibreFaucet | function diemlibreFaucet(address _faucetAddress) external returns(bool) {
require(sentAddresses[_faucetAddress] == false, "Error 501: Address has already been fauced with DLB.");
require(currentState.isInit, "Error 500: Contract Not Initialized or Contract Turned Off.");
uint256 tokenAllowance = DLB.allowance(currentState.holder, currentState.self);
require(currentState.faucetAmount > 0 && currentState.faucetAmount <= tokenAllowance, "Error 502: Insufficient Liquidity");
require(DLB.transferFrom(currentState.holder, _faucetAddress, currentState.faucetAmount), "Error 503: Oops... Could not complete Transaction. Please try again later.");
sentAddresses[_faucetAddress] = true;
savedAddresses.push(_faucetAddress);
return true;
}
| /**
* Method: faucet
* Des: To send a speicific amout of $DLB to addresses and you pay for gas.
**/ | NatSpecMultiLine | v0.8.4+commit.c7e474f2 | None | ipfs://cbb3ffbcc2acb76972873f4b1685f9ec2d863fb3c3973062e5e7ec769bce748b | {
"func_code_index": [
1461,
2297
]
} | 6,604 |
||
DiemlibreFaucet | DiemlibreFaucet.sol | 0x46c8f3059145e1b69acf2f926a5bcc1d1ad82129 | Solidity | DiemlibreFaucet | contract DiemlibreFaucet {
struct State {
bool isInit;
address self;
address owner;
address holder;
uint256 faucetAmount; // In smallest unit WEI
uint256 maxPageBuffer;
}
IERC20 DLB;
address[] savedAddresses;
mapping(address => bool) sentAddresses;
State currentState;
constructor(address _tokenAddress, address _holderAddress) {
require(_tokenAddress != address(0), "Error! Invalid Token Address.");
require(_holderAddress != address(0), "Error! Invalid Holder Address.");
require(_tokenAddress != _holderAddress, "Token Address and Spender Address cann't be the same.");
currentState = State({
isInit: false,
self: address(0),
owner: msg.sender,
holder: _holderAddress,
faucetAmount: 2000000000000000000000,
maxPageBuffer: 1000
});
DLB = IERC20(_tokenAddress);
}
function _withdrawETHToOwner(uint256 _amount) private returns(bool) {
payable(currentState.owner).transfer(_amount);
return true;
}
function getCurrentState() external view returns(State memory) {
return currentState;
}
/**
* Method: faucet
* Des: To send a speicific amout of $DLB to addresses and you pay for gas.
**/
function diemlibreFaucet(address _faucetAddress) external returns(bool) {
require(sentAddresses[_faucetAddress] == false, "Error 501: Address has already been fauced with DLB.");
require(currentState.isInit, "Error 500: Contract Not Initialized or Contract Turned Off.");
uint256 tokenAllowance = DLB.allowance(currentState.holder, currentState.self);
require(currentState.faucetAmount > 0 && currentState.faucetAmount <= tokenAllowance, "Error 502: Insufficient Liquidity");
require(DLB.transferFrom(currentState.holder, _faucetAddress, currentState.faucetAmount), "Error 503: Oops... Could not complete Transaction. Please try again later.");
sentAddresses[_faucetAddress] = true;
savedAddresses.push(_faucetAddress);
return true;
}
// Owner Functions
function init(address _selfAddress) external returns(bool) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
currentState.self = _selfAddress;
currentState.isInit = true;
return true;
}
function power(bool _state) external returns(State memory) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
currentState.isInit = _state;
return currentState;
}
function getSavedAddressesLength() external view returns(uint256) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
return savedAddresses.length;
}
function getSavedAddresses(uint256 _page) external view returns(address[] memory) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
require(_page >= 1, "Error 400: Invalid Page Number.");
uint256 i;
uint256 j = 0;
address[] memory res;
uint256 lowerLimit;
uint256 upperLimit;
uint256 tempUpperLimit = _page * currentState.maxPageBuffer;
if(savedAddresses.length < tempUpperLimit) {
if(savedAddresses.length < currentState.maxPageBuffer) lowerLimit = 0;
else lowerLimit = (_page - 1) * currentState.maxPageBuffer;
upperLimit = savedAddresses.length;
// If an unvailable page is requested lowerLimit will be greater than upperLimit
if(lowerLimit > upperLimit) return res;
// If lowerLimit == 0, then you should requesting for only page 1
if(lowerLimit == 0 && _page > 1) return res;
} else {
lowerLimit = (_page - 1) * currentState.maxPageBuffer;
upperLimit = tempUpperLimit;
}
uint256 resLength = upperLimit - lowerLimit;
res = new address[](resLength);
for(i = lowerLimit; i < upperLimit; i++) {
res[j] = savedAddresses[i];
j++;
}
return res;
}
function setHolderAddress(address _newHolder) external returns(State memory) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
currentState.holder = _newHolder;
return currentState;
}
function setFaucetAmount(uint256 _faucetAmount) external returns(State memory) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
currentState.faucetAmount = _faucetAmount;
return currentState;
}
function setMaxPageBuffer(uint256 _maxPageBuffer) external returns(State memory) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
currentState.maxPageBuffer = _maxPageBuffer;
return currentState;
}
function withdrawETHToOwner(uint256 _amount) external returns(bool) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
require(_amount > 0, "Error 400: Invalid Amount! Amount must be greater than 0.");
return _withdrawETHToOwner(_amount);
}
} | init | function init(address _selfAddress) external returns(bool) {
require(msg.sender == currentState.owner, "Error 401: Unauthorized Access.");
currentState.self = _selfAddress;
currentState.isInit = true;
return true;
}
| // Owner Functions | LineComment | v0.8.4+commit.c7e474f2 | None | ipfs://cbb3ffbcc2acb76972873f4b1685f9ec2d863fb3c3973062e5e7ec769bce748b | {
"func_code_index": [
2344,
2615
]
} | 6,605 |
||
BBT | BBT.sol | 0x4b2cc07661c7b69a4707277647727aa8898ffbde | Solidity | BBT | contract BBT is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
modifier onlyWhitelist() {
require(blacklist[msg.sender] == false);
_;
}
modifier canDistr() {
require(!distributionFinished);
_;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size + 4);
_;
}
// ------------------------------------------------------------------------
// airdrop params
// ------------------------------------------------------------------------
uint256 public _airdropAmount;
uint256 public _airdropTotal;
uint256 public _airdropSupply;
uint256 public _totalRemaining;
mapping(address => bool) initialized;
bool public distributionFinished = false;
mapping (address => bool) public blacklist;
event Distr(address indexed to, uint256 amount);
event DistrFinished();
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "BBT";
name = "BiBox";
decimals = 18;
_totalSupply = 1000000000 * 10 ** uint256(decimals);
_airdropAmount = 35000 * 10 ** uint256(decimals);
_airdropSupply = 300000000 * 10 ** uint256(decimals);
_totalRemaining = _airdropSupply;
balances[owner] = _totalSupply.sub(_airdropSupply);
emit Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public view returns (uint 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, uint tokens) onlyPayloadSize(2 * 32) public returns (bool success) {
require(to != address(0));
require(tokens <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public 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, uint tokens) onlyPayloadSize(3 * 32) public returns (bool success) {
require(tokens <= balances[from]);
require(tokens <= allowed[from][msg.sender]);
require(to != address(0));
balances[from] = balances[from].sub(tokens);
balances[to] = balances[to].add(tokens);
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 view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
// ------------------------------------------------------------------------
// Get the airdrop token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function getBalance(address _address) internal returns (uint256) {
if (_airdropTotal < _airdropSupply && !initialized[_address]) {
return balances[_address] + _airdropAmount;
} else {
return balances[_address];
}
}
// ------------------------------------------------------------------------
// internal private functions
// ------------------------------------------------------------------------
function distr(address _to, uint256 _amount) canDistr private returns (bool) {
_airdropTotal = _airdropTotal.add(_amount);
_totalRemaining = _totalRemaining.sub(_amount);
balances[_to] = balances[_to].add(_amount);
emit Distr(_to, _amount);
emit Transfer(address(0), _to, _amount);
if (_airdropTotal >= _airdropSupply) {
distributionFinished = true;
}
}
function () external payable {
getTokens();
}
function getTokens() payable canDistr onlyWhitelist public {
if (_airdropAmount > _totalRemaining) {
_airdropAmount = _totalRemaining;
}
require(_totalRemaining <= _totalRemaining);
distr(msg.sender, _airdropAmount);
if (_airdropAmount > 0) {
blacklist[msg.sender] = true;
}
if (_airdropTotal >= _airdropSupply) {
distributionFinished = true;
}
_airdropAmount = _airdropAmount.div(100000).mul(99999);
uint256 etherBalance = this.balance;
if (etherBalance > 0) {
owner.transfer(etherBalance);
}
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and a
// fixed supply
// ---------------------------------------------------------------------------- | LineComment | totalSupply | function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
| // ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------ | LineComment | v0.4.24+commit.e67f0147 | bzzr://f60236597425deaccb71e97847747c533f20c62a038dc91faefc0b2722993aca | {
"func_code_index": [
2053,
2172
]
} | 6,606 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.